aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-gpio.c
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2014-12-03 20:28:19 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-12-03 20:28:19 -0500
commit29470ea8d828e4dec74e94f7f17b7479ff5ef276 (patch)
treeff84d6c5c98e4317dc340e81557d7217b0d10203 /drivers/leds/leds-gpio.c
parentec98a4975e66a3aa366cd227edab027b01adea37 (diff)
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. 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>
Diffstat (limited to 'drivers/leds/leds-gpio.c')
-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 b3c5d9d6a42b..868e6fc17cba 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -170,6 +170,7 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
170 struct fwnode_handle *child; 170 struct fwnode_handle *child;
171 struct gpio_leds_priv *priv; 171 struct gpio_leds_priv *priv;
172 int count, ret; 172 int count, ret;
173 struct device_node *np;
173 174
174 count = device_get_child_node_count(dev); 175 count = device_get_child_node_count(dev);
175 if (!count) 176 if (!count)
@@ -189,7 +190,16 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
189 goto err; 190 goto err;
190 } 191 }
191 192
192 fwnode_property_read_string(child, "label", &led.name); 193 np = of_node(child);
194
195 if (fwnode_property_present(child, "label")) {
196 fwnode_property_read_string(child, "label", &led.name);
197 } else {
198 if (IS_ENABLED(CONFIG_OF) && !led.name && np)
199 led.name = np->name;
200 if (!led.name)
201 return ERR_PTR(-EINVAL);
202 }
193 fwnode_property_read_string(child, "linux,default-trigger", 203 fwnode_property_read_string(child, "linux,default-trigger",
194 &led.default_trigger); 204 &led.default_trigger);
195 205