[v2] gpio: Use of_property_read_bool() for boolean properties

Message ID 20230314154117.477138-1-robh@kernel.org
State New
Headers
Series [v2] gpio: Use of_property_read_bool() for boolean properties |

Commit Message

Rob Herring March 14, 2023, 3:41 p.m. UTC
  It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties.
Convert reading boolean properties to to of_property_read_bool().

Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Actually use of_property_read_bool() as the commit msg says instead
   of of_property_present()
---
 drivers/gpio/gpio-stp-xway.c | 2 +-
 drivers/gpio/gpio-tb10x.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Linus Walleij March 14, 2023, 6:01 p.m. UTC | #1
On Tue, Mar 14, 2023 at 4:41 PM Rob Herring <robh@kernel.org> wrote:

> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties.
> Convert reading boolean properties to to of_property_read_bool().
>
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
  
Bartosz Golaszewski March 15, 2023, 9:43 a.m. UTC | #2
On Tue, Mar 14, 2023 at 4:41 PM Rob Herring <robh@kernel.org> wrote:
>
> It is preferred to use typed property access functions (i.e.
> of_property_read_<type> functions) rather than low-level
> of_get_property/of_find_property functions for reading properties.
> Convert reading boolean properties to to of_property_read_bool().
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> v2:
>  - Actually use of_property_read_bool() as the commit msg says instead
>    of of_property_present()
> ---
>  drivers/gpio/gpio-stp-xway.c | 2 +-
>  drivers/gpio/gpio-tb10x.c    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
> index 0ce1543426a4..4750ea34204c 100644
> --- a/drivers/gpio/gpio-stp-xway.c
> +++ b/drivers/gpio/gpio-stp-xway.c
> @@ -292,7 +292,7 @@ static int xway_stp_probe(struct platform_device *pdev)
>         }
>
>         /* check which edge trigger we should use, default to a falling edge */
> -       if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
> +       if (!of_property_read_bool(pdev->dev.of_node, "lantiq,rising"))
>                 chip->edge = XWAY_STP_FALLING;
>
>         clk = devm_clk_get(&pdev->dev, NULL);
> diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
> index de6afa3f9716..78f8790168ae 100644
> --- a/drivers/gpio/gpio-tb10x.c
> +++ b/drivers/gpio/gpio-tb10x.c
> @@ -167,7 +167,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
>
>         platform_set_drvdata(pdev, tb10x_gpio);
>
> -       if (of_find_property(np, "interrupt-controller", NULL)) {
> +       if (of_property_read_bool(np, "interrupt-controller")) {
>                 struct irq_chip_generic *gc;
>
>                 ret = platform_get_irq(pdev, 0);
> --
> 2.39.2
>

Applied, thanks!

Bart
  

Patch

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index 0ce1543426a4..4750ea34204c 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -292,7 +292,7 @@  static int xway_stp_probe(struct platform_device *pdev)
 	}
 
 	/* check which edge trigger we should use, default to a falling edge */
-	if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
+	if (!of_property_read_bool(pdev->dev.of_node, "lantiq,rising"))
 		chip->edge = XWAY_STP_FALLING;
 
 	clk = devm_clk_get(&pdev->dev, NULL);
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index de6afa3f9716..78f8790168ae 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -167,7 +167,7 @@  static int tb10x_gpio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, tb10x_gpio);
 
-	if (of_find_property(np, "interrupt-controller", NULL)) {
+	if (of_property_read_bool(np, "interrupt-controller")) {
 		struct irq_chip_generic *gc;
 
 		ret = platform_get_irq(pdev, 0);