From: Sven Wegener Date: Mon, 13 Oct 2008 09:41:39 +0000 (+0100) Subject: leds: Remove uneeded strlen calls X-Git-Tag: v2.6.28-rc1~6^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd8e5a2039607e0f79c33549726a2415d977c938;p=platform%2Fkernel%2Flinux-3.10.git leds: Remove uneeded strlen calls 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 Signed-off-by: Andrew Morton Signed-off-by: Richard Purdie --- diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index ee74ee7..8a7d138 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -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, diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index 5c99f4f..db68196 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c @@ -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,