On Fri, Sep 5, 2025 at 11:00 AM Aleksandrs Vinarskis <[email protected]> wrote:

> Add 'name' argument to of_led_get() such that it can lookup LEDs in
> devicetree by either name or index.
>
> And use this modified function to add devicetree support to the generic
> (non devicetree specific) [devm_]led_get() function.
>
> This uses the standard devicetree pattern of adding a -names string array
> to map names to the indexes for an array of resources.

...

> +       if (dev->of_node) {

This check is not needed.

Currently of_led_get() returns -ENOENT if the np is NULL or index is
invalid (negative value).
Same will be with the added index search as in case of error it will
hold a negative value.

> +               led_cdev = of_led_get(dev->of_node, -1, con_id);
> +               if (!IS_ERR(led_cdev) || PTR_ERR(led_cdev) != -ENOENT)
> +                       return led_cdev;
> +       }

-- 
With Best Regards,
Andy Shevchenko

Reply via email to