Skip to contentSkip to conversation

mmc: Use of_property_present() for non-boolean properties

PATCH In review Rob Herring (Arm) 4 participants 4 messages Nov 4, 2024 – Nov 8, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/mmc/host/mxcmmc.c          | 6 +++---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mxcmmc.c +3 -3
index 1edf65291354..dcb1a7336029 100644
@@ -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)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 8f0bc6dca2b0..cda1872769e0 100644
@@ -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);
Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 46 lines

-----Original Message-----
From: Rob Herring (Arm) <[email protected]>
Sent: 2024年11月5日 3:07
To: Ulf Hansson <[email protected]>; Adrian Hunter <[email protected]>; Bough Chen <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; dl-S32 <[email protected]>; [email protected]
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.

---
 drivers/mmc/host/mxcmmc.c          | 6 +++---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mxcmmc.c index renamed from drivers/mmc/host/mxcmmc.c +0 -0

1edf65291354..dcb1a7336029 100644

drivers/mmc/host/mxcmmc.c +3 -3
@@ -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);
drivers/mmc/host/mxcmmc.c +0 -0
 	if (ret)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index 8f0bc6dca2b0..cda1872769e0 100644

drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device · line 1633

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -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

Regards
Haibo Chen

Quoted 5 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
 		boarddata->wp_type = ESDHC_WP_GPIO;
 

of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step);
--
2.45.2

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rob Herring (Arm)

Hello Rob,

Quoted 5 lines · Rob Herring (Arm)

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

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

Quoted 10 lines
---
 drivers/mmc/host/mxcmmc.c          | 6 +++---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mxcmmc.c +0 -0
index 1edf65291354..dcb1a7336029 100644

drivers/mmc/host/mxcmmc.c static int mxcmci_probe(struct platform_device · line 1054

Quoted 10 lines
drivers/mmc/host/mxcmmc.c +3 -3
@@ -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.

Quoted 18 lines
drivers/mmc/host/mxcmmc.c +0 -0
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 8f0bc6dca2b0..cda1872769e0 100644
@@ -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);

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Rob Herring (Arm)
Quoted 5 lines · Rob Herring (Arm)

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

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

Quoted 10 lines
---
 drivers/mmc/host/mxcmmc.c          | 6 +++---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/mxcmmc.c +0 -0
index 1edf65291354..dcb1a7336029 100644

drivers/mmc/host/mxcmmc.c static int mxcmci_probe(struct platform_device *pdev) · line 1053

Quoted 9 lines
drivers/mmc/host/mxcmmc.c +3 -3
@@ -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

Quoted 16 lines
drivers/mmc/host/mxcmmc.c +0 -0
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index 8f0bc6dca2b0..cda1872769e0 100644
@@ -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);