Re: [PATCH] led/led-class: Handle LEDs with the same name

From: Ricardo Ribalda Delgado
Date: Thu Feb 19 2015 - 18:00:23 EST

Hello Bryan

On Thu, Feb 19, 2015 at 8:12 PM, Bryan Wu <cooloney@xxxxxxxxx> wrote:
> Yes, this is what I want. It's good to let the user know there are
> multiple leds share the same name in DT. Sometime they made some
> mistake in the DTS file.

I have added that message now:

dev_info(parent, "Led %s renamed to %s due to name collision",
led_cdev->name, dev_name(led_cdev->dev));

> Please update the patch, we can start to discuss the implementation, then.
> Actually I think we don't need the temp_name and just use the "name".

We need to keep a pointer to the generated string, to release it later
with kfree.
Also I rather allocate new memory only if there is a name collision.

> And one more thing is device_find_child() will find child of the
> parent. But in your 2 PCI card case, these 2 parents are different
> then device_find_child() will return false twice even if your 2 red
> leds have the same name.

I am now iterating with

while (class_find_device(leds_class, NULL, name, match_name));


Ricardo Ribalda
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at