diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2014-07-29 09:36:36 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-29 14:31:30 +0200 |
commit | 03a2269509e5107f88c04c6bdde4ec692ba97a9a (patch) | |
tree | 32fc873d617103c8f4e6027595f62cf8990bdf81 | |
parent | 366f64ff1b13654c26329fdc93efde2e20834cee (diff) | |
download | barebox-03a2269509e5107f88c04c6bdde4ec692ba97a9a.tar.gz barebox-03a2269509e5107f88c04c6bdde4ec692ba97a9a.tar.xz |
led: try to get LED's label from the 'label' property
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | Documentation/devicetree/bindings/leds/common.rst | 2 | ||||
-rw-r--r-- | drivers/led/led-gpio.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/leds/common.rst b/Documentation/devicetree/bindings/leds/common.rst index c1fd1ab89e..1f5ae42caf 100644 --- a/Documentation/devicetree/bindings/leds/common.rst +++ b/Documentation/devicetree/bindings/leds/common.rst @@ -8,3 +8,5 @@ Common leds properties * ``panic`` - LED turns on when barebox panics * ``net`` - LED indicates network activity +* ``label``: The label for this LED. If omitted, the label is taken + from the node name (excluding the unit address). diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c index 7bb3b49953..a1a661724d 100644 --- a/drivers/led/led-gpio.c +++ b/drivers/led/led-gpio.c @@ -206,13 +206,17 @@ static int led_gpio_of_probe(struct device_d *dev) struct gpio_led *gled; enum of_gpio_flags flags; int gpio; + const char *label; gpio = of_get_named_gpio_flags(child, "gpios", 0, &flags); if (gpio < 0) continue; gled = xzalloc(sizeof(*gled)); - gled->led.name = xstrdup(child->name); + if (of_property_read_string(child, "label", &label)) + label = child->name; + gled->led.name = xstrdup(label); + gled->gpio = gpio; gled->active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; |