Skip to contentSkip to conversation

leds: core: add color LED sysfs extension

PATCH Superseded Heiner Kallweit 2 participants 3 messages Feb 16, 2016 – Feb 17, 2016 LED

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/4 leds: core: add color LED sysfs extension

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

---
v2:
- split from patch 1

---
 drivers/leds/led-class.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/leds/led-class.c +6 -3
index aa84e5b..09e0007 100644
@@ -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);
 
Signature · 1 line
2.7.1
#1 lore raw

Hi Heiner,

Quoted 28 lines · Heiner Kallweit

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

---
v2:
- split from patch 1

---
  drivers/leds/led-class.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/leds/led-class.c +4 -1
index aa84e5b..09e0007 100644
@@ -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,

drivers/leds/led-class.c static ssize_t brightness_store(struct device *dev, · line 57

Quoted 7 lines
drivers/leds/led-class.c +1 -1
@@ -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;

Please leave only this change in the patch, as it extends the scope of possible arguments for user space. Remaining changes can be moved to 1/4.

Quoted 7 lines
drivers/leds/led-class.c +1 -1
-	if (state == LED_OFF)
+	if (is_off(state))
  		led_trigger_remove(led_cdev);
  	led_set_brightness(led_cdev, state);
 
 
Signature · 2 lines
Best regards,
Jacek Anaszewski
#2 lore raw
Quoted 22 lines · Jacek Anaszewski

Hi Heiner,

Quoted 19 lines · Heiner Kallweit

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

---
v2:
- split from patch 1

---
  drivers/leds/led-class.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/leds/led-class.c +0 -0
index aa84e5b..09e0007 100644
@@ -32,7 +32,10 @@ static ssize_t brightness_show(struct device *dev,
      /* no lock needed for this */
      led_update_brightness(led_cdev);
 
Quoted 6 lines

drivers/leds/led-class.c static ssize_t brightness_show(struct device *dev, · line 39

Quoted 6 lines
drivers/leds/led-class.c +4 -1
-    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);
  }

This change also should remain here.

Quoted 5 lines
Quoted 5 lines
drivers/leds/led-class.c +0 -0
  static ssize_t brightness_store(struct device *dev,
@@ -49,11 +52,11 @@ static ssize_t brightness_store(struct device *dev,
          goto unlock;
      }
 
Quoted 13 lines

drivers/leds/led-class.c static ssize_t brightness_store(struct device *dev, · line 57

Quoted 4 lines
drivers/leds/led-class.c +1 -1
-    ret = kstrtoul(buf, 10, &state);
+    ret = kstrtoul(buf, 0, &state);
      if (ret)
          goto unlock;

Please leave only this change in the patch, as it extends the scope of possible arguments for user space. Remaining changes can be moved to 1/4.

Quoted 3 lines
drivers/leds/led-class.c +1 -1
-    if (state == LED_OFF)
+    if (is_off(state))

Only this should go to 1/4.

Quoted 6 lines
Quoted 4 lines
drivers/leds/led-class.c +0 -0
          led_trigger_remove(led_cdev);
      led_set_brightness(led_cdev, state);
 
 
Signature · 2 lines
Best regards,
Jacek Anaszewski