aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-02-25 13:31:23 +0000
committerFelix Fietkau <nbd@openwrt.org>2016-02-25 13:31:23 +0000
commitf61a80444cc031a1f544e55d2093318c21d96e05 (patch)
treef2b9c653e711b81dd9ad0013c17e77f3b107235f /target/linux/generic/files/drivers/net
parent3f76eeaadcf3aacbede9c76b09b8eaa2b3580b97 (diff)
downloadupstream-f61a80444cc031a1f544e55d2093318c21d96e05.tar.gz
upstream-f61a80444cc031a1f544e55d2093318c21d96e05.tar.bz2
upstream-f61a80444cc031a1f544e55d2093318c21d96e05.zip
switch: make LED port_mask file write handler use kstrtoul() function
This patch changes swconfig_trig_port_mask_store() handler to utilize kstrtoul() function instead of call to obsolete simple_strtoul(). Thanks to this change, new handler takes less memory and makes port_mask special file accept not only hexadecimal, but also decimal and octal numbers. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl> SVN-Revision: 48774
Diffstat (limited to 'target/linux/generic/files/drivers/net')
-rw-r--r--target/linux/generic/files/drivers/net/phy/swconfig_leds.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/swconfig_leds.c b/target/linux/generic/files/drivers/net/phy/swconfig_leds.c
index abd7bed48c..7d122d26cd 100644
--- a/target/linux/generic/files/drivers/net/phy/swconfig_leds.c
+++ b/target/linux/generic/files/drivers/net/phy/swconfig_leds.c
@@ -94,37 +94,28 @@ swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr,
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
unsigned long port_mask;
- ssize_t ret = -EINVAL;
- char *after;
- size_t count;
+ int ret;
+ bool changed;
- port_mask = simple_strtoul(buf, &after, 16);
- count = after - buf;
+ ret = kstrtoul(buf, 0, &port_mask);
+ if (ret)
+ return ret;
- if (*after && isspace(*after))
- count++;
+ write_lock(&trig_data->lock);
- if (count == size) {
- bool changed;
-
- write_lock(&trig_data->lock);
-
- changed = (trig_data->port_mask != port_mask);
- if (changed) {
- trig_data->port_mask = port_mask;
- if (port_mask == 0)
- swconfig_trig_set_brightness(trig_data, LED_OFF);
- }
-
- write_unlock(&trig_data->lock);
+ changed = (trig_data->port_mask != port_mask);
+ if (changed) {
+ trig_data->port_mask = port_mask;
+ if (port_mask == 0)
+ swconfig_trig_set_brightness(trig_data, LED_OFF);
+ }
- if (changed)
- swconfig_trig_update_port_mask(led_cdev->trigger);
+ write_unlock(&trig_data->lock);
- ret = count;
- }
+ if (changed)
+ swconfig_trig_update_port_mask(led_cdev->trigger);
- return ret;
+ return size;
}
static ssize_t