mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough
@ 2022-08-23 14:18 Ilpo Järvinen
  2022-08-23 14:18 ` [PATCH 2/3] serial: sh-sci: tail is already on valid range Ilpo Järvinen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2022-08-23 14:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
  Cc: Ilpo Järvinen

Testing also CIRC_CNT() with CIRC_CNT_TO_END() is unnecessary because
to latter alone covers all necessary cases.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/sh-sci.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 0075a1420005..6d2f5a08ff1f 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1408,9 +1408,7 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
 	head = xmit->head;
 	tail = xmit->tail;
 	buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
-	s->tx_dma_len = min_t(unsigned int,
-		CIRC_CNT(head, tail, UART_XMIT_SIZE),
-		CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE));
+	s->tx_dma_len = CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE);
 	if (!s->tx_dma_len) {
 		/* Transmit buffer has been flushed */
 		spin_unlock_irq(&port->lock);
-- 
2.30.2


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

* [PATCH 2/3] serial: sh-sci: tail is already on valid range
  2022-08-23 14:18 [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough Ilpo Järvinen
@ 2022-08-23 14:18 ` Ilpo Järvinen
  2022-08-30  6:46   ` Jiri Slaby
  2022-08-23 14:18 ` [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough Ilpo Järvinen
  2022-08-30  6:45 ` [PATCH 1/3] serial: sh-sci: " Jiri Slaby
  2 siblings, 1 reply; 6+ messages in thread
From: Ilpo Järvinen @ 2022-08-23 14:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
  Cc: Ilpo Järvinen

There is no need to and tail with UART_XMIT_SIZE - 1 because tail is
already on valid range.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/sh-sci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 6d2f5a08ff1f..2ddcd7eec71e 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1407,7 +1407,7 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
 	spin_lock_irq(&port->lock);
 	head = xmit->head;
 	tail = xmit->tail;
-	buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
+	buf = s->tx_dma_addr + tail;
 	s->tx_dma_len = CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE);
 	if (!s->tx_dma_len) {
 		/* Transmit buffer has been flushed */
-- 
2.30.2


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

* [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough
  2022-08-23 14:18 [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough Ilpo Järvinen
  2022-08-23 14:18 ` [PATCH 2/3] serial: sh-sci: tail is already on valid range Ilpo Järvinen
@ 2022-08-23 14:18 ` Ilpo Järvinen
  2022-08-30  6:46   ` Jiri Slaby
  2022-08-30  6:45 ` [PATCH 1/3] serial: sh-sci: " Jiri Slaby
  2 siblings, 1 reply; 6+ messages in thread
From: Ilpo Järvinen @ 2022-08-23 14:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
  Cc: Ilpo Järvinen

Testing also CIRC_CNT() with CIRC_CNT_TO_END() is unnecessary because
to latter alone covers all necessary cases.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/pch_uart.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 8a9065e4a903..116a2e76093d 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -898,9 +898,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)
 		fifo_size--;
 	}
 
-	bytes = min((int)CIRC_CNT(xmit->head, xmit->tail,
-			     UART_XMIT_SIZE), CIRC_CNT_TO_END(xmit->head,
-			     xmit->tail, UART_XMIT_SIZE));
+	bytes = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
 	if (!bytes) {
 		dev_dbg(priv->port.dev, "%s 0 bytes return\n", __func__);
 		pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_TX_INT);
-- 
2.30.2


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

* Re: [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough
  2022-08-23 14:18 [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough Ilpo Järvinen
  2022-08-23 14:18 ` [PATCH 2/3] serial: sh-sci: tail is already on valid range Ilpo Järvinen
  2022-08-23 14:18 ` [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough Ilpo Järvinen
@ 2022-08-30  6:45 ` Jiri Slaby
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Slaby @ 2022-08-30  6:45 UTC (permalink / raw)
  To: Ilpo Järvinen, Greg Kroah-Hartman, linux-serial, linux-kernel

On 23. 08. 22, 16:18, Ilpo Järvinen wrote:
> Testing also CIRC_CNT() with CIRC_CNT_TO_END() is unnecessary because
> to latter alone covers all necessary cases.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   drivers/tty/serial/sh-sci.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 0075a1420005..6d2f5a08ff1f 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1408,9 +1408,7 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
>   	head = xmit->head;
>   	tail = xmit->tail;
>   	buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
> -	s->tx_dma_len = min_t(unsigned int,
> -		CIRC_CNT(head, tail, UART_XMIT_SIZE),
> -		CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE));
> +	s->tx_dma_len = CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE);
>   	if (!s->tx_dma_len) {
>   		/* Transmit buffer has been flushed */
>   		spin_unlock_irq(&port->lock);

-- 
js
suse labs


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

* Re: [PATCH 2/3] serial: sh-sci: tail is already on valid range
  2022-08-23 14:18 ` [PATCH 2/3] serial: sh-sci: tail is already on valid range Ilpo Järvinen
@ 2022-08-30  6:46   ` Jiri Slaby
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Slaby @ 2022-08-30  6:46 UTC (permalink / raw)
  To: Ilpo Järvinen, Greg Kroah-Hartman, linux-serial, linux-kernel

On 23. 08. 22, 16:18, Ilpo Järvinen wrote:
> There is no need to and tail with UART_XMIT_SIZE - 1 because tail is
> already on valid range.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   drivers/tty/serial/sh-sci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 6d2f5a08ff1f..2ddcd7eec71e 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1407,7 +1407,7 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
>   	spin_lock_irq(&port->lock);
>   	head = xmit->head;
>   	tail = xmit->tail;
> -	buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
> +	buf = s->tx_dma_addr + tail;
>   	s->tx_dma_len = CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE);
>   	if (!s->tx_dma_len) {
>   		/* Transmit buffer has been flushed */

-- 
js
suse labs


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

* Re: [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough
  2022-08-23 14:18 ` [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough Ilpo Järvinen
@ 2022-08-30  6:46   ` Jiri Slaby
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Slaby @ 2022-08-30  6:46 UTC (permalink / raw)
  To: Ilpo Järvinen, Greg Kroah-Hartman, linux-serial, linux-kernel

On 23. 08. 22, 16:18, Ilpo Järvinen wrote:
> Testing also CIRC_CNT() with CIRC_CNT_TO_END() is unnecessary because
> to latter alone covers all necessary cases.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>   drivers/tty/serial/pch_uart.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
> index 8a9065e4a903..116a2e76093d 100644
> --- a/drivers/tty/serial/pch_uart.c
> +++ b/drivers/tty/serial/pch_uart.c
> @@ -898,9 +898,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)
>   		fifo_size--;
>   	}
>   
> -	bytes = min((int)CIRC_CNT(xmit->head, xmit->tail,
> -			     UART_XMIT_SIZE), CIRC_CNT_TO_END(xmit->head,
> -			     xmit->tail, UART_XMIT_SIZE));
> +	bytes = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
>   	if (!bytes) {
>   		dev_dbg(priv->port.dev, "%s 0 bytes return\n", __func__);
>   		pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_TX_INT);

-- 
js
suse labs


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

end of thread, other threads:[~2022-08-30  6:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 14:18 [PATCH 1/3] serial: sh-sci: CIRC_CNT_TO_END() is enough Ilpo Järvinen
2022-08-23 14:18 ` [PATCH 2/3] serial: sh-sci: tail is already on valid range Ilpo Järvinen
2022-08-30  6:46   ` Jiri Slaby
2022-08-23 14:18 ` [PATCH 3/3] serial: pch_uart: CIRC_CNT_TO_END() is enough Ilpo Järvinen
2022-08-30  6:46   ` Jiri Slaby
2022-08-30  6:45 ` [PATCH 1/3] serial: sh-sci: " Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®