linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mmc: mmci.c: Defer probe() in case of yet uninitialized GPIOs
@ 2012-06-16 16:49 Roland Stigge
  2012-06-16 17:23 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Stigge @ 2012-06-16 16:49 UTC (permalink / raw)
  To: linux-arm-kernel

If the GPIOs used by the MMCI driver are not registered yet when the driver is
probe()d, they can't be used. This happens if the mmci driver is probed before
the respective GPIO controller (e.g. on the LPC32xx EA3250 board, the PCA9532
GPIO controller would be initialized via DT after mmci). Therefore, we defer
mmci in this case.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 drivers/mmc/host/mmci.c |   30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

--- linux-2.6.orig/drivers/mmc/host/mmci.c
+++ linux-2.6/drivers/mmc/host/mmci.c
@@ -1215,13 +1215,21 @@ static void mmci_dt_populate_generic_pda
 {
 	int bus_width = 0;
 
-	pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0);
-	if (!pdata->gpio_wp)
-		pdata->gpio_wp = -1;
-
-	pdata->gpio_cd = of_get_named_gpio(np, "cd-gpios", 0);
-	if (!pdata->gpio_cd)
-		pdata->gpio_cd = -1;
+	if (of_get_property(np, "wp-gpios", NULL)) {
+		pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0);
+		if (pdata->gpio_wp == -ENODEV)
+			pdata->gpio_wp = -EPROBE_DEFER;
+	} else {
+		pdata->gpio_wp = -ENODEV;
+	}
+
+	if (of_get_property(np, "cd-gpios", NULL)) {
+		pdata->gpio_cd = of_get_named_gpio(np, "cd-gpios", 0);
+		if (pdata->gpio_cd == -ENODEV)
+			pdata->gpio_cd = -EPROBE_DEFER;
+	} else {
+		pdata->gpio_cd = -ENODEV;
+	}
 
 	if (of_get_property(np, "cd-inverted", NULL))
 		pdata->cd_invert = true;
@@ -1424,6 +1432,10 @@ static int __devinit mmci_probe(struct a
 	writel(0, host->base + MMCIMASK1);
 	writel(0xfff, host->base + MMCICLEAR);
 
+	if (plat->gpio_cd == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_gpio_cd;
+	}
 	if (gpio_is_valid(plat->gpio_cd)) {
 		ret = gpio_request(plat->gpio_cd, DRIVER_NAME " (cd)");
 		if (ret == 0)
@@ -1447,6 +1459,10 @@ static int __devinit mmci_probe(struct a
 		if (ret >= 0)
 			host->gpio_cd_irq = gpio_to_irq(plat->gpio_cd);
 	}
+	if (plat->gpio_wp == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_gpio_wp;
+	}
 	if (gpio_is_valid(plat->gpio_wp)) {
 		ret = gpio_request(plat->gpio_wp, DRIVER_NAME " (wp)");
 		if (ret == 0)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] mmc: mmci.c: Defer probe() in case of yet uninitialized GPIOs
  2012-06-16 16:49 [PATCH v2] mmc: mmci.c: Defer probe() in case of yet uninitialized GPIOs Roland Stigge
@ 2012-06-16 17:23 ` Arnd Bergmann
  2012-06-16 19:04   ` Roland Stigge
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2012-06-16 17:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 16 June 2012, Roland Stigge wrote:
> +       if (of_get_property(np, "wp-gpios", NULL)) {
> +               pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0);
> +               if (pdata->gpio_wp == -ENODEV)
> +                       pdata->gpio_wp = -EPROBE_DEFER;
> +       } else {
> +               pdata->gpio_wp = -ENODEV;
> +       }

This is still very ugly and there is a certain danfer that we might
have to duplicate this across more drivers. Can't we make
of_get_named_gpio_flags return -EPROBE_DEFER in cases where we can't
find the GPIO number yet but still have a chance of returning it at
a later point?

	Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] mmc: mmci.c: Defer probe() in case of yet uninitialized GPIOs
  2012-06-16 17:23 ` Arnd Bergmann
@ 2012-06-16 19:04   ` Roland Stigge
  0 siblings, 0 replies; 3+ messages in thread
From: Roland Stigge @ 2012-06-16 19:04 UTC (permalink / raw)
  To: linux-arm-kernel

On 16/06/12 19:23, Arnd Bergmann wrote:
> On Saturday 16 June 2012, Roland Stigge wrote:
>> +       if (of_get_property(np, "wp-gpios", NULL)) {
>> +               pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0);
>> +               if (pdata->gpio_wp == -ENODEV)
>> +                       pdata->gpio_wp = -EPROBE_DEFER;
>> +       } else {
>> +               pdata->gpio_wp = -ENODEV;
>> +       }
> 
> This is still very ugly and there is a certain danfer that we might
> have to duplicate this across more drivers. Can't we make
> of_get_named_gpio_flags return -EPROBE_DEFER in cases where we can't
> find the GPIO number yet but still have a chance of returning it at
> a later point?

OK, will post a new patch.

Roland

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-16 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-16 16:49 [PATCH v2] mmc: mmci.c: Defer probe() in case of yet uninitialized GPIOs Roland Stigge
2012-06-16 17:23 ` Arnd Bergmann
2012-06-16 19:04   ` Roland Stigge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).