diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-05-11 15:54:14 +0300 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-05-15 15:45:15 +0300 |
commit | 466f469733263d80ac53d321130d13eea3d875a4 (patch) | |
tree | 9e08c64a96ca2e5bd2c69eb1ef784188ad95cc14 /drivers/platform | |
parent | 35d13c7a05126a5a54a1ef40aff4c6984474e604 (diff) | |
download | linux-466f469733263d80ac53d321130d13eea3d875a4.tar.xz |
platform/x86: thinkpad_acpi: Replace custom approach by kstrtoint()
Call kstrtoint(), where appropriate, instead of using custom approach.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index bf651b850faa..ff7f0a4f2475 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -5446,23 +5446,18 @@ static int kbdlight_read(struct seq_file *m) static int kbdlight_write(char *buf) { char *cmd; - int level = -1; + int res, level = -EINVAL; if (!tp_features.kbdlight) return -ENODEV; while ((cmd = strsep(&buf, ","))) { - if (strlencmp(cmd, "0") == 0) - level = 0; - else if (strlencmp(cmd, "1") == 0) - level = 1; - else if (strlencmp(cmd, "2") == 0) - level = 2; - else - return -EINVAL; + res = kstrtoint(cmd, 10, &level); + if (res < 0) + return res; } - if (level == -1) + if (level >= 3 || level < 0) return -EINVAL; return kbdlight_set_level_and_update(level); @@ -9776,19 +9771,18 @@ static int lcdshadow_read(struct seq_file *m) static int lcdshadow_write(char *buf) { char *cmd; - int state = -1; + int res, state = -EINVAL; if (lcdshadow_state < 0) return -ENODEV; while ((cmd = strsep(&buf, ","))) { - if (strlencmp(cmd, "0") == 0) - state = 0; - else if (strlencmp(cmd, "1") == 0) - state = 1; + res = kstrtoint(cmd, 10, &state); + if (res < 0) + return res; } - if (state == -1) + if (state >= 2 || state < 0) return -EINVAL; return lcdshadow_set(state); |