[PATCH 1/6] led-uclass: do not create fallback label for top-level node

Marek Vasut marex at denx.de
Thu Oct 19 15:51:39 CEST 2023


On 10/19/23 11:58, Rasmus Villemoes wrote:
> 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 83c63f0d1185 ("led:
> Move OF "label" property parsing to core"), and also that the top node
> wrongly shows up with 'led list'. Some drivers have since been fixed
> up individually, e.g.
> 
> e3aa76644c2a "led: gpio: Check device compatible string to determine the top level node"
> 01074697801b "led: gpio: Use NOP uclass driver for top-level node"
> 910b01c27c04 "drivers: led: bcm6753: do not use null label to find the top"
> 
> 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.

Note that
83c63f0d1185 ("led: Move OF "label" property parsing to core")
and
01074697801b ("led: gpio: Use NOP uclass driver for top-level node")
were applied shortly after each other, so I don't see the point of the 
aforementioned rant.

I sort-of understand what you are trying to do in this patch based on 
$SUBJECT of this email, but not from this wall of text, so can you 
abbreviate the commit message ?

> But as a temporary work-around, 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() [similar to
> what e3aa76644c2a did, but that then vanished with the next commit.]
> 
> Fixes: 83c63f0d1185 ("led: Move OF "label" property parsing to core")
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> ---
>   drivers/led/led-uclass.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
> index 68ca3c2970..5a5d07b9a7 100644
> --- a/drivers/led/led-uclass.c
> +++ b/drivers/led/led-uclass.c
> @@ -72,7 +72,7 @@ static int led_post_bind(struct udevice *dev)
>   	const char *default_state;
>   
>   	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));

Is there an existing driver which has a top-level DT node with "label" 
property ?

>   	uc_plat->default_state = LEDST_COUNT;



More information about the U-Boot mailing list