2024-01-10 10:25:16

by Tudor Ambarus

[permalink] [raw]
Subject: [PATCH 14/18] tty: serial: samsung: return bool for s3c24xx_serial_console_txrdy()

s3c24xx_serial_console_txrdy() returned just 0 or 1 to indicate whether
the TX is empty or not. Change its return type to bool.

Signed-off-by: Tudor Ambarus <[email protected]>
---
drivers/tty/serial/samsung_tty.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 63e993bed296..37c0ba2a122c 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2183,7 +2183,7 @@ static const struct dev_pm_ops s3c24xx_serial_pm_ops = {

static struct uart_port *cons_uart;

-static int
+static bool
s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
{
const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
@@ -2193,13 +2193,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
/* fifo mode - check amount of data in fifo registers... */

ufstat = rd_regl(port, S3C2410_UFSTAT);
- return (ufstat & info->tx_fifofull) ? 0 : 1;
+ return !(ufstat & info->tx_fifofull);
}

/* in non-fifo mode, we go and use the tx buffer empty */

utrstat = rd_regl(port, S3C2410_UTRSTAT);
- return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
+ return !!(utrstat & S3C2410_UTRSTAT_TXE);
}

static bool
--
2.43.0.472.g3155946c3a-goog



2024-01-16 18:55:07

by Sam Protsenko

[permalink] [raw]
Subject: Re: [PATCH 14/18] tty: serial: samsung: return bool for s3c24xx_serial_console_txrdy()

On Wed, Jan 10, 2024 at 4:25 AM Tudor Ambarus <tudor.ambarus@linaroorg> wrote:
>
> s3c24xx_serial_console_txrdy() returned just 0 or 1 to indicate whether
> the TX is empty or not. Change its return type to bool.
>
> Signed-off-by: Tudor Ambarus <[email protected]>
> ---
> drivers/tty/serial/samsung_tty.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
> index 63e993bed296..37c0ba2a122c 100644
> --- a/drivers/tty/serial/samsung_tty.c
> +++ b/drivers/tty/serial/samsung_tty.c
> @@ -2183,7 +2183,7 @@ static const struct dev_pm_ops s3c24xx_serial_pm_ops = {
>
> static struct uart_port *cons_uart;
>
> -static int
> +static bool
> s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
> {
> const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
> @@ -2193,13 +2193,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
> /* fifo mode - check amount of data in fifo registers... */
>
> ufstat = rd_regl(port, S3C2410_UFSTAT);
> - return (ufstat & info->tx_fifofull) ? 0 : 1;
> + return !(ufstat & info->tx_fifofull);
> }
>
> /* in non-fifo mode, we go and use the tx buffer empty */
>
> utrstat = rd_regl(port, S3C2410_UTRSTAT);
> - return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
> + return !!(utrstat & S3C2410_UTRSTAT_TXE);

Again, personally I think !! is just clutters the code here, as the
function already returns bool. Other than that:

Reviewed-by: Sam Protsenko <[email protected]>

> }
>
> static bool
> --
> 2.43.0.472.g3155946c3a-goog
>
>

2024-01-17 15:57:48

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH 14/18] tty: serial: samsung: return bool for s3c24xx_serial_console_txrdy()



On 1/16/24 18:54, Sam Protsenko wrote:
> On Wed, Jan 10, 2024 at 4:25 AM Tudor Ambarus <[email protected]> wrote:
>>
>> s3c24xx_serial_console_txrdy() returned just 0 or 1 to indicate whether
>> the TX is empty or not. Change its return type to bool.
>>
>> Signed-off-by: Tudor Ambarus <[email protected]>
>> ---
>> drivers/tty/serial/samsung_tty.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
>> index 63e993bed296..37c0ba2a122c 100644
>> --- a/drivers/tty/serial/samsung_tty.c
>> +++ b/drivers/tty/serial/samsung_tty.c
>> @@ -2183,7 +2183,7 @@ static const struct dev_pm_ops s3c24xx_serial_pm_ops = {
>>
>> static struct uart_port *cons_uart;
>>
>> -static int
>> +static bool
>> s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
>> {
>> const struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
>> @@ -2193,13 +2193,13 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, u32 ufcon)
>> /* fifo mode - check amount of data in fifo registers... */
>>
>> ufstat = rd_regl(port, S3C2410_UFSTAT);
>> - return (ufstat & info->tx_fifofull) ? 0 : 1;
>> + return !(ufstat & info->tx_fifofull);
>> }
>>
>> /* in non-fifo mode, we go and use the tx buffer empty */
>>
>> utrstat = rd_regl(port, S3C2410_UTRSTAT);
>> - return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
>> + return !!(utrstat & S3C2410_UTRSTAT_TXE);
>
> Again, personally I think !! is just clutters the code here, as the
> function already returns bool. Other than that:
>

Indeed, I'll update. Thanks!
ta