aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2014-12-04 02:28:19 +0100
committerMihai Serban <mihai.serban@intel.com>2016-01-07 17:55:03 +0200
commit9e59c811462b8245cc922227202b55bf77501b13 (patch)
tree67e1a642029ef6bf26c0cb910b949485ed2caa8a
parent9c8b1b270132a6dbbce86fcdace1c541017ef062 (diff)
downloadminnowboard-v3.14-9e59c811462b8245cc922227202b55bf77501b13.tar.gz
BACKPORT: leds: leds-gpio: Fix multiple instances registration without 'label' property
Since commit a43f2cbbb009f96 ("leds: leds-gpio: Make use of device property API") it is no longer possible to register multiple gpio leds without passing the 'label' property. According to Documentation/devicetree/bindings/leds/common.txt: "Optional properties for child nodes: - label : The label for this LED. If omitted, the label is taken from the node name (excluding the unit address)." So retrieve the node name when the 'label' property is absent to keep the old behaviour and fix this regression. Change-Id: I41a274ae46cf24d76ec5be6ee3b54ee39fc922c5 Fixes: a43f2cbbb009 (leds: leds-gpio: Make use of device property API) Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Grant Likely <grant.likely@linaro.org> Acked-by: Bryan Wu <cooloney@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Robert Dolca <robert.dolca@intel.com>
-rw-r--r--drivers/leds/leds-gpio.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 66d13637536..d9b846ac82f 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -171,6 +171,7 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
struct fwnode_handle *child;
struct gpio_leds_priv *priv;
int count, ret;
+ struct device_node *np;
count = device_get_child_node_count(dev);
if (!count)
@@ -190,7 +191,16 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
goto err;
}
- fwnode_property_read_string(child, "label", &led.name);
+ np = of_node(child);
+
+ if (fwnode_property_present(child, "label")) {
+ fwnode_property_read_string(child, "label", &led.name);
+ } else {
+ if (IS_ENABLED(CONFIG_OF) && !led.name && np)
+ led.name = np->name;
+ if (!led.name)
+ return ERR_PTR(-EINVAL);
+ }
fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger);