LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] call gpio_cansleep only after gpio_request succeeded
@ 2008-02-14 14:32 Uwe Kleine-König
  2008-02-14 15:25 ` Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2008-02-14 14:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: David Brownell, Raphael Assenat, Richard Purdie

If you have GPIO_LIB gpio_cansleep oopses on an invalid
gpio.  So better gpio_request your pin first.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Raphael Assenat <raph@8d.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
Hello,

I currently start using GPIO_LIB and don't have any chips yet.  The Oops will
vanish after I will have registered the chips for my SoC's gpios, but still
this way the code is more robust.

Best regards
Uwe

 drivers/leds/leds-gpio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c0a9c4..76ddcf3 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
 		cur_led = &pdata->leds[i];
 		led_dat = &leds_data[i];
 
+		ret = gpio_request(led_dat->gpio, cur_led->name);
+		if (ret < 0)
+			goto err;
+
 		led_dat->cdev.name = cur_led->name;
 		led_dat->cdev.default_trigger = cur_led->default_trigger;
 		led_dat->gpio = cur_led->gpio;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
 		led_dat->cdev.brightness_set = gpio_led_set;
 		led_dat->cdev.brightness = LED_OFF;
 
-		ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
-		if (ret < 0)
-			goto err;
-
 		gpio_direction_output(led_dat->gpio, led_dat->active_low);
 
 		INIT_WORK(&led_dat->work, gpio_led_work);
-- 
1.5.4.1


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

* Re: [PATCH] call gpio_cansleep only after gpio_request succeeded
  2008-02-14 14:32 [PATCH] call gpio_cansleep only after gpio_request succeeded Uwe Kleine-König
@ 2008-02-14 15:25 ` Uwe Kleine-König
  2008-02-14 16:43 ` David Brownell
  2008-03-06 10:24 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2008-02-14 15:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: David Brownell, Raphael Assenat, Richard Purdie

Hello,

Uwe Kleine-König wrote:
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 6c0a9c4..76ddcf3 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
>  		cur_led = &pdata->leds[i];
>  		led_dat = &leds_data[i];
>  
> +		ret = gpio_request(led_dat->gpio, cur_led->name);

The line above must read:

		ret = gpio_request(led_dat->gpio, cur_led->name);

I managed to notice that the 2nd argument needs a change but I
overlooked the first somehow.

Best regards
Uwe

-- 
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962

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

* Re: [PATCH] call gpio_cansleep only after gpio_request succeeded
  2008-02-14 14:32 [PATCH] call gpio_cansleep only after gpio_request succeeded Uwe Kleine-König
  2008-02-14 15:25 ` Uwe Kleine-König
@ 2008-02-14 16:43 ` David Brownell
  2008-03-06 10:24 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: David Brownell @ 2008-02-14 16:43 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-kernel, Raphael Assenat, Richard Purdie

On Thursday 14 February 2008, Uwe Kleine-König wrote:
> If you have GPIO_LIB gpio_cansleep oopses on an invalid
> gpio.  So better gpio_request your pin first.
> 
> Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
> Cc: David Brownell <dbrownell@users.sourceforge.net>

Acked-by: David Brownell <dbrownell@users.sourceforge.net>

... my bad, sorry.  The "first do gpio_request(), THEN
you can test gpio_cansleep()" issue got resolved in that
direction a bit late; this is the only in-tree driver
that I know would be affected.  My test platforms haven't
yet been updated to 2.6.25-rc1 ... :(



> Cc: Raphael Assenat <raph@8d.com>
> Cc: Richard Purdie <rpurdie@rpsys.net>
> ---
> Hello,
> 
> I currently start using GPIO_LIB and don't have any chips yet.  The Oops will
> vanish after I will have registered the chips for my SoC's gpios, but still
> this way the code is more robust.
> 
> Best regards
> Uwe
> 
>  drivers/leds/leds-gpio.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 6c0a9c4..76ddcf3 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
>  		cur_led = &pdata->leds[i];
>  		led_dat = &leds_data[i];
>  
> +		ret = gpio_request(led_dat->gpio, cur_led->name);
> +		if (ret < 0)
> +			goto err;
> +
>  		led_dat->cdev.name = cur_led->name;
>  		led_dat->cdev.default_trigger = cur_led->default_trigger;
>  		led_dat->gpio = cur_led->gpio;
> @@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
>  		led_dat->cdev.brightness_set = gpio_led_set;
>  		led_dat->cdev.brightness = LED_OFF;
>  
> -		ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
> -		if (ret < 0)
> -			goto err;
> -
>  		gpio_direction_output(led_dat->gpio, led_dat->active_low);
>  
>  		INIT_WORK(&led_dat->work, gpio_led_work);
> -- 
> 1.5.4.1
> 



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

* [PATCH] call gpio_cansleep only after gpio_request succeeded
  2008-02-14 14:32 [PATCH] call gpio_cansleep only after gpio_request succeeded Uwe Kleine-König
  2008-02-14 15:25 ` Uwe Kleine-König
  2008-02-14 16:43 ` David Brownell
@ 2008-03-06 10:24 ` Uwe Kleine-König
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2008-03-06 10:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Raphael Assenat, Richard Purdie

If you have GPIO_LIB gpio_cansleep oopses on an invalid
gpio.  So better gpio_request your pin first.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Raphael Assenat <raph@8d.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
Hello,

I already sent that patch on Thu, 14 Feb 2008.  Since then I changed

	gpio_request(led_dat->gpio, ...

to

	gpio_request(cur_led->gpio, ...

because at that time led_dat->gpio isn't initialized yet.

And I got the Acked-by: David.

Best regards
Uwe

---
 drivers/leds/leds-gpio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c0a9c4..d13b622 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
 		cur_led = &pdata->leds[i];
 		led_dat = &leds_data[i];
 
+		ret = gpio_request(cur_led->gpio, cur_led->name);
+		if (ret < 0)
+			goto err;
+
 		led_dat->cdev.name = cur_led->name;
 		led_dat->cdev.default_trigger = cur_led->default_trigger;
 		led_dat->gpio = cur_led->gpio;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
 		led_dat->cdev.brightness_set = gpio_led_set;
 		led_dat->cdev.brightness = LED_OFF;
 
-		ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
-		if (ret < 0)
-			goto err;
-
 		gpio_direction_output(led_dat->gpio, led_dat->active_low);
 
 		INIT_WORK(&led_dat->work, gpio_led_work);
-- 
1.5.4.3


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

end of thread, other threads:[~2008-03-06 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-14 14:32 [PATCH] call gpio_cansleep only after gpio_request succeeded Uwe Kleine-König
2008-02-14 15:25 ` Uwe Kleine-König
2008-02-14 16:43 ` David Brownell
2008-03-06 10:24 ` Uwe Kleine-König

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