Commit eabde0fa authored by Azael Avalos's avatar Azael Avalos Committed by Darren Hart

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: default avatarAzael Avalos <coproscefalo@gmail.com>
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent 893f3f62
...@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, ...@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
int time = -1; int time;
int ret;
ret = kstrtoint(buf, 0, &time);
if (ret)
return ret;
if (sscanf(buf, "%i", &time) != 1 && (time < 0 || time > 60)) /* Check for supported values depending on kbd_type */
if (toshiba->kbd_type == 1) {
if (time < 0 || time > 60)
return -EINVAL;
} else if (toshiba->kbd_type == 2) {
if (time < 1 || time > 60)
return -EINVAL; return -EINVAL;
}
/* Set the Keyboard Backlight Timeout */
/* Set the Keyboard Backlight Timeout: 0-60 seconds */ /* Only make a change if the actual timeout has changed */
if (time != -1 && toshiba->kbd_time != time) { if (toshiba->kbd_time != time) {
/* Shift the time to "base time" (0x3c0000 == 60 seconds) */
time = time << HCI_MISC_SHIFT; time = time << HCI_MISC_SHIFT;
time = (toshiba->kbd_mode == SCI_KBD_MODE_AUTO) ? /* OR the "base time" to the actual method format */
time + 1 : time + 2; if (toshiba->kbd_type == 1)
if (toshiba_kbd_illum_status_set(toshiba, time) < 0) time |= SCI_KBD_MODE_FNZ;
return -EIO; else if (toshiba->kbd_type == 2)
time |= SCI_KBD_MODE_AUTO;
ret = toshiba_kbd_illum_status_set(toshiba, time);
if (ret)
return ret;
toshiba->kbd_time = time >> HCI_MISC_SHIFT; toshiba->kbd_time = time >> HCI_MISC_SHIFT;
} }
......
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