]> git.karo-electronics.de Git - linux-beck.git/commitdiff
leds: Remove uneeded strlen calls
authorSven Wegener <sven.wegener@stealer.net>
Mon, 13 Oct 2008 09:41:39 +0000 (10:41 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Mon, 20 Oct 2008 21:37:04 +0000 (22:37 +0100)
There's no need for the additional call to strlen(), we can directly
return the value returned by sprintf().  We now return a length value
that doesn't include the final '\0', but user space shouldn't bother
about it anyway.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
drivers/leds/led-class.c
drivers/leds/ledtrig-timer.c

index ee74ee7b2accab837fc43c0c8cda523795bed5ce..8a7d138ec503dd6acbdebc4a303ac9a32648efda 100644 (file)
@@ -34,14 +34,11 @@ static ssize_t led_brightness_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
-       ssize_t ret = 0;
 
        /* no lock needed for this */
        led_update_brightness(led_cdev);
-       sprintf(buf, "%u\n", led_cdev->brightness);
-       ret = strlen(buf) + 1;
 
-       return ret;
+       return sprintf(buf, "%u\n", led_cdev->brightness);
 }
 
 static ssize_t led_brightness_store(struct device *dev,
index 5c99f4f0c69214f101a519c9c190d57aae64e317..db681962d7bb14742d53dea274ea3c49e424b6dd 100644 (file)
@@ -70,9 +70,7 @@ static ssize_t led_delay_on_show(struct device *dev,
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
        struct timer_trig_data *timer_data = led_cdev->trigger_data;
 
-       sprintf(buf, "%lu\n", timer_data->delay_on);
-
-       return strlen(buf) + 1;
+       return sprintf(buf, "%lu\n", timer_data->delay_on);
 }
 
 static ssize_t led_delay_on_store(struct device *dev,
@@ -116,9 +114,7 @@ static ssize_t led_delay_off_show(struct device *dev,
        struct led_classdev *led_cdev = dev_get_drvdata(dev);
        struct timer_trig_data *timer_data = led_cdev->trigger_data;
 
-       sprintf(buf, "%lu\n", timer_data->delay_off);
-
-       return strlen(buf) + 1;
+       return sprintf(buf, "%lu\n", timer_data->delay_off);
 }
 
 static ssize_t led_delay_off_store(struct device *dev,