From: Pavel Machek <pavel@ucw.cz>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "Richard Purdie" <rpurdie@rpsys.net>,
"Jacek Anaszewski" <jacek.anaszewski@gmail.com>,
linux-leds@vger.kernel.org, "Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH V2 1/2] leds: core: add OF variants of LED registering functions
Date: Tue, 7 Mar 2017 13:05:47 +0100 [thread overview]
Message-ID: <20170307120547.GA2740@amd> (raw)
In-Reply-To: <20170306051945.14857-1-zajec5@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5016 bytes --]
On Mon 2017-03-06 06:19:44, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> These new functions allow passing an additional device_node argument
> that will be internally set for created LED device. Thanks to this LED
> core code and triggers will be able to access DT node for reading extra
> info.
>
> The easiest solution for achieving this was reworking old functions to
> more generic ones & adding simple defines for API compatibility.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Both patches: Acked-by: Pavel Machek <pavel@ucw.cz>
> ---
> V2: Use new functions instead of adding property to the struct led_classdev.
> ---
> drivers/leds/led-class.c | 26 ++++++++++++++++----------
> include/linux/leds.h | 14 ++++++++++----
> 2 files changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index 95d971aa2440..349d334d2e98 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -182,11 +182,14 @@ static int led_classdev_next_name(const char *init_name, char *name,
> }
>
> /**
> - * led_classdev_register - register a new object of led_classdev class.
> - * @parent: The device to register.
> + * of_led_classdev_register - register a new object of led_classdev class.
> + *
> + * @parent: parent of LED device
> * @led_cdev: the led_classdev structure for this device.
> + * @np: DT node describing this LED
> */
> -int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
> +int of_led_classdev_register(struct device *parent, struct device_node *np,
> + struct led_classdev *led_cdev)
> {
> char name[LED_MAX_NAME_SIZE];
> int ret;
> @@ -199,6 +202,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
> led_cdev, led_cdev->groups, "%s", name);
> if (IS_ERR(led_cdev->dev))
> return PTR_ERR(led_cdev->dev);
> + led_cdev->dev->of_node = np;
>
> if (ret)
> dev_warn(parent, "Led %s renamed to %s due to name collision",
> @@ -234,7 +238,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(led_classdev_register);
> +EXPORT_SYMBOL_GPL(of_led_classdev_register);
>
> /**
> * led_classdev_unregister - unregisters a object of led_properties class.
> @@ -276,12 +280,14 @@ static void devm_led_classdev_release(struct device *dev, void *res)
> }
>
> /**
> - * devm_led_classdev_register - resource managed led_classdev_register()
> - * @parent: The device to register.
> + * devm_of_led_classdev_register - resource managed led_classdev_register()
> + *
> + * @parent: parent of LED device
> * @led_cdev: the led_classdev structure for this device.
> */
> -int devm_led_classdev_register(struct device *parent,
> - struct led_classdev *led_cdev)
> +int devm_of_led_classdev_register(struct device *parent,
> + struct device_node *np,
> + struct led_classdev *led_cdev)
> {
> struct led_classdev **dr;
> int rc;
> @@ -290,7 +296,7 @@ int devm_led_classdev_register(struct device *parent,
> if (!dr)
> return -ENOMEM;
>
> - rc = led_classdev_register(parent, led_cdev);
> + rc = of_led_classdev_register(parent, np, led_cdev);
> if (rc) {
> devres_free(dr);
> return rc;
> @@ -301,7 +307,7 @@ int devm_led_classdev_register(struct device *parent,
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(devm_led_classdev_register);
> +EXPORT_SYMBOL_GPL(devm_of_led_classdev_register);
>
> static int devm_led_classdev_match(struct device *dev, void *res, void *data)
> {
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index 0518903778b6..00dcb9f8293b 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -114,10 +114,16 @@ struct led_classdev {
> struct mutex led_access;
> };
>
> -extern int led_classdev_register(struct device *parent,
> - struct led_classdev *led_cdev);
> -extern int devm_led_classdev_register(struct device *parent,
> - struct led_classdev *led_cdev);
> +extern int of_led_classdev_register(struct device *parent,
> + struct device_node *np,
> + struct led_classdev *led_cdev);
> +#define led_classdev_register(parent, led_cdev) \
> + of_led_classdev_register(parent, NULL, led_cdev)
> +extern int devm_of_led_classdev_register(struct device *parent,
> + struct device_node *np,
> + struct led_classdev *led_cdev);
> +#define devm_led_classdev_register(parent, led_cdev) \
> + devm_of_led_classdev_register(parent, NULL, led_cdev)
> extern void led_classdev_unregister(struct led_classdev *led_cdev);
> extern void devm_led_classdev_unregister(struct device *parent,
> struct led_classdev *led_cdev);
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-03-07 12:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 5:19 [PATCH V2 1/2] leds: core: add OF variants of LED registering functions Rafał Miłecki
2017-03-06 5:19 ` [PATCH V2 2/2] leds: gpio: use OF variant of LED registering function Rafał Miłecki
2017-03-07 12:05 ` Pavel Machek [this message]
2017-03-07 19:30 ` [PATCH V2 1/2] leds: core: add OF variants of LED registering functions Jacek Anaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170307120547.GA2740@amd \
--to=pavel@ucw.cz \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-leds@vger.kernel.org \
--cc=rafal@milecki.pl \
--cc=rpurdie@rpsys.net \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).