From: Anton Vorontsov <cbou@mail.ru>
To: Richard Purdie <rpurdie@rpsys.net>
Cc: kogiidena@eggplant.ddo.jp, linux-kernel@vger.kernel.org,
lethal@linux-sh.org
Subject: Re: [PATCH 1/2] leds:arch/sh/boards/landisk LEDs supports
Date: Mon, 14 May 2007 23:56:51 +0400 [thread overview]
Message-ID: <20070514195651.GA26554@zarina> (raw)
In-Reply-To: <1179098182.5883.31.camel@localhost.localdomain>
On Mon, May 14, 2007 at 12:16:22AM +0100, Richard Purdie wrote:
> On Wed, 2007-05-09 at 20:03 +0400, Anton Vorontsov wrote:
> > Following patch sitting for a long time in our handhelds.org tree.
> >
> > kogiidena, I'm almost sure you'll find it useful, just apply patch,
> > and implement .is_led_supported function for your trigger, which will
> > eliminate trigger showing in
> > /sys/class/leds/LED_WHICH_NOT_SUPPORTS_CUSTOM_TRIGGER/triggers
>
> I like the approach and will apply something like this.
Splendid!
> Comments
> follow..
...
> Missing newline.
...
> ditto.
Thanks, fixed.
> Thanks,
>
> Richard
From: Anton Vorontsov <cbou@mail.ru>
Date: Mon, 14 May 2007 23:39:30 +0400
Subject: [PATCH] Custom triggers support, which are might not supported by all LEDs
Signed-off-by: Anton Vorontsov <cbou@mail.ru>
---
drivers/leds/led-triggers.c | 11 ++++++++++-
include/linux/leds.h | 1 +
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 454fb09..7fde7d0 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -53,6 +53,10 @@ ssize_t led_trigger_store(struct class_device *dev, const char *buf,
read_lock(&triggers_list_lock);
list_for_each_entry(trig, &trigger_list, next_trig) {
if (!strcmp(trigger_name, trig->name)) {
+ if (trig->is_led_supported &&
+ !trig->is_led_supported(led_cdev))
+ break;
+
write_lock(&led_cdev->trigger_lock);
led_trigger_set(led_cdev, trig);
write_unlock(&led_cdev->trigger_lock);
@@ -85,6 +89,9 @@ ssize_t led_trigger_show(struct class_device *dev, char *buf)
if (led_cdev->trigger && !strcmp(led_cdev->trigger->name,
trig->name))
len += sprintf(buf+len, "[%s] ", trig->name);
+ else if (trig->is_led_supported &&
+ !trig->is_led_supported(led_cdev))
+ continue;
else
len += sprintf(buf+len, "%s ", trig->name);
}
@@ -171,7 +178,9 @@ int led_trigger_register(struct led_trigger *trigger)
list_for_each_entry(led_cdev, &leds_list, node) {
write_lock(&led_cdev->trigger_lock);
if (!led_cdev->trigger && led_cdev->default_trigger &&
- !strcmp(led_cdev->default_trigger, trigger->name))
+ !strcmp(led_cdev->default_trigger, trigger->name) &&
+ (!trigger->is_led_supported ||
+ trigger->is_led_supported(led_cdev)))
led_trigger_set(led_cdev, trigger);
write_unlock(&led_cdev->trigger_lock);
}
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 88afcef..71175f6 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -70,6 +70,7 @@ struct led_trigger {
const char *name;
void (*activate)(struct led_classdev *led_cdev);
void (*deactivate)(struct led_classdev *led_cdev);
+ int (*is_led_supported)(struct led_classdev *led_cdev);
/* LEDs under control by this trigger (for simple triggers) */
rwlock_t leddev_list_lock;
--
1.5.1.1-dirty
next prev parent reply other threads:[~2007-05-14 19:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-08 12:26 [PATCH 1/2] leds:arch/sh/boards/landisk LEDs supports kogiidena
2007-05-08 12:54 ` Richard Purdie
2007-05-09 14:26 ` kogiidena
2007-05-09 15:13 ` Richard Purdie
2007-05-09 16:03 ` Anton Vorontsov
2007-05-10 11:52 ` kogiidena
2007-05-10 14:04 ` Paul Mundt
2007-05-11 15:03 ` kogiidena
2007-05-12 4:01 ` kogiidena
2007-05-13 23:16 ` Richard Purdie
2007-05-14 19:56 ` Anton Vorontsov [this message]
2007-05-14 20:12 ` Anton Vorontsov
2007-05-14 20:33 ` Richard Purdie
2007-05-14 21:13 ` Anton Vorontsov
2007-05-09 21:48 ` kogiidena
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=20070514195651.GA26554@zarina \
--to=cbou@mail.ru \
--cc=kogiidena@eggplant.ddo.jp \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--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 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.