All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/4] leds: core: add color LED sysfs extension
@ 2016-02-16 19:28 Heiner Kallweit
  2016-02-17 12:33 ` Jacek Anaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Heiner Kallweit @ 2016-02-16 19:28 UTC (permalink / raw)
  To: Jacek Anaszewski, linux-leds

Extend brightness sysfs property handling to deal with monochrome
and color mode as well.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- split from patch 1
---
 drivers/leds/led-class.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aa84e5b..09e0007 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -32,7 +32,10 @@ static ssize_t brightness_show(struct device *dev,
 	/* no lock needed for this */
 	led_update_brightness(led_cdev);
 
-	return sprintf(buf, "%u\n", led_cdev->brightness);
+	if (led_cdev->brightness > LED_FULL)
+		return sprintf(buf, "%#06x\n", led_cdev->brightness);
+	else
+		return sprintf(buf, "%u\n", led_cdev->brightness);
 }
 
 static ssize_t brightness_store(struct device *dev,
@@ -49,11 +52,11 @@ static ssize_t brightness_store(struct device *dev,
 		goto unlock;
 	}
 
-	ret = kstrtoul(buf, 10, &state);
+	ret = kstrtoul(buf, 0, &state);
 	if (ret)
 		goto unlock;
 
-	if (state == LED_OFF)
+	if (is_off(state))
 		led_trigger_remove(led_cdev);
 	led_set_brightness(led_cdev, state);
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-17 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 19:28 [PATCH v2 2/4] leds: core: add color LED sysfs extension Heiner Kallweit
2016-02-17 12:33 ` Jacek Anaszewski
2016-02-17 12:43   ` Jacek Anaszewski

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.