From: Krzysztof Kozlowski <krzk@kernel.org>
To: pavel@ucw.cz
Cc: jacek.anaszewski@gmail.com, robh+dt@kernel.org,
mark.rutland@arm.com, baolin.wang@linaro.org,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/5] leds: Add helper for getting default pattern from Device Tree
Date: Thu, 13 Dec 2018 09:21:16 +0100 [thread overview]
Message-ID: <CAJKOXPcka9qc7CgXhA0jbEFUurAYO=GZP0utiuYcNee4AmnMNg@mail.gmail.com> (raw)
In-Reply-To: <20181212122227.GB11088@amd>
On Wed, 12 Dec 2018 at 13:22, Pavel Machek <pavel@ucw.cz> wrote:
>
> On Wed 2018-12-12 12:16:43, Krzysztof Kozlowski wrote:
> > Multiple LED triggers might need to access default pattern so add a
> > helper for that.
> >
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
>
> Acked-by: Pavel Machek <pavel@ucw.cz>
>
> >
> > New patch in the series
> >
> > ---
> > drivers/leds/led-class.c | 25 +++++++++++++++++++++++++
> > include/linux/leds.h | 3 +++
> > 2 files changed, 28 insertions(+)
> >
> > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> > index 3c7e3487b373..44b95e6480f6 100644
> > --- a/drivers/leds/led-class.c
> > +++ b/drivers/leds/led-class.c
> > @@ -17,6 +17,7 @@
> > #include <linux/leds.h>
> > #include <linux/list.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
> > #include <linux/slab.h>
> > #include <linux/spinlock.h>
> > #include <linux/timer.h>
> > @@ -244,6 +245,30 @@ static int led_classdev_next_name(const char *init_name, char *name,
> > }
> >
> > /**
> > + * led_classdev_get_default_pattern - return default pattern
> > + *
> > + * @led_cdev: the led_classdev structure for this device
> > + *
> > + * Return: Null terminated string with default pattern from DeviceTree or NULL
> > + */
>
> Is it valid kerneldoc?
Yes, maybe kind a short but in general it follows style.
https://www.kernel.org/doc/Documentation/kernel-doc-nano-HOWTO.txt
> Note that core still owns the string so that
> caller is not expected to free it?
That should be obvious by returning "const char *". The
of_property_string() does not mention such case neither... I can
document it but really "const char *" is self-documenting code.
> > +const char *led_classdev_get_default_pattern(struct led_classdev *led_cdev)
> > +{
> > + struct device_node *np = dev_of_node(led_cdev->dev);
> > + const char *pattern;
> > +
> > + if (!np)
> > + return NULL;
> > +
> > + if (of_property_read_string(np, "led-pattern", &pattern))
> > + return NULL;
> > +
> > + if (!strlen(pattern))
> > + return NULL;
> > +
> > + return pattern;
> > +}
I missed here EXPORT_SYMBOL_GPL.
Best regards,
Krzysztof
> > +
> > +/**
> > * of_led_classdev_register - register a new object of led_classdev class.
> > *
> > * @parent: parent of LED device
> > diff --git a/include/linux/leds.h b/include/linux/leds.h
> > index 5263f87e1d2c..9da2bfa183ea 100644
> > --- a/include/linux/leds.h
> > +++ b/include/linux/leds.h
> > @@ -129,6 +129,9 @@ struct led_classdev {
> > struct mutex led_access;
> > };
> >
> > +extern const char *
> > +led_classdev_get_default_pattern(struct led_classdev *led_cdev);
> > +
> > extern int of_led_classdev_register(struct device *parent,
> > struct device_node *np,
> > struct led_classdev *led_cdev);
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2018-12-13 8:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 11:16 [PATCH v3 0/5] leds: trigger: Add pattern initialization from Device Tree Krzysztof Kozlowski
2018-12-12 11:16 ` [PATCH v3 1/5] dt-bindings: leds: " Krzysztof Kozlowski
2018-12-12 12:32 ` Pavel Machek
2018-12-13 8:36 ` Krzysztof Kozlowski
2018-12-17 22:40 ` Rob Herring
2018-12-18 9:06 ` Krzysztof Kozlowski
2018-12-12 11:16 ` [PATCH v3 2/5] leds: Add helper for getting default pattern " Krzysztof Kozlowski
2018-12-12 12:22 ` Pavel Machek
2018-12-13 8:21 ` Krzysztof Kozlowski [this message]
2018-12-12 11:16 ` [PATCH v3 3/5] leds: trigger: pattern: Add pattern initialization " Krzysztof Kozlowski
2018-12-12 11:16 ` [PATCH v3 4/5] leds: trigger: oneshot: Add " Krzysztof Kozlowski
2018-12-12 11:16 ` [PATCH v3 5/5] leds: trigger: timer: " Krzysztof Kozlowski
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='CAJKOXPcka9qc7CgXhA0jbEFUurAYO=GZP0utiuYcNee4AmnMNg@mail.gmail.com' \
--to=krzk@kernel.org \
--cc=baolin.wang@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pavel@ucw.cz \
--cc=robh+dt@kernel.org \
/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).