Little patch for sc16is7xx.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I am working on a board with a nxp sc16is740 and am using the
driver for this. I noticed that when closing a connection the driver
would query the tx level repeatedly and this was caused by this
procedure:

static unsigned int sc16is7xx_tx_empty(struct uart_port *port)
{
        unsigned int lvl, lsr;

        lvl = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG);
        lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG);

        return ((lsr & SC16IS7XX_LSR_THRE_BIT) && !lvl) ? TIOCSER_TEMT : 0;
}

The lvl variable seems to contain the number of bytes in the FIFO but
in reality it contains the number of free places in the FIFO. So the
fix I want to propose is this:

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index df9a384..0e59860 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -699,7 +699,7 @@ static unsigned int sc16is7xx_tx_empty(struct
uart_port *port)
 {
        unsigned int lvl, lsr;

-       lvl = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG);
+       lvl = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG) -
SC16IS7XX_FIFO_SIZE;
        lsr = sc16is7xx_port_read(port, SC16IS7XX_LSR_REG);

        return ((lsr & SC16IS7XX_LSR_THRE_BIT) && !lvl) ? TIOCSER_TEMT : 0;

Regards
Michel Vos
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux