aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-05-15 12:44:17 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-15 14:20:56 -0400
commit3dc7b82ea7649356bf027fba50c16ca50cec31e2 (patch)
tree52bb14b8021c851d6cbd765f74aafa6c33ea631e /drivers/leds/led-class.c
parent263de9b582b0f9b6ad5a0651b7df884fe80d6c3c (diff)
[PATCH] LED: Fix sysfs store function error handling
Fix the error handling of some LED _store functions. This corrects them to return -EINVAL if the value is not numeric with an optional byte of trailing whitespace. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r--drivers/leds/led-class.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index b0b5d05fadd6..c75d0ef1609c 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -19,6 +19,7 @@
19#include <linux/sysdev.h> 19#include <linux/sysdev.h>
20#include <linux/timer.h> 20#include <linux/timer.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/ctype.h>
22#include <linux/leds.h> 23#include <linux/leds.h>
23#include "leds.h" 24#include "leds.h"
24 25
@@ -43,9 +44,13 @@ static ssize_t led_brightness_store(struct class_device *dev,
43 ssize_t ret = -EINVAL; 44 ssize_t ret = -EINVAL;
44 char *after; 45 char *after;
45 unsigned long state = simple_strtoul(buf, &after, 10); 46 unsigned long state = simple_strtoul(buf, &after, 10);
47 size_t count = after - buf;
46 48
47 if (after - buf > 0) { 49 if (*after && isspace(*after))
48 ret = after - buf; 50 count++;
51
52 if (count == size) {
53 ret = count;
49 led_set_brightness(led_cdev, state); 54 led_set_brightness(led_cdev, state);
50 } 55 }
51 56