linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>,
	Peter Hurley <peter@hurleysoftware.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Subject: Re: [PATCH] serial: core: remove silly test for uart_state
Date: Fri, 6 Jan 2017 19:22:43 +0200	[thread overview]
Message-ID: <CAHp75VeHbyp=9t290cxUSbFq0JRRrSwAJMmuLsR5H21cHeDwfg@mail.gmail.com> (raw)
In-Reply-To: <20170106024510.22369-1-cascardo@cascardo.eti.br>

On Fri, Jan 6, 2017 at 4:45 AM, Thadeu Lima de Souza Cascardo
<cascardo@cascardo.eti.br> wrote:
> The polling functions were checking for a NULL uart_state, which is
> indexed from uart_driver->state. It should be always allocated and
> non-NULL when the tty_driver is registered, and line should not be
> larger than the tty_driver->num anyways.

I'm not sure this is guaranteed. Let Peter to comment on it.

Peter, what is your opinion?

P.S. If Peter is okay with it, I don't see any problems with code itself either.

>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
> ---
>  drivers/tty/serial/serial_core.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 9939c3d9912b..6f7247114ef8 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -2330,9 +2330,6 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options)
>         int flow = 'n';
>         int ret = 0;
>
> -       if (!state)
> -               return -1;
> -
>         tport = &state->port;
>         mutex_lock(&tport->mutex);
>
> @@ -2367,12 +2364,10 @@ static int uart_poll_get_char(struct tty_driver *driver, int line)
>         struct uart_port *port;
>         int ret = -1;
>
> -       if (state) {
> -               port = uart_port_ref(state);
> -               if (port) {
> -                       ret = port->ops->poll_get_char(port);
> -                       uart_port_deref(port);
> -               }
> +       port = uart_port_ref(state);
> +       if (port) {
> +               ret = port->ops->poll_get_char(port);
> +               uart_port_deref(port);
>         }
>         return ret;
>  }
> @@ -2383,9 +2378,6 @@ static void uart_poll_put_char(struct tty_driver *driver, int line, char ch)
>         struct uart_state *state = drv->state + line;
>         struct uart_port *port;
>
> -       if (!state)
> -               return;
> -
>         port = uart_port_ref(state);
>         if (!port)
>                 return;
> --
> 2.11.0
>



-- 
With Best Regards,
Andy Shevchenko

      reply	other threads:[~2017-01-06 17:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06  2:45 [PATCH] serial: core: remove silly test for uart_state Thadeu Lima de Souza Cascardo
2017-01-06 17:22 ` Andy Shevchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHp75VeHbyp=9t290cxUSbFq0JRRrSwAJMmuLsR5H21cHeDwfg@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=cascardo@cascardo.eti.br \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).