linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties
@ 2025-01-09 18:20 Rob Herring (Arm)
  2025-01-10  8:13 ` Richard GENOUD
  2025-01-10  9:32 ` Nicolas Ferre
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring (Arm) @ 2025-01-09 18:20 UTC (permalink / raw)
  To: Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea
  Cc: linux-kernel, linux-serial, linux-arm-kernel

The use of of_property_read_bool() for non-boolean properties is
deprecated in favor of of_property_present() when testing for property
presence.

As of_property_present() returns a boolean, use that directly
and simplify the code a bit while we're here.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/tty/serial/atmel_serial.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 0cf05ac18993..f44f9d20a974 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1727,26 +1727,16 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port,
 
 	/* DMA/PDC usage specification */
 	if (of_property_read_bool(np, "atmel,use-dma-rx")) {
-		if (of_property_read_bool(np, "dmas")) {
-			atmel_port->use_dma_rx  = true;
-			atmel_port->use_pdc_rx  = false;
-		} else {
-			atmel_port->use_dma_rx  = false;
-			atmel_port->use_pdc_rx  = true;
-		}
+		atmel_port->use_dma_rx = of_property_present(np, "dmas");
+		atmel_port->use_pdc_rx = !atmel_port->use_dma_rx;
 	} else {
 		atmel_port->use_dma_rx  = false;
 		atmel_port->use_pdc_rx  = false;
 	}
 
 	if (of_property_read_bool(np, "atmel,use-dma-tx")) {
-		if (of_property_read_bool(np, "dmas")) {
-			atmel_port->use_dma_tx  = true;
-			atmel_port->use_pdc_tx  = false;
-		} else {
-			atmel_port->use_dma_tx  = false;
-			atmel_port->use_pdc_tx  = true;
-		}
+		atmel_port->use_dma_tx = of_property_present(np, "dmas");
+		atmel_port->use_pdc_tx = !atmel_port->use_dma_tx;
 	} else {
 		atmel_port->use_dma_tx  = false;
 		atmel_port->use_pdc_tx  = false;
-- 
2.45.2



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

* Re: [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties
  2025-01-09 18:20 [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties Rob Herring (Arm)
@ 2025-01-10  8:13 ` Richard GENOUD
  2025-01-10  9:32 ` Nicolas Ferre
  1 sibling, 0 replies; 3+ messages in thread
From: Richard GENOUD @ 2025-01-10  8:13 UTC (permalink / raw)
  To: Rob Herring (Arm), Greg Kroah-Hartman, Jiri Slaby, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea
  Cc: linux-kernel, linux-serial, linux-arm-kernel

Le 09/01/2025 à 19:20, Rob Herring (Arm) a écrit :
> The use of of_property_read_bool() for non-boolean properties is
> deprecated in favor of of_property_present() when testing for property
> presence.
> 
> As of_property_present() returns a boolean, use that directly
> and simplify the code a bit while we're here.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>   drivers/tty/serial/atmel_serial.c | 18 ++++--------------
>   1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 0cf05ac18993..f44f9d20a974 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -1727,26 +1727,16 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port,
>   
>   	/* DMA/PDC usage specification */
>   	if (of_property_read_bool(np, "atmel,use-dma-rx")) {
> -		if (of_property_read_bool(np, "dmas")) {
> -			atmel_port->use_dma_rx  = true;
> -			atmel_port->use_pdc_rx  = false;
> -		} else {
> -			atmel_port->use_dma_rx  = false;
> -			atmel_port->use_pdc_rx  = true;
> -		}
> +		atmel_port->use_dma_rx = of_property_present(np, "dmas");
> +		atmel_port->use_pdc_rx = !atmel_port->use_dma_rx;
>   	} else {
>   		atmel_port->use_dma_rx  = false;
>   		atmel_port->use_pdc_rx  = false;
>   	}
>   
>   	if (of_property_read_bool(np, "atmel,use-dma-tx")) {
> -		if (of_property_read_bool(np, "dmas")) {
> -			atmel_port->use_dma_tx  = true;
> -			atmel_port->use_pdc_tx  = false;
> -		} else {
> -			atmel_port->use_dma_tx  = false;
> -			atmel_port->use_pdc_tx  = true;
> -		}
> +		atmel_port->use_dma_tx = of_property_present(np, "dmas");
> +		atmel_port->use_pdc_tx = !atmel_port->use_dma_tx;
>   	} else {
>   		atmel_port->use_dma_tx  = false;
>   		atmel_port->use_pdc_tx  = false;

Acked-by: Richard Genoud <richard.genoud@bootlin.com>

The code is indeed nicer like that!
Thanks!

Regards,
Richard


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

* Re: [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties
  2025-01-09 18:20 [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties Rob Herring (Arm)
  2025-01-10  8:13 ` Richard GENOUD
@ 2025-01-10  9:32 ` Nicolas Ferre
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2025-01-10  9:32 UTC (permalink / raw)
  To: Rob Herring (Arm), Richard Genoud, Greg Kroah-Hartman, Jiri Slaby,
	Alexandre Belloni, Claudiu Beznea
  Cc: linux-kernel, linux-serial, linux-arm-kernel

On 09/01/2025 at 19:20, Rob Herring (Arm) wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The use of of_property_read_bool() for non-boolean properties is
> deprecated in favor of of_property_present() when testing for property
> presence.
> 
> As of_property_present() returns a boolean, use that directly
> and simplify the code a bit while we're here.

Indeed! Thanks Rob.

Reviewed-by: Nicolas Ferre <nicolas.ferre@microchip.com>


> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>   drivers/tty/serial/atmel_serial.c | 18 ++++--------------
>   1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 0cf05ac18993..f44f9d20a974 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -1727,26 +1727,16 @@ static void atmel_init_property(struct atmel_uart_port *atmel_port,
> 
>          /* DMA/PDC usage specification */
>          if (of_property_read_bool(np, "atmel,use-dma-rx")) {
> -               if (of_property_read_bool(np, "dmas")) {
> -                       atmel_port->use_dma_rx  = true;
> -                       atmel_port->use_pdc_rx  = false;
> -               } else {
> -                       atmel_port->use_dma_rx  = false;
> -                       atmel_port->use_pdc_rx  = true;
> -               }
> +               atmel_port->use_dma_rx = of_property_present(np, "dmas");
> +               atmel_port->use_pdc_rx = !atmel_port->use_dma_rx;
>          } else {
>                  atmel_port->use_dma_rx  = false;
>                  atmel_port->use_pdc_rx  = false;
>          }
> 
>          if (of_property_read_bool(np, "atmel,use-dma-tx")) {
> -               if (of_property_read_bool(np, "dmas")) {
> -                       atmel_port->use_dma_tx  = true;
> -                       atmel_port->use_pdc_tx  = false;
> -               } else {
> -                       atmel_port->use_dma_tx  = false;
> -                       atmel_port->use_pdc_tx  = true;
> -               }
> +               atmel_port->use_dma_tx = of_property_present(np, "dmas");
> +               atmel_port->use_pdc_tx = !atmel_port->use_dma_tx;
>          } else {
>                  atmel_port->use_dma_tx  = false;
>                  atmel_port->use_pdc_tx  = false;
> --
> 2.45.2
> 



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

end of thread, other threads:[~2025-01-10  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 18:20 [PATCH] tty: atmel_serial: Use of_property_present() for non-boolean properties Rob Herring (Arm)
2025-01-10  8:13 ` Richard GENOUD
2025-01-10  9:32 ` Nicolas Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).