Skip to content

Commit eabde0f

Browse files
Coproscefalodvhart
authored andcommitted
toshiba_acpi: Adapt kbd_bl_timeout_store to the new kbd type
With the introduction of the new keyboard backlight implementation, the *_timeout_store function is broken, as it only supports the first kbd_type. This patch adapts such function for the new kbd_type, as well as converts from using sscanf to kstrtoint. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
1 parent 893f3f6 commit eabde0f

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

‎drivers/platform/x86/toshiba_acpi.c‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev,
14531453
const char *buf, size_t count)
14541454
{
14551455
struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
1456-
int time = -1;
1456+
int time;
1457+
int ret;
14571458

1458-
if (sscanf(buf, "%i", &time) != 1 && (time < 0 || time > 60))
1459-
return -EINVAL;
1459+
ret = kstrtoint(buf, 0, &time);
1460+
if (ret)
1461+
return ret;
1462+
1463+
/* Check for supported values depending on kbd_type */
1464+
if (toshiba->kbd_type == 1) {
1465+
if (time < 0 || time > 60)
1466+
return -EINVAL;
1467+
} else if (toshiba->kbd_type == 2) {
1468+
if (time < 1 || time > 60)
1469+
return -EINVAL;
1470+
}
1471+
1472+
/* Set the Keyboard Backlight Timeout */
14601473

1461-
/* Set the Keyboard Backlight Timeout: 0-60 seconds */
1462-
if (time != -1 && toshiba->kbd_time != time) {
1474+
/* Only make a change if the actual timeout has changed */
1475+
if (toshiba->kbd_time != time) {
1476+
/* Shift the time to "base time" (0x3c0000 == 60 seconds) */
14631477
time = time << HCI_MISC_SHIFT;
1464-
time = (toshiba->kbd_mode == SCI_KBD_MODE_AUTO) ?
1465-
time + 1 : time + 2;
1466-
if (toshiba_kbd_illum_status_set(toshiba, time) < 0)
1467-
return -EIO;
1478+
/* OR the "base time" to the actual method format */
1479+
if (toshiba->kbd_type == 1)
1480+
time |= SCI_KBD_MODE_FNZ;
1481+
else if (toshiba->kbd_type == 2)
1482+
time |= SCI_KBD_MODE_AUTO;
1483+
1484+
ret = toshiba_kbd_illum_status_set(toshiba, time);
1485+
if (ret)
1486+
return ret;
1487+
14681488
toshiba->kbd_time = time >> HCI_MISC_SHIFT;
14691489
}
14701490

0 commit comments

Comments
 (0)