diff mbox

[v2,3/8] tty: serial: qcom_geni_serial: Use min3 to find minimum of 3 values

Message ID 1523302721-19439-4-git-send-email-kramasub@codeaurora.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Karthikeyan Ramasubramanian April 9, 2018, 7:38 p.m. UTC
Use min3 helper to calculate the minimum value of 3 variables.

Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
---
 drivers/tty/serial/qcom_geni_serial.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Matthias Kaehlcke April 12, 2018, 10:40 p.m. UTC | #1
On Mon, Apr 09, 2018 at 01:38:36PM -0600, Karthikeyan Ramasubramanian wrote:
> Use min3 helper to calculate the minimum value of 3 variables.
> 
> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
> ---
>  drivers/tty/serial/qcom_geni_serial.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index ae959d6..21e9160 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -586,11 +586,7 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport)
>  
>  	avail = (port->tx_fifo_depth - port->tx_wm) * port->tx_bytes_pw;
>  	tail = (xmit->tail + port->xmit_size) & (UART_XMIT_SIZE - 1);
> -	if (chunk > (UART_XMIT_SIZE - tail))
> -		chunk = UART_XMIT_SIZE - tail;
> -	if (chunk > avail)
> -		chunk = avail;
> -
> +	chunk = min3((size_t)chunk, UART_XMIT_SIZE - tail, avail);
>  	if (!chunk)
>  		goto out_write_wakeup;

Reviewed-by: Matthias Kaehlcke <mka@chromium.org
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Boyd April 17, 2018, 6:04 a.m. UTC | #2
Quoting Karthikeyan Ramasubramanian (2018-04-09 12:38:36)
> Use min3 helper to calculate the minimum value of 3 variables.
> 
> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index ae959d6..21e9160 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -586,11 +586,7 @@  static void qcom_geni_serial_handle_tx(struct uart_port *uport)
 
 	avail = (port->tx_fifo_depth - port->tx_wm) * port->tx_bytes_pw;
 	tail = (xmit->tail + port->xmit_size) & (UART_XMIT_SIZE - 1);
-	if (chunk > (UART_XMIT_SIZE - tail))
-		chunk = UART_XMIT_SIZE - tail;
-	if (chunk > avail)
-		chunk = avail;
-
+	chunk = min3((size_t)chunk, UART_XMIT_SIZE - tail, avail);
 	if (!chunk)
 		goto out_write_wakeup;