From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH] leds: triggers: simplify led_trigger_store
Date: Wed, 09 Mar 2016 16:29:56 +0100 [thread overview]
Message-ID: <56E04174.1030506@samsung.com> (raw)
In-Reply-To: <56DF4D64.4050908@gmail.com>
Hi Heiner,
Thanks for the patch. Applied to linux-leds.git.
Best regards,
Jacek Anaszewski
On 03/08/2016 11:08 PM, Heiner Kallweit wrote:
> led_trigger_store can be significantly simplified by using sysfs_streq().
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/leds/led-triggers.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index e1e9334..2181581 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -34,9 +34,7 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> struct led_classdev *led_cdev = dev_get_drvdata(dev);
> - char trigger_name[TRIG_NAME_MAX];
> struct led_trigger *trig;
> - size_t len;
> int ret = count;
>
> mutex_lock(&led_cdev->led_access);
> @@ -46,21 +44,14 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
> goto unlock;
> }
>
> - trigger_name[sizeof(trigger_name) - 1] = '\0';
> - strncpy(trigger_name, buf, sizeof(trigger_name) - 1);
> - len = strlen(trigger_name);
> -
> - if (len && trigger_name[len - 1] == '\n')
> - trigger_name[len - 1] = '\0';
> -
> - if (!strcmp(trigger_name, "none")) {
> + if (sysfs_streq(buf, "none")) {
> led_trigger_remove(led_cdev);
> goto unlock;
> }
>
> down_read(&triggers_list_lock);
> list_for_each_entry(trig, &trigger_list, next_trig) {
> - if (!strcmp(trigger_name, trig->name)) {
> + if (sysfs_streq(buf, trig->name)) {
> down_write(&led_cdev->trigger_lock);
> led_trigger_set(led_cdev, trig);
> up_write(&led_cdev->trigger_lock);
>
prev parent reply other threads:[~2016-03-09 15:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 22:08 [PATCH] leds: triggers: simplify led_trigger_store Heiner Kallweit
2016-03-09 15:29 ` Jacek Anaszewski [this message]
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=56E04174.1030506@samsung.com \
--to=j.anaszewski@samsung.com \
--cc=hkallweit1@gmail.com \
--cc=linux-leds@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.