Skip to content

Commit 466f469

Browse files
committed
platform/x86: thinkpad_acpi: Replace custom approach by kstrtoint()
Call kstrtoint(), where appropriate, instead of using custom approach. Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 35d13c7 commit 466f469

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5446,23 +5446,18 @@ static int kbdlight_read(struct seq_file *m)
54465446
static int kbdlight_write(char *buf)
54475447
{
54485448
char *cmd;
5449-
int level = -1;
5449+
int res, level = -EINVAL;
54505450

54515451
if (!tp_features.kbdlight)
54525452
return -ENODEV;
54535453

54545454
while ((cmd = strsep(&buf, ","))) {
5455-
if (strlencmp(cmd, "0") == 0)
5456-
level = 0;
5457-
else if (strlencmp(cmd, "1") == 0)
5458-
level = 1;
5459-
else if (strlencmp(cmd, "2") == 0)
5460-
level = 2;
5461-
else
5462-
return -EINVAL;
5455+
res = kstrtoint(cmd, 10, &level);
5456+
if (res < 0)
5457+
return res;
54635458
}
54645459

5465-
if (level == -1)
5460+
if (level >= 3 || level < 0)
54665461
return -EINVAL;
54675462

54685463
return kbdlight_set_level_and_update(level);
@@ -9776,19 +9771,18 @@ static int lcdshadow_read(struct seq_file *m)
97769771
static int lcdshadow_write(char *buf)
97779772
{
97789773
char *cmd;
9779-
int state = -1;
9774+
int res, state = -EINVAL;
97809775

97819776
if (lcdshadow_state < 0)
97829777
return -ENODEV;
97839778

97849779
while ((cmd = strsep(&buf, ","))) {
9785-
if (strlencmp(cmd, "0") == 0)
9786-
state = 0;
9787-
else if (strlencmp(cmd, "1") == 0)
9788-
state = 1;
9780+
res = kstrtoint(cmd, 10, &state);
9781+
if (res < 0)
9782+
return res;
97899783
}
97909784

9791-
if (state == -1)
9785+
if (state >= 2 || state < 0)
97929786
return -EINVAL;
97939787

97949788
return lcdshadow_set(state);

0 commit comments

Comments
 (0)