[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191013120952.GL5653@amd>
Date: Sun, 13 Oct 2019 14:09:52 +0200
From: Pavel Machek <pavel@....cz>
To: Jean-Jacques Hiblot <jjhiblot@...com>
Cc: jacek.anaszewski@...il.com, sre@...nel.org, robh+dt@...nel.org,
mark.rutland@....com, lee.jones@...aro.org,
daniel.thompson@...aro.org, dmurphy@...com,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org, tomi.valkeinen@...com
Subject: Re: [PATCH v9 3/5] leds: Add managed API to get a LED from a device
driver
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@...com>
> Acked-by: Pavel Machek <pavel@....cz>
> ---
> 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
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists