serial: ifx6x60: ifx_spi_write don't need to do mrdy_assert when fifo is not empty
authorJun Chen <jun.d.chen@intel.com>
Wed, 7 Nov 2012 17:04:04 +0000 (12:04 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Nov 2012 00:51:38 +0000 (16:51 -0800)
This patch check whether the fifo lenth is empty before writing new data to fifo.If condition
is true,ifx_spi_write need to trigger one mrdy_assert. If condition is false,the mrdy_assert
will be trigger by the next ifx_spi_io.

Cc: Bi Chao <chao.bi@intel.com>
Signed-off-by: Chen Jun <jun.d.chen@intel.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/ifx6x60.c

index 21eb70bcb6a0d80f4f0fc158ea8b4199fda8677e..1754c147a94c18e9ebb1b7901264db3bf1d35c4e 100644 (file)
@@ -508,9 +508,16 @@ static int ifx_spi_write(struct tty_struct *tty, const unsigned char *buf,
 {
        struct ifx_spi_device *ifx_dev = tty->driver_data;
        unsigned char *tmp_buf = (unsigned char *)buf;
-       int tx_count = kfifo_in_locked(&ifx_dev->tx_fifo, tmp_buf, count,
-                                  &ifx_dev->fifo_lock);
-       mrdy_assert(ifx_dev);
+       unsigned long flags;
+       bool is_fifo_empty;
+
+       spin_lock_irqsave(&ifx_dev->fifo_lock, flags);
+       is_fifo_empty = kfifo_is_empty(&ifx_dev->tx_fifo);
+       int tx_count = kfifo_in(&ifx_dev->tx_fifo, tmp_buf, count);
+       spin_unlock_irqrestore(&ifx_dev->fifo_lock, flags);
+       if (is_fifo_empty)
+               mrdy_assert(ifx_dev);
+
        return tx_count;
 }