2024-03-07 12:19:27

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/1] mmc: sdhci-s3c: Replace deprecated of_get_named_gpio()

It seems the of_get_named_gpio() is solely used to check
if the GPIO is present in DT as the function can return 0
if and only if it's present and it becomes in the global
number space 0. But this quite likely shows that the code
wasn't ever been tested on the systems when no GPIO is provided.
In any case, the proper test is just to call of_property_present()
without any attempts in requesting GPIO (as we haven't saved the
number or descriptor anywhere in the code).

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/mmc/host/sdhci-s3c.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 0e8a8ac14e56..6493b0edba34 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -17,10 +17,8 @@
#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/io.h>
-#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>

@@ -446,7 +444,7 @@ static int sdhci_s3c_parse_dt(struct device *dev,
return 0;
}

- if (of_get_named_gpio(node, "cd-gpios", 0))
+ if (of_property_present(node, "cd-gpios"))
return 0;

/* assuming internal card detect that will be configured by pinctrl */
--
2.43.0.rc1.1.gbec44491f096



2024-03-08 10:07:46

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] mmc: sdhci-s3c: Replace deprecated of_get_named_gpio()

On 7/03/24 14:19, Andy Shevchenko wrote:
> It seems the of_get_named_gpio() is solely used to check
> if the GPIO is present in DT as the function can return 0
> if and only if it's present and it becomes in the global
> number space 0. But this quite likely shows that the code
> wasn't ever been tested on the systems when no GPIO is provided.
> In any case, the proper test is just to call of_property_present()
> without any attempts in requesting GPIO (as we haven't saved the
> number or descriptor anywhere in the code).
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Looks to me like pdata->cd_type is zero either way, so it makes no
difference, unless of_get_named_gpio() has some side-effects.

Acked-by: Adrian Hunter <[email protected]>

> ---
> drivers/mmc/host/sdhci-s3c.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 0e8a8ac14e56..6493b0edba34 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -17,10 +17,8 @@
> #include <linux/slab.h>
> #include <linux/clk.h>
> #include <linux/io.h>
> -#include <linux/gpio.h>
> #include <linux/module.h>
> #include <linux/of.h>
> -#include <linux/of_gpio.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
>
> @@ -446,7 +444,7 @@ static int sdhci_s3c_parse_dt(struct device *dev,
> return 0;
> }
>
> - if (of_get_named_gpio(node, "cd-gpios", 0))
> + if (of_property_present(node, "cd-gpios"))
> return 0;
>
> /* assuming internal card detect that will be configured by pinctrl */


2024-03-25 15:52:10

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] mmc: sdhci-s3c: Replace deprecated of_get_named_gpio()

On Thu, 7 Mar 2024 at 13:19, Andy Shevchenko
<[email protected]> wrote:
>
> It seems the of_get_named_gpio() is solely used to check
> if the GPIO is present in DT as the function can return 0
> if and only if it's present and it becomes in the global
> number space 0. But this quite likely shows that the code
> wasn't ever been tested on the systems when no GPIO is provided.
> In any case, the proper test is just to call of_property_present()
> without any attempts in requesting GPIO (as we haven't saved the
> number or descriptor anywhere in the code).
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


> ---
> drivers/mmc/host/sdhci-s3c.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 0e8a8ac14e56..6493b0edba34 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -17,10 +17,8 @@
> #include <linux/slab.h>
> #include <linux/clk.h>
> #include <linux/io.h>
> -#include <linux/gpio.h>
> #include <linux/module.h>
> #include <linux/of.h>
> -#include <linux/of_gpio.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
>
> @@ -446,7 +444,7 @@ static int sdhci_s3c_parse_dt(struct device *dev,
> return 0;
> }
>
> - if (of_get_named_gpio(node, "cd-gpios", 0))
> + if (of_property_present(node, "cd-gpios"))
> return 0;
>
> /* assuming internal card detect that will be configured by pinctrl */
> --
> 2.43.0.rc1.1.gbec44491f096
>