[BNX2]: Add 5708S parallel detection.
[safe/jmp/linux-2.6] / drivers / leds / ledtrig-timer.c
index f484b5d..29a8818 100644 (file)
@@ -11,7 +11,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -20,6 +19,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 +69,15 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf,
        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 +101,15 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf,
        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;
@@ -115,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
 static void timer_trig_activate(struct led_classdev *led_cdev)
 {
        struct timer_trig_data *timer_data;
+       int rc;
 
        timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
        if (!timer_data)
@@ -126,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
        timer_data->timer.function = led_timer_function;
        timer_data->timer.data = (unsigned long) led_cdev;
 
-       class_device_create_file(led_cdev->class_dev,
+       rc = class_device_create_file(led_cdev->class_dev,
                                &class_device_attr_delay_on);
-       class_device_create_file(led_cdev->class_dev,
+       if (rc) goto err_out;
+       rc = class_device_create_file(led_cdev->class_dev,
                                &class_device_attr_delay_off);
+       if (rc) goto err_out_delayon;
+
+       return;
+
+err_out_delayon:
+       class_device_remove_file(led_cdev->class_dev,
+                               &class_device_attr_delay_on);
+err_out:
+       led_cdev->trigger_data = NULL;
+       kfree(timer_data);
 }
 
 static void timer_trig_deactivate(struct led_classdev *led_cdev)