Skip to contentSkip to conversation

mmc: Only retrieve cd pin when GPIO is enabled

PATCH New Harm Berntsen 3 participants 5 messages Oct 30, 2020 – Jan 19, 2021 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 mmc: Only retrieve cd pin when GPIO is enabled

The driver only needs to retrieve the pin for the ACPI info. The driver itself works without depending on GPIO.

---

?drivers/mmc/pci_mmc.c | 2 ++
?1 file changed, 2 insertions(+)

drivers/mmc/pci_mmc.c +0 -0
index 0c45e1b893..dba6324247 100644
@@ -52,9 +52,11 @@ static int pci_mmc_probe(struct udevice *dev)

?
?static int pci_mmc_ofdata_to_platdata(struct udevice *dev)
?{
+#if defined(CONFIG_DM_GPIO)
????????struct pci_mmc_priv *priv = dev_get_priv(dev);
?
????????gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN); +#endif
?
????????return 0;
?}

#1 lore raw

PATCH 3/3 mmc: Only retrieve cd pin when GPIO is enabled

Hi Harm,

Quoted 17 lines · Harm Berntsen

The driver only needs to retrieve the pin for the ACPI info. The driver itself works without depending on GPIO.

---

 drivers/mmc/pci_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/pci_mmc.c +0 -0
index 0c45e1b893..dba6324247 100644

drivers/mmc/pci_mmc.c static int pci_mmc_probe(struct udevice *dev) · line 55

Quoted 4 lines
drivers/mmc/pci_mmc.c +1 -0
@@ -52,9 +52,11 @@ static int pci_mmc_probe(struct udevice *dev)
 
 static int pci_mmc_ofdata_to_platdata(struct udevice *dev)
 {
+#if defined(CONFIG_DM_GPIO)

Can this be:

if (CONFIG_IS_ENABLED(DM_GPIO))

We try to avoid #ifdef in the code.

drivers/mmc/pci_mmc.c static int pci_mmc_probe(struct udevice *dev) · line 62

Quoted 8 lines
drivers/mmc/pci_mmc.c +1 -0
        struct pci_mmc_priv *priv = dev_get_priv(dev);
 
        gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
+#endif
 
        return 0;
 }

Regards,
Simon

#2 lore raw

PATCH v2 3/3 mmc: Only retrieve cd pin when GPIO is enabled

The driver only needs to retrieve the pin for the ACPI info. The driver itself works without depending on GPIO.

---
Changes for v2:
- Changed ifdef to if (CONFIG_IS_ENABLED(DM_GPIO))

 drivers/mmc/pci_mmc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/pci_mmc.c +4 -2
index 0c45e1b893..bd229693b0 100644
@@ -52,9 +52,11 @@ static int pci_mmc_probe(struct udevice *dev)
 
 static int pci_mmc_ofdata_to_platdata(struct udevice *dev)
 {
-	struct pci_mmc_priv *priv = dev_get_priv(dev);
+	if (CONFIG_IS_ENABLED(DM_GPIO)) {
+		struct pci_mmc_priv *priv = dev_get_priv(dev);
 
-	gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
+		gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
+	}
 
 	return 0;
 }
Signature · 1 line
2.29.2
#3 lore raw

PATCH v2 3/3 mmc: Only retrieve cd pin when GPIO is enabled

Hi Harm,

Quoted 18 lines · Harm Berntsen

The driver only needs to retrieve the pin for the ACPI info. The driver itself works without depending on GPIO.

---
Changes for v2:
- Changed ifdef to if (CONFIG_IS_ENABLED(DM_GPIO))

 drivers/mmc/pci_mmc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/pci_mmc.c +0 -0
index 0c45e1b893..bd229693b0 100644

drivers/mmc/pci_mmc.c static int pci_mmc_probe(struct udevice *dev) · line 59

Quoted 10 lines
drivers/mmc/pci_mmc.c +4 -2
@@ -52,9 +52,11 @@ static int pci_mmc_probe(struct udevice *dev)
 
 static int pci_mmc_ofdata_to_platdata(struct udevice *dev)
 {
-       struct pci_mmc_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(DM_GPIO)) {
+               struct pci_mmc_priv *priv = dev_get_priv(dev);
 
-       gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
+               gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
+       }

This should work OK since priv is cleared to zeroes on init

Quoted 7 lines
drivers/mmc/pci_mmc.c +0 -1
        return 0;
 }
 
--

2.29.2

#4 lore raw

PATCH v2 3/3 mmc: Only retrieve cd pin when GPIO is enabled

In reply to Harm Berntsen
Quoted 6 lines · Harm Berntsen

The driver only needs to retrieve the pin for the ACPI info. The driver itself works without depending on GPIO.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210119/e6518494/attachment.sig>