diff mbox series

[V9,2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485

Message ID 20240118074003.2334348-3-manikanta.guntupalli@amd.com
State Superseded
Headers show
Series Add rs485 support to uartps driver | expand

Commit Message

Manikanta Guntupalli Jan. 18, 2024, 7:40 a.m. UTC
Relocate cdns_uart_tx_empty function to avoid prototype statement in
rs485 changes.
Update return check with uart_tx_stopped() in cdns_uart_handle_tx().

Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
---
Changes since V4:
This patch introduced in V4.

Changes for V5:
None.

Changes for V6:
None.

Changes for V7:
None.

Changes for V8:
None.

Changes for V9:
Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
Update description of cdns_uart_handle_tx() and add clear TX Empty interrupt
comment cdns_uart_start_tx().
---
 drivers/tty/serial/xilinx_uartps.c | 35 +++++++++++++++---------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Comments

Maarten Brock Jan. 22, 2024, 3:32 p.m. UTC | #1
> -----Original Message-----
> From: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> Sent: Thursday, 18 January 2024 08:40
> Subject: [PATCH V9 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to
> facilitate rs485
> 
> Relocate cdns_uart_tx_empty function to avoid prototype statement in
> rs485 changes.
> Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
> 
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> ---
> Changes for V9:
> Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
> Update description of cdns_uart_handle_tx() and add clear TX Empty interrupt
> comment cdns_uart_start_tx().
> ---
>  drivers/tty/serial/xilinx_uartps.c | 35 +++++++++++++++---------------
>  1 file changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
> index 920762d7b4a4..787c7cbc6600 100644
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -316,7 +331,7 @@ static void cdns_uart_handle_tx(void *dev_id)
>  	struct circ_buf *xmit = &port->state->xmit;
>  	unsigned int numbytes;
> 
> -	if (uart_circ_empty(xmit)) {
> +	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {

Can you please also insert a comment here?
+		/* Disable the TX Empty interrupt */

>  		writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR);
>  		return;
>  	}

Kind regards,
Maarten Brock
Maarten Brock Jan. 22, 2024, 4:49 p.m. UTC | #2
> -----Original Message-----
> From: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> Sent: Thursday, 18 January 2024 08:40
> Subject: [PATCH V9 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to
> facilitate rs485
> 
> Relocate cdns_uart_tx_empty function to avoid prototype statement in
> rs485 changes.
> Update return check with uart_tx_stopped() in cdns_uart_handle_tx().
> 
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
> ---
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -316,7 +331,7 @@ static void cdns_uart_handle_tx(void *dev_id)
>  	struct circ_buf *xmit = &port->state->xmit;
>  	unsigned int numbytes;
> 
> -	if (uart_circ_empty(xmit)) {
> +	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {

Can you please also insert a comment here?
+ 		/* Disable the TX Empty interrupt */

>  		writel(CDNS_UART_IXR_TXEMPTY, port->membase +
> CDNS_UART_IDR);
>  		return;
>  	}
 
Kind regards,
Maarten Brock
diff mbox series

Patch

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 920762d7b4a4..787c7cbc6600 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -306,7 +306,22 @@  static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus)
 }
 
 /**
- * cdns_uart_handle_tx - Handle the bytes to be Txed.
+ * cdns_uart_tx_empty -  Check whether TX is empty
+ * @port: Handle to the uart port structure
+ *
+ * Return: TIOCSER_TEMT on success, 0 otherwise
+ */
+static unsigned int cdns_uart_tx_empty(struct uart_port *port)
+{
+	unsigned int status;
+
+	status = readl(port->membase + CDNS_UART_SR);
+	status &= (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE);
+	return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0;
+}
+
+/**
+ * cdns_uart_handle_tx - Handle the bytes to be transmitted.
  * @dev_id: Id of the UART port
  * Return: None
  */
@@ -316,7 +331,7 @@  static void cdns_uart_handle_tx(void *dev_id)
 	struct circ_buf *xmit = &port->state->xmit;
 	unsigned int numbytes;
 
-	if (uart_circ_empty(xmit)) {
+	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
 		writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR);
 		return;
 	}
@@ -587,6 +602,7 @@  static void cdns_uart_start_tx(struct uart_port *port)
 	if (uart_circ_empty(&port->state->xmit))
 		return;
 
+	/* Clear the TX Empty interrupt */
 	writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR);
 
 	cdns_uart_handle_tx(port);
@@ -626,21 +642,6 @@  static void cdns_uart_stop_rx(struct uart_port *port)
 	writel(regval, port->membase + CDNS_UART_CR);
 }
 
-/**
- * cdns_uart_tx_empty -  Check whether TX is empty
- * @port: Handle to the uart port structure
- *
- * Return: TIOCSER_TEMT on success, 0 otherwise
- */
-static unsigned int cdns_uart_tx_empty(struct uart_port *port)
-{
-	unsigned int status;
-
-	status = readl(port->membase + CDNS_UART_SR) &
-		       (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE);
-	return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0;
-}
-
 /**
  * cdns_uart_break_ctl - Based on the input ctl we have to start or stop
  *			transmitting char breaks