mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Hubert Feurstein <h.feurstein@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH v2] led: gpio: add support for default-state dt-property
Date: Wed,  4 Mar 2015 10:52:04 +0100	[thread overview]
Message-ID: <1425462724-10581-1-git-send-email-h.feurstein@gmail.com> (raw)
In-Reply-To: <20150217075906.GP12209@pengutronix.de>

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

  reply	other threads:[~2015-03-04  9:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 13:03 [PATCH] " h.feurstein
2015-02-17  7:59 ` Sascha Hauer
2015-03-04  9:52   ` Hubert Feurstein [this message]
2015-03-04 10:37     ` [PATCH v2] " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425462724-10581-1-git-send-email-h.feurstein@gmail.com \
    --to=h.feurstein@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox