mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2024-12-11 17:34:57 +00:00
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
This commit is contained in:
parent
3f76eeaadc
commit
f61a80444c
@ -94,19 +94,13 @@ swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr,
|
|||||||
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||||
struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
|
struct swconfig_trig_data *trig_data = led_cdev->trigger_data;
|
||||||
unsigned long port_mask;
|
unsigned long port_mask;
|
||||||
ssize_t ret = -EINVAL;
|
int ret;
|
||||||
char *after;
|
|
||||||
size_t count;
|
|
||||||
|
|
||||||
port_mask = simple_strtoul(buf, &after, 16);
|
|
||||||
count = after - buf;
|
|
||||||
|
|
||||||
if (*after && isspace(*after))
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (count == size) {
|
|
||||||
bool changed;
|
bool changed;
|
||||||
|
|
||||||
|
ret = kstrtoul(buf, 0, &port_mask);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
write_lock(&trig_data->lock);
|
write_lock(&trig_data->lock);
|
||||||
|
|
||||||
changed = (trig_data->port_mask != port_mask);
|
changed = (trig_data->port_mask != port_mask);
|
||||||
@ -121,10 +115,7 @@ swconfig_trig_port_mask_store(struct device *dev, struct device_attribute *attr,
|
|||||||
if (changed)
|
if (changed)
|
||||||
swconfig_trig_update_port_mask(led_cdev->trigger);
|
swconfig_trig_update_port_mask(led_cdev->trigger);
|
||||||
|
|
||||||
ret = count;
|
return size;
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
Loading…
Reference in New Issue
Block a user