diff mbox series

mmc: Use of_property_present() for non-boolean properties

Message ID 20241104190707.275758-1-robh@kernel.org
State New
Headers show
Series mmc: Use of_property_present() for non-boolean properties | expand

Commit Message

Rob Herring Nov. 4, 2024, 7:07 p.m. UTC
The use of of_property_read_bool() for non-boolean properties is
deprecated in favor of of_property_present() when testing for property
presence.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/mmc/host/mxcmmc.c          | 6 +++---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Bough Chen Nov. 5, 2024, 1:57 a.m. UTC | #1
> -----Original Message-----
> From: Rob Herring (Arm) <robh@kernel.org>
> Sent: 2024年11月5日 3:07
> To: Ulf Hansson <ulf.hansson@linaro.org>; Adrian Hunter
> <adrian.hunter@intel.com>; Bough Chen <haibo.chen@nxp.com>; Shawn Guo
> <shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Fabio Estevam
> <festevam@gmail.com>
> Cc: linux-mmc@vger.kernel.org; linux-kernel@vger.kernel.org;
> imx@lists.linux.dev; dl-S32 <S32@nxp.com>;
> linux-arm-kernel@lists.infradead.org
> Subject: [PATCH] mmc: Use of_property_present() for non-boolean properties
> 
> The use of of_property_read_bool() for non-boolean properties is deprecated in
> favor of of_property_present() when testing for property presence.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  drivers/mmc/host/mxcmmc.c          | 6 +++---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index
> 1edf65291354..dcb1a7336029 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -1048,9 +1048,9 @@ static int mxcmci_probe(struct platform_device
> *pdev)
> 
>  	if (pdata)
>  		dat3_card_detect = pdata->dat3_card_detect;
> -	else if (mmc_card_is_removable(mmc)
> -			&& !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
> -		dat3_card_detect = true;
> +	else
> +		dat3_card_detect = mmc_card_is_removable(mmc) &&
> +			!of_property_present(pdev->dev.of_node, "cd-gpios");
> 
>  	ret = mmc_regulator_get_supply(mmc);
>  	if (ret)
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 8f0bc6dca2b0..cda1872769e0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1629,7 +1629,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device
> *pdev,
>  	 * Retrieveing and requesting the actual WP GPIO will happen
>  	 * in the call to mmc_of_parse().
>  	 */
> -	if (of_property_read_bool(np, "wp-gpios"))
> +	if (of_property_present(np, "wp-gpios"))

For the change in sdhci-esdhc-imx.c

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>

Regards
Haibo Chen
>  		boarddata->wp_type = ESDHC_WP_GPIO;
> 
>  	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
> --
> 2.45.2
Dragan Simic Nov. 5, 2024, 6:29 a.m. UTC | #2
Hello Rob,

On 2024-11-04 20:07, Rob Herring (Arm) wrote:
> The use of of_property_read_bool() for non-boolean properties is
> deprecated in favor of of_property_present() when testing for property
> presence.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

Looking good to me, thanks for the patch!  See also a small nitpick 
below.

Reviewed-by: Dragan Simic <dsimic@manjaro.org>

> ---
>  drivers/mmc/host/mxcmmc.c          | 6 +++---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> index 1edf65291354..dcb1a7336029 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -1048,9 +1048,9 @@ static int mxcmci_probe(struct platform_device 
> *pdev)
> 
>  	if (pdata)
>  		dat3_card_detect = pdata->dat3_card_detect;
> -	else if (mmc_card_is_removable(mmc)
> -			&& !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
> -		dat3_card_detect = true;
> +	else
> +		dat3_card_detect = mmc_card_is_removable(mmc) &&
> +			!of_property_present(pdev->dev.of_node, "cd-gpios");

There's enough space in the allowed 100 columns to align "mmc_card_..."
and "!of_property_..." by indenting the latter further a bit.

> 
>  	ret = mmc_regulator_get_supply(mmc);
>  	if (ret)
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 8f0bc6dca2b0..cda1872769e0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1629,7 +1629,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device 
> *pdev,
>  	 * Retrieveing and requesting the actual WP GPIO will happen
>  	 * in the call to mmc_of_parse().
>  	 */
> -	if (of_property_read_bool(np, "wp-gpios"))
> +	if (of_property_present(np, "wp-gpios"))
>  		boarddata->wp_type = ESDHC_WP_GPIO;
> 
>  	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
Adrian Hunter Nov. 8, 2024, 8:46 a.m. UTC | #3
On 4/11/24 21:07, Rob Herring (Arm) wrote:
> The use of of_property_read_bool() for non-boolean properties is
> deprecated in favor of of_property_present() when testing for property
> presence.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

No longer applies cleanly to mmc next, and one minor comment
below otherwise:

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/mxcmmc.c          | 6 +++---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> index 1edf65291354..dcb1a7336029 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -1048,9 +1048,9 @@ static int mxcmci_probe(struct platform_device *pdev)
>  
>  	if (pdata)
>  		dat3_card_detect = pdata->dat3_card_detect;
> -	else if (mmc_card_is_removable(mmc)
> -			&& !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
> -		dat3_card_detect = true;
> +	else
> +		dat3_card_detect = mmc_card_is_removable(mmc) &&
> +			!of_property_present(pdev->dev.of_node, "cd-gpios");

dat3_card_detect no longer needs to be initialized to false

>  
>  	ret = mmc_regulator_get_supply(mmc);
>  	if (ret)
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 8f0bc6dca2b0..cda1872769e0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1629,7 +1629,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>  	 * Retrieveing and requesting the actual WP GPIO will happen
>  	 * in the call to mmc_of_parse().
>  	 */
> -	if (of_property_read_bool(np, "wp-gpios"))
> +	if (of_property_present(np, "wp-gpios"))
>  		boarddata->wp_type = ESDHC_WP_GPIO;
>  
>  	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
diff mbox series

Patch

diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 1edf65291354..dcb1a7336029 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -1048,9 +1048,9 @@  static int mxcmci_probe(struct platform_device *pdev)
 
 	if (pdata)
 		dat3_card_detect = pdata->dat3_card_detect;
-	else if (mmc_card_is_removable(mmc)
-			&& !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
-		dat3_card_detect = true;
+	else
+		dat3_card_detect = mmc_card_is_removable(mmc) &&
+			!of_property_present(pdev->dev.of_node, "cd-gpios");
 
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 8f0bc6dca2b0..cda1872769e0 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1629,7 +1629,7 @@  sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 	 * Retrieveing and requesting the actual WP GPIO will happen
 	 * in the call to mmc_of_parse().
 	 */
-	if (of_property_read_bool(np, "wp-gpios"))
+	if (of_property_present(np, "wp-gpios"))
 		boarddata->wp_type = ESDHC_WP_GPIO;
 
 	of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);