* [PATCH] led: gpio: add support for default-state dt-property
@ 2015-02-16 13:03 h.feurstein
2015-02-17 7:59 ` Sascha Hauer
0 siblings, 1 reply; 4+ messages in thread
From: h.feurstein @ 2015-02-16 13:03 UTC (permalink / raw)
To: barebox; +Cc: Hubert Feurstein
From: Hubert Feurstein <hubert.feurstein@deto.at>
This patch adds support for the default-state device tree property.
Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
---
drivers/led/led-gpio.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index a1a6617..69ad7e7 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev)
for_each_child_of_node(dev->device_node, child) {
struct gpio_led *gled;
+ const char *default_state;
enum of_gpio_flags flags;
int gpio;
const char *label;
@@ -225,6 +226,18 @@ static int led_gpio_of_probe(struct device_d *dev)
led_gpio_register(gled);
led_of_parse_trigger(&gled->led, child);
+
+ if (!of_property_read_string(child, "default-state", &default_state)) {
+ int state = -1;
+
+ if (!strcmp(default_state, "on"))
+ state = 1;
+ else if (!strcmp(default_state, "off"))
+ state = 0;
+
+ if (state >= 0)
+ led_gpio_set(&gled->led, state ^ gled->active_low);
+ }
}
return 0;
--
2.3.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] led: gpio: add support for default-state dt-property
2015-02-16 13:03 [PATCH] led: gpio: add support for default-state dt-property h.feurstein
@ 2015-02-17 7:59 ` Sascha Hauer
2015-03-04 9:52 ` [PATCH v2] " Hubert Feurstein
0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2015-02-17 7:59 UTC (permalink / raw)
To: h.feurstein; +Cc: Hubert Feurstein, barebox
On Mon, Feb 16, 2015 at 02:03:28PM +0100, h.feurstein@gmail.com wrote:
> From: Hubert Feurstein <hubert.feurstein@deto.at>
>
> This patch adds support for the default-state device tree property.
>
> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
> ---
> drivers/led/led-gpio.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
> index a1a6617..69ad7e7 100644
> --- a/drivers/led/led-gpio.c
> +++ b/drivers/led/led-gpio.c
> @@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev)
>
> for_each_child_of_node(dev->device_node, child) {
> struct gpio_led *gled;
> + const char *default_state;
> enum of_gpio_flags flags;
> int gpio;
> const char *label;
> @@ -225,6 +226,18 @@ static int led_gpio_of_probe(struct device_d *dev)
>
> led_gpio_register(gled);
> led_of_parse_trigger(&gled->led, child);
> +
> + if (!of_property_read_string(child, "default-state", &default_state)) {
> + int state = -1;
> +
> + if (!strcmp(default_state, "on"))
> + state = 1;
> + else if (!strcmp(default_state, "off"))
> + state = 0;
> +
> + if (state >= 0)
> + led_gpio_set(&gled->led, state ^ gled->active_low);
led_gpio_set already evaluates active_low, so doing it here again is
wrong.
Sascha
--
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] 4+ messages in thread
* [PATCH v2] led: gpio: add support for default-state dt-property
2015-02-17 7:59 ` Sascha Hauer
@ 2015-03-04 9:52 ` Hubert Feurstein
2015-03-04 10:37 ` Sascha Hauer
0 siblings, 1 reply; 4+ messages in thread
From: Hubert Feurstein @ 2015-03-04 9:52 UTC (permalink / raw)
To: barebox
This patch adds support for the default-state device tree property.
Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
---
drivers/led/led-gpio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index a1a6617..ae3f13f 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev)
for_each_child_of_node(dev->device_node, child) {
struct gpio_led *gled;
+ const char *default_state;
enum of_gpio_flags flags;
int gpio;
const char *label;
@@ -225,6 +226,13 @@ static int led_gpio_of_probe(struct device_d *dev)
led_gpio_register(gled);
led_of_parse_trigger(&gled->led, child);
+
+ if (!of_property_read_string(child, "default-state", &default_state)) {
+ if (!strcmp(default_state, "on"))
+ led_gpio_set(&gled->led, 1);
+ else if (!strcmp(default_state, "off"))
+ led_gpio_set(&gled->led, 0);
+ }
}
return 0;
--
2.3.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] led: gpio: add support for default-state dt-property
2015-03-04 9:52 ` [PATCH v2] " Hubert Feurstein
@ 2015-03-04 10:37 ` Sascha Hauer
0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-03-04 10:37 UTC (permalink / raw)
To: Hubert Feurstein; +Cc: barebox
On Wed, Mar 04, 2015 at 10:52:04AM +0100, Hubert Feurstein wrote:
> This patch adds support for the default-state device tree property.
>
> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
> ---
> drivers/led/led-gpio.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Nice, as it happens I can just make use of this patch to turn off an
annoying LED on my beaglebone board.
Applied, thanks.
Sascha
--
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] 4+ messages in thread
end of thread, other threads:[~2015-03-04 10:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-16 13:03 [PATCH] led: gpio: add support for default-state dt-property h.feurstein
2015-02-17 7:59 ` Sascha Hauer
2015-03-04 9:52 ` [PATCH v2] " Hubert Feurstein
2015-03-04 10:37 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox