public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Organov <sorganov@gmail.com>
To: Tom Rix <trix@redhat.com>
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	shawnguo@kernel.org, s.hauer@pengutronix.de,
	kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] serial: imx: remove a redundant check
Date: Sat, 11 Feb 2023 20:48:00 +0300	[thread overview]
Message-ID: <87lel4hz5b.fsf@osv.gnss.ru> (raw)
In-Reply-To: <20230211154550.2130670-1-trix@redhat.com> (Tom Rix's message of "Sat, 11 Feb 2023 07:45:50 -0800")

Tom Rix <trix@redhat.com> writes:

> cpp_check reports
> drivers/tty/serial/imx.c:1207:15: style: Condition 'r_bytes>0' is always true [knownConditionTrueFalse]
>   if (r_bytes > 0) {
>
> r_byte is set to
>   r_bytes = rx_ring->head - rx_ring->tail;
>
> The head - tail calculation is also done by the earlier check
>   if (rx_ring->head <= sg_dma_len(sgl) &&
>       rx_ring->head > rx_ring->tail) {
>
> so r_bytes will always be > 0, so the second check is not needed.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  drivers/tty/serial/imx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 363c77a140f0..523f296d5747 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1204,11 +1204,9 @@ static void imx_uart_dma_rx_callback(void *data)
>  		r_bytes = rx_ring->head - rx_ring->tail;
>  
>  		/* If we received something, check for 0xff flood */
> -		if (r_bytes > 0) {
> -			spin_lock(&sport->port.lock);
> -			imx_uart_check_flood(sport, imx_uart_readl(sport, USR2));
> -			spin_unlock(&sport->port.lock);
> -		}
> +		spin_lock(&sport->port.lock);
> +		imx_uart_check_flood(sport, imx_uart_readl(sport, USR2));
> +		spin_unlock(&sport->port.lock);
>  
>  		if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ))
>  		{

Nice catch. Didn't notice this when wrote the check-flood patch, sorry!

Thanks,
-- Sergey Organov


  reply	other threads:[~2023-02-11 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11 15:45 [PATCH] serial: imx: remove a redundant check Tom Rix
2023-02-11 17:48 ` Sergey Organov [this message]
2023-02-13  8:46 ` Iuliana Prodan

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=87lel4hz5b.fsf@osv.gnss.ru \
    --to=sorganov@gmail.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=trix@redhat.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