linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] leds: leds-gpio: Fix multiple instances registration when 'label' property is absent
@ 2014-12-03 17:57 Fabio Estevam
  2014-12-03 19:59 ` Fabio Estevam
  2014-12-03 23:17 ` Grant Likely
  0 siblings, 2 replies; 12+ messages in thread
From: Fabio Estevam @ 2014-12-03 17:57 UTC (permalink / raw)
  To: cooloney
  Cc: rpurdie, jean-michel.hautbois, grant.likely, rafael.j.wysocki,
	mika.westerberg, linux-leds, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

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.

Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Consider ACPI case as suggested by Grant

 drivers/leds/leds-gpio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index fd53968..8a8ba11 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)
 	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)
@@ -189,7 +190,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);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-12-04  1:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-03 17:57 [PATCH v2] leds: leds-gpio: Fix multiple instances registration when 'label' property is absent Fabio Estevam
2014-12-03 19:59 ` Fabio Estevam
2014-12-03 22:23   ` Bryan Wu
2014-12-03 23:16   ` Grant Likely
2014-12-03 23:17 ` Grant Likely
2014-12-03 23:28   ` Fabio Estevam
2014-12-03 23:59     ` Bryan Wu
2014-12-04  0:12       ` Fabio Estevam
2014-12-04  0:48         ` Bryan Wu
2014-12-04  0:50           ` Fabio Estevam
2014-12-04  1:00             ` Bryan Wu
2014-12-04  1:29               ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).