From: "Rafał Miłecki" <zajec5@gmail.com>
To: Richard Purdie <rpurdie@rpsys.net>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
Pavel Machek <pavel@ucw.cz>
Cc: linux-leds@vger.kernel.org, "Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH 1/2] leds: core: add struct device_node pointer to the struct led_classdev
Date: Mon, 27 Feb 2017 23:27:55 +0100 [thread overview]
Message-ID: <431cabc7-2ffe-9f8d-01fc-616978f12821@gmail.com> (raw)
In-Reply-To: <20170227222300.2060-1-zajec5@gmail.com>
On 02/27/2017 11:22 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> This allows every led_classdev_register user to set of_node before
> calling that function. Thanks to this LEDs core code may access DT node
> during LED registration (e.g. to read extra info).
>
> A small disadvantage of this imlementation is keeping of_node pointer in
> two places: struct led_classdev and struct device.
> Another solutions were:
> 1) Passing pointer with a led_classdev_register call
> This would require changing & complicating the API.
> 2) Moving allocation part of led_classdev_register to separated function
> This would make registering LED even more complicated.
>
> Having duplicated pointer semms like a reasonable trade-off.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> drivers/leds/led-class.c | 1 +
> include/linux/leds.h | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index 326ee6e925a2..9db9d05e4832 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -199,6 +199,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 = led_cdev->of_node;
>
> if (ret)
> dev_warn(parent, "Led %s renamed to %s due to name collision",
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index 569cb531094c..7dc4a679f376 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -85,6 +85,7 @@ struct led_classdev {
> unsigned long *delay_off);
>
> struct device *dev;
> + struct device_node *of_node;
> const struct attribute_group **groups;
>
> struct list_head node; /* LED Device list */
>
Sorry Jacek, I used your old e-mail accidentally. Hope you got this patchset.
next prev parent reply other threads:[~2017-02-27 22:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 22:22 [PATCH 1/2] leds: core: add struct device_node pointer to the struct led_classdev Rafał Miłecki
2017-02-27 22:23 ` [PATCH 2/2] leds: gpio: set of_node before calling led_classdev_register Rafał Miłecki
2017-02-27 22:27 ` Rafał Miłecki [this message]
2017-02-28 21:20 ` [PATCH 1/2] leds: core: add struct device_node pointer to the struct led_classdev Jacek Anaszewski
2017-03-02 17:42 ` Rafał Miłecki
2017-03-02 20:29 ` Jacek Anaszewski
2017-03-02 22:45 ` Rafał Miłecki
2017-03-03 22:20 ` 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=431cabc7-2ffe-9f8d-01fc-616978f12821@gmail.com \
--to=zajec5@gmail.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafal@milecki.pl \
--cc=rpurdie@rpsys.net \
/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).