Hi! > If the LED is acquired by a consumer device with devm_led_get(), it is > automatically released when the device is detached. > > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@xxxxxx> > Acked-by: Pavel Machek <pavel@xxxxxx> > --- > drivers/leds/led-class.c | 49 ++++++++++++++++++++++++++++++++++++++++ > include/linux/leds.h | 2 ++ > 2 files changed, 51 insertions(+) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 1d1f1d546dc7..639224392ffa 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -264,6 +264,55 @@ void led_put(struct led_classdev *led_cdev) > } > EXPORT_SYMBOL_GPL(led_put); > > +static void devm_led_release(struct device *dev, void *res) > +{ > + struct led_classdev **p = res; > + > + led_put(*p); > +} > + > +/** > + * devm_of_led_get - Resource-managed request of a LED device > + * @dev: LED consumer > + * @index: index of the LED to obtain in the consumer > + * > + * The device node of the device is parse to find the request LED device. > + * The LED device returned from this function is automatically released > + * on driver detach. > + * > + * @return a pointer to a LED device or ERR_PTR(errno) on failure. > + */ > +struct led_classdev *__must_check devm_of_led_get(struct device *dev, > + int index) > +{ > + struct led_classdev *led; > + struct led_classdev **dr; > + > + if (!dev) > + return ERR_PTR(-EINVAL); > + > + /* Consummer not using device tree? */ Typo "consumer". I may fix it before applying the patch. Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Attachment:
signature.asc
Description: Digital signature