From 067e4ce35b944314742cb46b3c82cb9b801c50ca Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 17 Nov 2023 12:38:07 +0100 Subject: led-uclass: do not create fallback label for top-level node Many existing drivers, and led-uclass itself, rely on uc_plat->label being NULL for the device representing the top node, as opposed to the child nodes representing individual LEDs. This means that the drivers whose .probe methods rely on this were broken by commit 83c63f0d1185 ("led: Move OF "label" property parsing to core"), and also that the top node wrongly shows up with 'led list'. Binding the same driver to the top node as to the individual child nodes is arguably wrong, and the approach of using a UCLASS_NOP driver for the top node is probably better - this has for example been done in commit 01074697801b ("led: gpio: Use NOP uclass driver for top-level node") and commit 910b01c27c04 ("drivers: led: bcm6753: do not use null label to find the top") Until remaining affected drivers are fixed, we can use a heuristic that only sets the label to the fallback value derived from the node name if the node does not have a "compatible" property - i.e., if it has been bound to the LED driver explicitly via device_bind_driver_to_node(). This is similar to what commit e3aa76644c2a ("led: gpio: Check device compatible string to determine the top level node") did for gpio_led, but that fix was then supplanted by commit 01074697801b ("led: gpio: Use NOP uclass driver for top-level node") Fixes: 83c63f0d1185 ("led: Move OF "label" property parsing to core") Signed-off-by: Rasmus Villemoes --- drivers/led/led-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/led') diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 009f1080197..0232fa84def 100644 --- a/drivers/led/led-uclass.c +++ b/drivers/led/led-uclass.c @@ -74,7 +74,7 @@ static int led_post_bind(struct udevice *dev) if (!uc_plat->label) uc_plat->label = dev_read_string(dev, "label"); - if (!uc_plat->label) + if (!uc_plat->label && !dev_read_string(dev, "compatible")) uc_plat->label = ofnode_get_name(dev_ofnode(dev)); uc_plat->default_state = LEDST_COUNT; -- cgit v1.2.3