leds: simple_strtoul-cleanup
PATCH 1/1 leds: simple_strtoul-cleanup
led-class.c and ledtri-timer.c still use simple_strtoul(). Change leds to use kstrtoul() instead of obsolete simple_strtoul().
Quoted 1 line
From
1bd3a727b022e35c5c4506b610798acd8b05b70dMon Sep 17 00:00:00 2001
From: Shuah Khan <[email protected]>
Date: Sun, 8 Apr 2012 13:39:30 -0600
Subject: [PATCH] leds: simple_strtoul-cleanup
--- drivers/leds/led-class.c | 24 ++++++++++-------------- drivers/leds/ledtrig-timer.c | 42 ++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 38 deletions(-)
drivers/leds/led-class.c +10 -14
@@ -44,23 +44,19 @@ static ssize_t led_brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct led_classdev *led_cdev = dev_get_drvdata(dev); -ssize_t ret = -EINVAL ; -char *after; -unsigned long state =simple_strtoul (buf, &after,10 ); -size_t count = after - buf; +unsigned long state; +int ret; -if (isspace (*after)) - count++; + ret =kstrtoul (buf,10 , &state); +if (ret) + goto out; -if (count == size) { - ret = count; +if (state ==LED_OFF ) +led_trigger_remove (led_cdev); +led_set_brightness (led_cdev, state); -if (state ==LED_OFF ) -led_trigger_remove (led_cdev); -led_set_brightness (led_cdev, state); - } - -return ret; +out: +return size; } static ssize_t led_max_brightness_show(struct device *dev,
drivers/leds/ledtrig-timer.c +22 -28
64 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Quoted 2 lines · Shuah Khan
led-class.candledtri-timer.cstill usesimple_strtoul(). Change leds to usekstrtoul()instead of obsoletesimple_strtoul().
[]
Review static ssize_t led_brightness_store(struct device *dev, · line 44
Quoted 2 lines
(quoted diff) +0
-0@@ -44,23 +44,19 @@ static ssize_t led_brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
[]
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 31
Quoted 3 lines
drivers/leds/ledtrig-timer.c +0
-0@@ -31,21 +31,18 @@ static ssize_t led_delay_on_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
[]
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 48
Quoted 1 line
drivers/leds/ledtrig-timer.c +0
-0static ssize_t led_delay_off_show(struct device *dev,
[]
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 34
Quoted 2 lines
drivers/leds/ledtrig-timer.c +2
-0+out: +return size;
These now don't return -EINVAL, is that a problem
for any caller?
Quoted 11 lines · Joe Perches
Quoted 2 lines · Shuah Khan
led-class.candledtri-timer.cstill usesimple_strtoul(). Change leds to usekstrtoul()instead of obsoletesimple_strtoul().[]
Review static ssize_t led_brightness_store(struct device *dev, · line 44
Quoted 2 lines
(quoted diff) +0
-0@@ -44,23 +44,19 @@ static ssize_t led_brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)[]
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 31
Quoted 3 lines
drivers/leds/ledtrig-timer.c +0
-0@@ -31,21 +31,18 @@ static ssize_t led_delay_on_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)[]
Quoted 7 lines
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 48
Quoted 1 line
drivers/leds/ledtrig-timer.c +0
-0static ssize_t led_delay_off_show(struct device *dev,[]
drivers/leds/ledtrig-timer.c static ssize_t led_delay_on_store(struct device *dev, · line 34
Quoted 2 lines
drivers/leds/ledtrig-timer.c +2
-0+out: +return size;These now don't return
-EINVAL, is that a problem
for any caller?
I looked at the other _store() interfaces in leds - there is no consistent EINVAL return. However, it would be an easy change to make to have these return EINVAL in case of error like they used to. I can send an updated patch.
-- Shuah
led-class.c and ledtri-timer.c still use simple_strtoul(). Change leds to use kstrtoul() instead of obsolete simple_strtoul().
This patch version addresses Joe's review comment. Added returning -EINVAL in error paths back in. Also fixed existing int ret declaration to be ssize_t to match the return type for _store functions in ledtrig-timer.c
Quoted 1 line
From
411bd03d4327d210595264c39f71e6f446ac0f90Mon Sep 17 00:00:00 2001
From: Shuah Khan <[email protected]>
Date: Mon, 9 Apr 2012 09:05:07 -0600
Subject: [PATCH] leds: simple_strtoul-cleanup
--- drivers/leds/led-class.c | 21 ++++++++------------- drivers/leds/ledtrig-timer.c | 40 ++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 37 deletions(-)
drivers/leds/led-class.c +8 -13
@@ -44,23 +44,18 @@ static ssize_t led_brightness_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct led_classdev *led_cdev = dev_get_drvdata(dev); +unsigned long state;ssize_t ret = -EINVAL ; -char *after; -unsigned long state =simple_strtoul (buf, &after,10 ); -size_t count = after - buf; -if (isspace (*after)) - count++; + ret =kstrtoul (buf,10 , &state); +if (ret) +return ret; -if (count == size) { - ret = count; +if (state ==LED_OFF ) +led_trigger_remove (led_cdev); +led_set_brightness (led_cdev, state); -if (state ==LED_OFF ) -led_trigger_remove (led_cdev); -led_set_brightness (led_cdev, state); - } - -return ret; +return size; } static ssize_t led_max_brightness_show(struct device *dev,
drivers/leds/ledtrig-timer.c +20 -28
62 lines not on this page · raw message
Signature · 1 line
1.7.5.4