diff mbox

[RESEND,#2,v2] LEDS: Add output invertion option to backlight trigger

Message ID 20110106130440.cfd77c8e.akpm@linux-foundation.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andrew Morton Jan. 6, 2011, 9:04 p.m. UTC
None
diff mbox

Patch

--- a/drivers/leds/ledtrig-backlight.c~leds-add-output-inversion-option-to-backlight-trigger-fix
+++ a/drivers/leds/ledtrig-backlight.c
@@ -65,7 +65,7 @@  static ssize_t bl_trig_invert_show(struc
 	struct led_classdev *led = dev_get_drvdata(dev);
 	struct bl_trig_notifier *n = led->trigger_data;
 
-	return sprintf(buf, "%s\n", n->invert ? "yes" : "no");
+	return sprintf(buf, "%u\n", n->invert);
 }
 
 static ssize_t bl_trig_invert_store(struct device *dev,
@@ -73,16 +73,17 @@  static ssize_t bl_trig_invert_store(stru
 {
 	struct led_classdev *led = dev_get_drvdata(dev);
 	struct bl_trig_notifier *n = led->trigger_data;
-	unsigned invert;
+	unsigned long invert;
 	int ret;
 
-	ret = sscanf(buf, "%u", &invert);
-	if (ret < 1) {
-		dev_err(dev, "invalid value\n");
+	ret = strict_strtoul(buf, 10, &invert);
+	if (ret < 0)
+		return ret;
+
+	if (invert > 1)
 		return -EINVAL;
-	}
 
-	n->invert = !!invert;
+	n->invert = invert;
 
 	/* After inverting, we need to update the LED. */
 	if ((n->old_status == BLANK) ^ n->invert)