diff options
author | Azael Avalos <coproscefalo@gmail.com> | 2014-10-04 14:02:21 -0400 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2014-10-06 20:44:42 -0400 |
commit | eabde0fa967052df12bdd8e8a72f0af799e1e704 (patch) | |
tree | dcb00008ea57a5c5b434487df66db0b1a15d3439 /drivers/platform | |
parent | 893f3f62dc7ade3700cdceed23ce38bb92e3966b (diff) |
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>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 5d509eac8ce6..ef3a1904e92f 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, | |||
1453 | const char *buf, size_t count) | 1453 | const char *buf, size_t count) |
1454 | { | 1454 | { |
1455 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1455 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1456 | int time = -1; | 1456 | int time; |
1457 | int ret; | ||
1457 | 1458 | ||
1458 | if (sscanf(buf, "%i", &time) != 1 && (time < 0 || time > 60)) | 1459 | ret = kstrtoint(buf, 0, &time); |
1459 | return -EINVAL; | 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 */ | ||
1460 | 1473 | ||
1461 | /* Set the Keyboard Backlight Timeout: 0-60 seconds */ | 1474 | /* Only make a change if the actual timeout has changed */ |
1462 | if (time != -1 && toshiba->kbd_time != time) { | 1475 | if (toshiba->kbd_time != time) { |
1476 | /* Shift the time to "base time" (0x3c0000 == 60 seconds) */ | ||
1463 | time = time << HCI_MISC_SHIFT; | 1477 | time = time << HCI_MISC_SHIFT; |
1464 | time = (toshiba->kbd_mode == SCI_KBD_MODE_AUTO) ? | 1478 | /* OR the "base time" to the actual method format */ |
1465 | time + 1 : time + 2; | 1479 | if (toshiba->kbd_type == 1) |
1466 | if (toshiba_kbd_illum_status_set(toshiba, time) < 0) | 1480 | time |= SCI_KBD_MODE_FNZ; |
1467 | return -EIO; | 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 | |||
1468 | toshiba->kbd_time = time >> HCI_MISC_SHIFT; | 1488 | toshiba->kbd_time = time >> HCI_MISC_SHIFT; |
1469 | } | 1489 | } |
1470 | 1490 | ||