* [PATCH] LED: add support to leds with readable status
@ 2008-03-16 16:50 Henrique de Moraes Holschuh
2008-03-16 17:27 ` Henrique de Moraes Holschuh
0 siblings, 1 reply; 3+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-03-16 16:50 UTC (permalink / raw)
To: Richard Purdie
Cc: N�meth M�rton, linux-kernel,
Henrique de Moraes Holschuh, Richard Purdie
Some led hardware allows drivers to query the led state, and this patch
adds a hook to let the led class take advantage of that information when
available.
Without this functionality, when access to the led hardware is not
exclusive (i.e. firmware or hardware might change its state behind the
kernel's back), reality goes out of sync with the led class' idea of what
the led is doing, which is annoying at best.
Behaviour for drivers that do not or cannot read the led status is
unchanged.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
drivers/leds/led-class.c | 9 +++++++++
include/linux/leds.h | 2 ++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index e6c5b98..2b4bcd4 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -24,6 +24,12 @@
static struct class *leds_class;
+static void led_update_brightness(struct led_classdev *led_cdev)
+{
+ if (led_cdev->brightness_get)
+ led_cdev->brightness = led_cdev->brightness_get(led_cdev);
+}
+
static ssize_t led_brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -31,6 +37,7 @@ static ssize_t led_brightness_show(struct device *dev,
ssize_t ret = 0;
/* no lock needed for this */
+ led_update_brightness(led_cdev);
sprintf(buf, "%u\n", led_cdev->brightness);
ret = strlen(buf) + 1;
@@ -113,6 +120,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
list_add_tail(&led_cdev->node, &leds_list);
up_write(&leds_list_lock);
+ led_update_brightness(led_cdev);
+
#ifdef CONFIG_LEDS_TRIGGERS
init_rwsem(&led_cdev->trigger_lock);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 01adfad..de704f0 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -37,6 +37,8 @@ struct led_classdev {
/* Set LED brightness level */
void (*brightness_set)(struct led_classdev *led_cdev,
enum led_brightness brightness);
+ /* Get LED brightness level */
+ enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
/* Activate hardware accelerated blink */
int (*blink_set)(struct led_classdev *led_cdev,
--
1.5.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] LED: add support to leds with readable status
2008-03-16 16:50 [PATCH] LED: add support to leds with readable status Henrique de Moraes Holschuh
@ 2008-03-16 17:27 ` Henrique de Moraes Holschuh
2008-03-16 17:57 ` [PATCH] leds: " Henrique de Moraes Holschuh
0 siblings, 1 reply; 3+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-03-16 17:27 UTC (permalink / raw)
To: Richard Purdie; +Cc: N?meth M?rton, linux-kernel
Richard,
Thinkpad-acpi LED support needs this patch...
Code using this feature is available for a quick peek at:
http://repo.or.cz/w/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git?a=shortlog;h=refs/heads/devel
and I'd like to submit for merging during 2.6.26's merge window (which means
it needs to go to acpi-test soon).
I need your opinion on the patch, and to know where you will accept it for
2.6.26 or not, in order to plan my submission path for the stuff that
depends on it.
It applies cleanly on top of your for-mm branch.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] leds: add support to leds with readable status
2008-03-16 17:27 ` Henrique de Moraes Holschuh
@ 2008-03-16 17:57 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 3+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-03-16 17:57 UTC (permalink / raw)
To: Richard Purdie; +Cc: linux-kernel
Some led hardware allows drivers to query the led state, and this patch
adds a hook to let the led class take advantage of that information when
available.
Without this functionality, when access to the led hardware is not
exclusive (i.e. firmware or hardware might change its state behind the
kernel's back), reality goes out of sync with the led class' idea of what
the led is doing, which is annoying at best.
Behaviour for drivers that do not or cannot read the led status is
unchanged.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
Resend with a proper "leds:" prefix on patch short title
instead of "LED:".
drivers/leds/led-class.c | 9 +++++++++
include/linux/leds.h | 2 ++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 1801317..3c40383 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -24,6 +24,12 @@
static struct class *leds_class;
+static void led_update_brightness(struct led_classdev *led_cdev)
+{
+ if (led_cdev->brightness_get)
+ led_cdev->brightness = led_cdev->brightness_get(led_cdev);
+}
+
static ssize_t led_brightness_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -31,6 +37,7 @@ static ssize_t led_brightness_show(struct device *dev,
ssize_t ret = 0;
/* no lock needed for this */
+ led_update_brightness(led_cdev);
sprintf(buf, "%u\n", led_cdev->brightness);
ret = strlen(buf) + 1;
@@ -113,6 +120,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
list_add_tail(&led_cdev->node, &leds_list);
up_write(&leds_list_lock);
+ led_update_brightness(led_cdev);
+
#ifdef CONFIG_LEDS_TRIGGERS
init_rwsem(&led_cdev->trigger_lock);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 4cb5927..dd5969e 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -37,6 +37,8 @@ struct led_classdev {
/* Set LED brightness level */
void (*brightness_set)(struct led_classdev *led_cdev,
enum led_brightness brightness);
+ /* Get LED brightness level */
+ enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
/* Activate hardware accelerated blink */
int (*blink_set)(struct led_classdev *led_cdev,
--
1.5.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-03-16 17:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-16 16:50 [PATCH] LED: add support to leds with readable status Henrique de Moraes Holschuh
2008-03-16 17:27 ` Henrique de Moraes Holschuh
2008-03-16 17:57 ` [PATCH] leds: " Henrique de Moraes Holschuh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®