Commit 466f4697 authored by Andy Shevchenko's avatar Andy Shevchenko

platform/x86: thinkpad_acpi: Replace custom approach by kstrtoint()

Call kstrtoint(), where appropriate, instead of using custom approach.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 35d13c7a
...@@ -5446,23 +5446,18 @@ static int kbdlight_read(struct seq_file *m) ...@@ -5446,23 +5446,18 @@ static int kbdlight_read(struct seq_file *m)
static int kbdlight_write(char *buf) static int kbdlight_write(char *buf)
{ {
char *cmd; char *cmd;
int level = -1; int res, level = -EINVAL;
if (!tp_features.kbdlight) if (!tp_features.kbdlight)
return -ENODEV; return -ENODEV;
while ((cmd = strsep(&buf, ","))) { while ((cmd = strsep(&buf, ","))) {
if (strlencmp(cmd, "0") == 0) res = kstrtoint(cmd, 10, &level);
level = 0; if (res < 0)
else if (strlencmp(cmd, "1") == 0) return res;
level = 1;
else if (strlencmp(cmd, "2") == 0)
level = 2;
else
return -EINVAL;
} }
if (level == -1) if (level >= 3 || level < 0)
return -EINVAL; return -EINVAL;
return kbdlight_set_level_and_update(level); return kbdlight_set_level_and_update(level);
...@@ -9776,19 +9771,18 @@ static int lcdshadow_read(struct seq_file *m) ...@@ -9776,19 +9771,18 @@ static int lcdshadow_read(struct seq_file *m)
static int lcdshadow_write(char *buf) static int lcdshadow_write(char *buf)
{ {
char *cmd; char *cmd;
int state = -1; int res, state = -EINVAL;
if (lcdshadow_state < 0) if (lcdshadow_state < 0)
return -ENODEV; return -ENODEV;
while ((cmd = strsep(&buf, ","))) { while ((cmd = strsep(&buf, ","))) {
if (strlencmp(cmd, "0") == 0) res = kstrtoint(cmd, 10, &state);
state = 0; if (res < 0)
else if (strlencmp(cmd, "1") == 0) return res;
state = 1;
} }
if (state == -1) if (state >= 2 || state < 0)
return -EINVAL; return -EINVAL;
return lcdshadow_set(state); return lcdshadow_set(state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment