Re: [PATCH v1 2/3] serial: 8250_exar: Refactor exar_shutdown()

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

 



Andy,

Correct me if I'm wrong here, but will that still work correctly?
That will break once the buffer on the exar chip is clear, but there
could potentially be characters still in the kernel
buffer(uart_circ_empty would not be true)

-Robert Middleton

On Fri, Aug 2, 2019 at 11:34 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> First of all, boolean variable should be assigned with boolean values.
> Second, it's not needed at all in this case.
>
> Drop unneeded boolean variable and use 'break' statement instead.
>
> While here, change iterations to be more visible by moving the number of them
> to the variable definition block.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 873aa6b0c2f3..f81d5c4fa232 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -169,19 +169,16 @@ static void xr17v35x_set_divisor(struct uart_port *p, unsigned int baud,
>  static void exar_shutdown(struct uart_port *port)
>  {
>         unsigned char lsr;
> -       bool tx_complete = 0;
>         struct uart_8250_port *up = up_to_u8250p(port);
>         struct circ_buf *xmit = &port->state->xmit;
> -       int i = 0;
> +       unsigned int i = 1000;
>
>         do {
>                 lsr = serial_in(up, UART_LSR);
>                 if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
> -                       tx_complete = 1;
> -               else
> -                       tx_complete = 0;
> +                       break;
>                 msleep(1);
> -       } while (!uart_circ_empty(xmit) && !tx_complete && i++ < 1000);
> +       } while (!uart_circ_empty(xmit) && --i);
>
>         serial8250_do_shutdown(port);
>  }
> --
> 2.20.1
>



[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