From: Rasmus Villemoes Date: Fri, 17 Nov 2023 11:38:07 +0000 (+0100) Subject: led-uclass: do not create fallback label for top-level node X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=067e4ce35b944314742cb46b3c82cb9b801c50ca;p=u-boot.git 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 --- diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c index 009f108019..0232fa84de 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;