* [PATCH] LED: Fix sysfs store function error handling
@ 2006-05-06 11:12 Richard Purdie
0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2006-05-06 11:12 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML, Johannes Berg
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>
Index: git/drivers/leds/led-class.c
===================================================================
--- git.orig/drivers/leds/led-class.c 2006-05-04 23:12:57.000000000 +0100
+++ git/drivers/leds/led-class.c 2006-05-06 11:01:04.000000000 +0100
@@ -19,6 +19,7 @@
#include <linux/sysdev.h>
#include <linux/timer.h>
#include <linux/err.h>
+#include <linux/ctype.h>
#include <linux/leds.h>
#include "leds.h"
@@ -43,9 +44,13 @@
ssize_t ret = -EINVAL;
char *after;
unsigned long state = simple_strtoul(buf, &after, 10);
+ size_t count = after - buf;
- if (after - buf > 0) {
- ret = after - buf;
+ if (*after && isspace(*after))
+ count++;
+
+ if (count == size) {
+ ret = count;
led_set_brightness(led_cdev, state);
}
Index: git/drivers/leds/ledtrig-timer.c
===================================================================
--- git.orig/drivers/leds/ledtrig-timer.c 2006-05-04 23:12:57.000000000 +0100
+++ git/drivers/leds/ledtrig-timer.c 2006-05-06 11:01:42.000000000 +0100
@@ -20,6 +20,7 @@
#include <linux/device.h>
#include <linux/sysdev.h>
#include <linux/timer.h>
+#include <linux/ctype.h>
#include <linux/leds.h>
#include "leds.h"
@@ -69,11 +70,15 @@
int ret = -EINVAL;
char *after;
unsigned long state = simple_strtoul(buf, &after, 10);
+ size_t count = after - buf;
- if (after - buf > 0) {
+ if (*after && isspace(*after))
+ count++;
+
+ if (count == size) {
timer_data->delay_on = state;
mod_timer(&timer_data->timer, jiffies + 1);
- ret = after - buf;
+ ret = count;
}
return ret;
@@ -97,11 +102,15 @@
int ret = -EINVAL;
char *after;
unsigned long state = simple_strtoul(buf, &after, 10);
+ size_t count = after - buf;
+
+ if (*after && isspace(*after))
+ count++;
- if (after - buf > 0) {
+ if (count == size) {
timer_data->delay_off = state;
mod_timer(&timer_data->timer, jiffies + 1);
- ret = after - buf;
+ ret = count;
}
return ret;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-06 11:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-06 11:12 [PATCH] LED: Fix sysfs store function error handling Richard Purdie
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®