All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: imx: remove a redundant check
@ 2023-02-11 15:45 ` Tom Rix
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rix @ 2023-02-11 15:45 UTC (permalink / raw)
  To: gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam, linux-imx
  Cc: linux-serial, linux-arm-kernel, linux-kernel, Tom Rix

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)) {
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] serial: imx: remove a redundant check
@ 2023-02-11 15:45 ` Tom Rix
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rix @ 2023-02-11 15:45 UTC (permalink / raw)
  To: gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam, linux-imx
  Cc: linux-serial, linux-arm-kernel, linux-kernel, Tom Rix

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)) {
 
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: imx: remove a redundant check
  2023-02-11 15:45 ` Tom Rix
@ 2023-02-11 17:48   ` Sergey Organov
  -1 siblings, 0 replies; 6+ messages in thread
From: Sergey Organov @ 2023-02-11 17:48 UTC (permalink / raw)
  To: Tom Rix
  Cc: gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam,
	linux-imx, linux-serial, linux-arm-kernel, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: imx: remove a redundant check
@ 2023-02-11 17:48   ` Sergey Organov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Organov @ 2023-02-11 17:48 UTC (permalink / raw)
  To: Tom Rix
  Cc: gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam,
	linux-imx, linux-serial, linux-arm-kernel, linux-kernel

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: imx: remove a redundant check
  2023-02-11 15:45 ` Tom Rix
@ 2023-02-13  8:46   ` Iuliana Prodan
  -1 siblings, 0 replies; 6+ messages in thread
From: Iuliana Prodan @ 2023-02-13  8:46 UTC (permalink / raw)
  To: Tom Rix, gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam,
	linux-imx
  Cc: linux-serial, linux-arm-kernel, linux-kernel

On 2/11/2023 5:45 PM, Tom Rix wrote:
> 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>

Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.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)) {
>   

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: imx: remove a redundant check
@ 2023-02-13  8:46   ` Iuliana Prodan
  0 siblings, 0 replies; 6+ messages in thread
From: Iuliana Prodan @ 2023-02-13  8:46 UTC (permalink / raw)
  To: Tom Rix, gregkh, jirislaby, shawnguo, s.hauer, kernel, festevam,
	linux-imx
  Cc: linux-serial, linux-arm-kernel, linux-kernel

On 2/11/2023 5:45 PM, Tom Rix wrote:
> 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>

Reviewed-by: Iuliana Prodan <iuliana.prodan@nxp.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)) {
>   

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-13  9:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 15:45 [PATCH] serial: imx: remove a redundant check Tom Rix
2023-02-11 15:45 ` Tom Rix
2023-02-11 17:48 ` Sergey Organov
2023-02-11 17:48   ` Sergey Organov
2023-02-13  8:46 ` Iuliana Prodan
2023-02-13  8:46   ` Iuliana Prodan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.