linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred
@ 2012-06-18 17:22 Roland Stigge
  2012-06-18 17:26 ` Stephen Warren
  2012-06-18 17:29 ` Alexandre Pereira da Silva
  0 siblings, 2 replies; 3+ messages in thread
From: Roland Stigge @ 2012-06-18 17:22 UTC (permalink / raw)
  To: linux-arm-kernel

of_get_named_gpio_flags() and of_get_named_gpio() return -EPROBE_DEFER if the
respective GPIO is not (yet) available. This is useful if driver's probe()
functions try to get a GPIO whose controller isn't probed yet. Thus, the driver
can be probed again later on.

The function still returns -EINVAL on other errors (parse error or node doesn't
exist). This way, the case of an optional/intentionally missing GPIO is handled
appropriately.

For this change, two sound drivers (tegra_{alc5632,wm8903}) need to be
adjusted.

Signed-off-by: Roland Stigge <stigge@antcom.de>
---
 drivers/gpio/gpiolib-of.c       |    5 ++++-
 sound/soc/tegra/tegra_alc5632.c |    2 +-
 sound/soc/tegra/tegra_wm8903.c  |   10 +++++-----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index d18068a..9f84fad 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -62,7 +62,10 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
 int of_get_named_gpio_flags(struct device_node *np, const char *propname,
                            int index, enum of_gpio_flags *flags)
 {
-	struct gg_data gg_data = { .flags = flags, .out_gpio = -ENODEV };
+	/* Return -EPROBE_DEFER to support probe() functions to be called
+	 * later when the GPIO actually becomes available
+	 */
+	struct gg_data gg_data = { .flags = flags, .out_gpio = -EPROBE_DEFER };
 	int ret;
 
 	/* .of_xlate might decide to not fill in the flags, so clear it. */
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index d684df2..e463529 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -177,7 +177,7 @@ static __devinit int tegra_alc5632_probe(struct platform_device *pdev)
 	}
 
 	alc5632->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0);
-	if (alc5632->gpio_hp_det == -ENODEV)
+	if (alc5632->gpio_hp_det == -EPROBE_DEFER)
 		return -EPROBE_DEFER;
 
 	ret = snd_soc_of_parse_card_name(card, "nvidia,model");
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index 0c5bb33..d4f14e4 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -284,27 +284,27 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
 	} else if (np) {
 		pdata->gpio_spkr_en = of_get_named_gpio(np,
 						"nvidia,spkr-en-gpios", 0);
-		if (pdata->gpio_spkr_en == -ENODEV)
+		if (pdata->gpio_spkr_en == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
 		pdata->gpio_hp_mute = of_get_named_gpio(np,
 						"nvidia,hp-mute-gpios", 0);
-		if (pdata->gpio_hp_mute == -ENODEV)
+		if (pdata->gpio_hp_mute == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
 		pdata->gpio_hp_det = of_get_named_gpio(np,
 						"nvidia,hp-det-gpios", 0);
-		if (pdata->gpio_hp_det == -ENODEV)
+		if (pdata->gpio_hp_det == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
 		pdata->gpio_int_mic_en = of_get_named_gpio(np,
 						"nvidia,int-mic-en-gpios", 0);
-		if (pdata->gpio_int_mic_en == -ENODEV)
+		if (pdata->gpio_int_mic_en == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 
 		pdata->gpio_ext_mic_en = of_get_named_gpio(np,
 						"nvidia,ext-mic-en-gpios", 0);
-		if (pdata->gpio_ext_mic_en == -ENODEV)
+		if (pdata->gpio_ext_mic_en == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
 	}
 
-- 
1.7.10

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

* [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred
  2012-06-18 17:22 [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred Roland Stigge
@ 2012-06-18 17:26 ` Stephen Warren
  2012-06-18 17:29 ` Alexandre Pereira da Silva
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Warren @ 2012-06-18 17:26 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/18/2012 11:22 AM, Roland Stigge wrote:
> of_get_named_gpio_flags() and of_get_named_gpio() return -EPROBE_DEFER if the
> respective GPIO is not (yet) available. This is useful if driver's probe()
> functions try to get a GPIO whose controller isn't probed yet. Thus, the driver
> can be probed again later on.
> 
> The function still returns -EINVAL on other errors (parse error or node doesn't
> exist). This way, the case of an optional/intentionally missing GPIO is handled
> appropriately.
> 
> For this change, two sound drivers (tegra_{alc5632,wm8903}) need to be
> adjusted.

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

(That applies to the two separate sound patches too, if needed!)

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

* [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred
  2012-06-18 17:22 [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred Roland Stigge
  2012-06-18 17:26 ` Stephen Warren
@ 2012-06-18 17:29 ` Alexandre Pereira da Silva
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Pereira da Silva @ 2012-06-18 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 18, 2012 at 2:22 PM, Roland Stigge <stigge@antcom.de> wrote:
> of_get_named_gpio_flags() and of_get_named_gpio() return -EPROBE_DEFER if the
> respective GPIO is not (yet) available. This is useful if driver's probe()
> functions try to get a GPIO whose controller isn't probed yet. Thus, the driver
> can be probed again later on.
>
> The function still returns -EINVAL on other errors (parse error or node doesn't
> exist). This way, the case of an optional/intentionally missing GPIO is handled
> appropriately.
>
> For this change, two sound drivers (tegra_{alc5632,wm8903}) need to be
> adjusted.
>
> Signed-off-by: Roland Stigge <stigge@antcom.de>
Acked-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com>

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

end of thread, other threads:[~2012-06-18 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-18 17:22 [PATCH] sound/gpio: of_get_named_gpio() return -EPROBE_DEFER if GPIO deferred Roland Stigge
2012-06-18 17:26 ` Stephen Warren
2012-06-18 17:29 ` Alexandre Pereira da Silva

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).