aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorMattia Dongili <malattia@linux.it>2012-05-19 09:35:47 -0400
committerMatthew Garrett <mjg@redhat.com>2012-05-31 14:29:34 -0400
commit9e1233792933bc9b64133c3b00f2f4ef8b02d1a2 (patch)
treeef2079551b0eab0c3657c80f7405d2f0f0dc38d6 /drivers/platform
parentebcef1b0e41f2ff972e5c5487a30e8f4ee2b6f13 (diff)
sony-laptop: use kstrtoul to parse sysfs values
This avoids surprises like echoing "enable" into a sysfs file and finding that the feature was actually disabled. Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/sony-laptop.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 6aefd3511a8d..d6c53c622b6c 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -944,7 +944,8 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
944 struct device_attribute *attr, 944 struct device_attribute *attr,
945 const char *buffer, size_t count) 945 const char *buffer, size_t count)
946{ 946{
947 int value, ret = 0; 947 unsigned long value = 0;
948 int ret = 0;
948 struct sony_nc_value *item = 949 struct sony_nc_value *item =
949 container_of(attr, struct sony_nc_value, devattr); 950 container_of(attr, struct sony_nc_value, devattr);
950 951
@@ -954,7 +955,8 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
954 if (count > 31) 955 if (count > 31)
955 return -EINVAL; 956 return -EINVAL;
956 957
957 value = simple_strtoul(buffer, NULL, 10); 958 if (kstrtoul(buffer, 10, &value))
959 return -EINVAL;
958 960
959 if (item->validate) 961 if (item->validate)
960 value = item->validate(SNC_VALIDATE_IN, value); 962 value = item->validate(SNC_VALIDATE_IN, value);
@@ -962,8 +964,8 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
962 if (value < 0) 964 if (value < 0)
963 return value; 965 return value;
964 966
965 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, &value, 967 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset,
966 NULL); 968 (int *)&value, NULL);
967 if (ret < 0) 969 if (ret < 0)
968 return -EIO; 970 return -EIO;
969 971
@@ -1445,7 +1447,7 @@ static ssize_t sony_nc_kbd_backlight_mode_store(struct device *dev,
1445 if (count > 31) 1447 if (count > 31)
1446 return -EINVAL; 1448 return -EINVAL;
1447 1449
1448 if (strict_strtoul(buffer, 10, &value)) 1450 if (kstrtoul(buffer, 10, &value))
1449 return -EINVAL; 1451 return -EINVAL;
1450 1452
1451 ret = __sony_nc_kbd_backlight_mode_set(value); 1453 ret = __sony_nc_kbd_backlight_mode_set(value);
@@ -1489,7 +1491,7 @@ static ssize_t sony_nc_kbd_backlight_timeout_store(struct device *dev,
1489 if (count > 31) 1491 if (count > 31)
1490 return -EINVAL; 1492 return -EINVAL;
1491 1493
1492 if (strict_strtoul(buffer, 10, &value)) 1494 if (kstrtoul(buffer, 10, &value))
1493 return -EINVAL; 1495 return -EINVAL;
1494 1496
1495 ret = __sony_nc_kbd_backlight_timeout_set(value); 1497 ret = __sony_nc_kbd_backlight_timeout_set(value);
@@ -2439,7 +2441,9 @@ static ssize_t sony_pic_wwanpower_store(struct device *dev,
2439 if (count > 31) 2441 if (count > 31)
2440 return -EINVAL; 2442 return -EINVAL;
2441 2443
2442 value = simple_strtoul(buffer, NULL, 10); 2444 if (kstrtoul(buffer, 10, &value))
2445 return -EINVAL;
2446
2443 mutex_lock(&spic_dev.lock); 2447 mutex_lock(&spic_dev.lock);
2444 __sony_pic_set_wwanpower(value); 2448 __sony_pic_set_wwanpower(value);
2445 mutex_unlock(&spic_dev.lock); 2449 mutex_unlock(&spic_dev.lock);
@@ -2476,7 +2480,9 @@ static ssize_t sony_pic_bluetoothpower_store(struct device *dev,
2476 if (count > 31) 2480 if (count > 31)
2477 return -EINVAL; 2481 return -EINVAL;
2478 2482
2479 value = simple_strtoul(buffer, NULL, 10); 2483 if (kstrtoul(buffer, 10, &value))
2484 return -EINVAL;
2485
2480 mutex_lock(&spic_dev.lock); 2486 mutex_lock(&spic_dev.lock);
2481 __sony_pic_set_bluetoothpower(value); 2487 __sony_pic_set_bluetoothpower(value);
2482 mutex_unlock(&spic_dev.lock); 2488 mutex_unlock(&spic_dev.lock);
@@ -2515,7 +2521,9 @@ static ssize_t sony_pic_fanspeed_store(struct device *dev,
2515 if (count > 31) 2521 if (count > 31)
2516 return -EINVAL; 2522 return -EINVAL;
2517 2523
2518 value = simple_strtoul(buffer, NULL, 10); 2524 if (kstrtoul(buffer, 10, &value))
2525 return -EINVAL;
2526
2519 if (sony_pic_set_fanspeed(value)) 2527 if (sony_pic_set_fanspeed(value))
2520 return -EIO; 2528 return -EIO;
2521 2529