mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21)
@ 2012-12-26 16:33 Jean-Christophe PLAGNIOL-VILLARD
  2012-12-26 16:33 ` [PATCH 2/2] led-gpio: use gpio_request and gpio_free Jean-Christophe PLAGNIOL-VILLARD
  2013-01-02 10:06 ` [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-12-26 16:33 UTC (permalink / raw)
  To: barebox

as d1 pioB18 is used for the one wire too

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
Hi,

	to be applied before led-gpio switch to gpio_request/free
	otherwise we have a nice crash.

Best Regards,
J.

 arch/arm/boards/at91sam9x5ek/init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 6d1ebe5..77c3ee3 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -224,7 +224,7 @@ static void __init ek_add_led(void)
 		at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
 		led_gpio_register(&leds[i]);
 	}
-	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[0].led);
+	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[1].led);
 }
 
 static int at91sam9x5ek_mem_init(void)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] led-gpio: use gpio_request and gpio_free
  2012-12-26 16:33 [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Jean-Christophe PLAGNIOL-VILLARD
@ 2012-12-26 16:33 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-01-02 10:06 ` [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-12-26 16:33 UTC (permalink / raw)
  To: barebox

So we can ensure a gpio is not used for something else

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/led/led-gpio.c |   67 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 4 deletions(-)

diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index c78ef9e..08dc9ba 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -19,7 +19,7 @@
  */
 #include <common.h>
 #include <led.h>
-#include <asm/gpio.h>
+#include <gpio.h>
 
 static void led_gpio_set(struct led *led, unsigned int value)
 {
@@ -37,10 +37,21 @@ static void led_gpio_set(struct led *led, unsigned int value)
  */
 int led_gpio_register(struct gpio_led *led)
 {
+	int ret;
+	char *name = led->led.name;
+
+	ret = gpio_request(led->gpio, name ? name : "led");
+	if (ret)
+		return ret;
+
 	led->led.set = led_gpio_set;
 	led->led.max_value = 1;
 
-	return led_register(&led->led);
+	ret = led_register(&led->led);
+	if (ret)
+		gpio_free(led->gpio);
+
+	return ret;
 }
 
 /**
@@ -83,10 +94,31 @@ static void led_gpio_bicolor_set(struct led *led, unsigned int value)
  */
 int led_gpio_bicolor_register(struct gpio_bicolor_led *led)
 {
+	int ret;
+	char *name = led->led.name;
+
+	ret = gpio_request(led->gpio_c0, name ? name : "led_c0");
+	if (ret)
+		return ret;
+
+	ret = gpio_request(led->gpio_c1, name ? name : "led_c1");
+	if (ret)
+		goto err_gpio_c0;
+
 	led->led.set = led_gpio_bicolor_set;
 	led->led.max_value = 2;
 
-	return led_register(&led->led);
+	ret = led_register(&led->led);
+	if (ret)
+		goto err_gpio_c1;
+
+	return 0;
+
+err_gpio_c1:
+	gpio_free(led->gpio_c1);
+err_gpio_c0:
+	gpio_free(led->gpio_c0);
+	return ret;
 }
 
 /**
@@ -120,10 +152,37 @@ static void led_gpio_rgb_set(struct led *led, unsigned int value)
  */
 int led_gpio_rgb_register(struct gpio_rgb_led *led)
 {
+	int ret;
+	char *name = led->led.name;
+
+	ret = gpio_request(led->gpio_r, name ? name : "led_r");
+	if (ret)
+		return ret;
+
+	ret = gpio_request(led->gpio_g, name ? name : "led_g");
+	if (ret)
+		goto err_gpio_r;
+
+	ret = gpio_request(led->gpio_b, name ? name : "led_b");
+	if (ret)
+		goto err_gpio_g;
+
 	led->led.set = led_gpio_rgb_set;
 	led->led.max_value = 7;
 
-	return led_register(&led->led);
+	ret = led_register(&led->led);
+	if (ret)
+		goto err_gpio_b;
+
+	return 0;
+
+err_gpio_b:
+	gpio_free(led->gpio_b);
+err_gpio_g:
+	gpio_free(led->gpio_g);
+err_gpio_r:
+	gpio_free(led->gpio_r);
+	return ret;
 }
 
 /**
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21)
  2012-12-26 16:33 [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Jean-Christophe PLAGNIOL-VILLARD
  2012-12-26 16:33 ` [PATCH 2/2] led-gpio: use gpio_request and gpio_free Jean-Christophe PLAGNIOL-VILLARD
@ 2013-01-02 10:06 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2013-01-02 10:06 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Dec 26, 2012 at 05:33:55PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as d1 pioB18 is used for the one wire too
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> Hi,
> 
> 	to be applied before led-gpio switch to gpio_request/free
> 	otherwise we have a nice crash.
> 
> Best Regards,
> J.

Applied, thanks

Sascha

> 
>  arch/arm/boards/at91sam9x5ek/init.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
> index 6d1ebe5..77c3ee3 100644
> --- a/arch/arm/boards/at91sam9x5ek/init.c
> +++ b/arch/arm/boards/at91sam9x5ek/init.c
> @@ -224,7 +224,7 @@ static void __init ek_add_led(void)
>  		at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
>  		led_gpio_register(&leds[i]);
>  	}
> -	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[0].led);
> +	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[1].led);
>  }
>  
>  static int at91sam9x5ek_mem_init(void)
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-01-02 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-26 16:33 [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Jean-Christophe PLAGNIOL-VILLARD
2012-12-26 16:33 ` [PATCH 2/2] led-gpio: use gpio_request and gpio_free Jean-Christophe PLAGNIOL-VILLARD
2013-01-02 10:06 ` [PATCH 1/2] at91sam9x5ek: switch heartbeat to d2 (pioD21) Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox