toshiba_acpi: Adapt kbd_bl_timeout_store to the new kbd type
Subsystems (2)
Azael Avalos
maintainerPATCH v2 1/1 toshiba_acpi: Adapt kbd_bl_timeout_store to the new kbd type
With the introduccion of the new keyboard backlight implementation, the *_timeout_store function is broken, as it only supports the first kbd_type.
This patch adapt such function for the new kbd_type, as well as convert from using sscanf to kstrtoint.
---
Changes since v1:
- Check for timeout values depending on kbd_type
- Removed some misleading comments
Note: I'll be out of town until the next weekend, in case something else needs to be changed, I'll catch up whenever I'm back.
drivers/platform/x86/toshiba_acpi.c | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)
drivers/platform/x86/toshiba_acpi.c +29 -9
@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, const char *buf, size_t count) {struct toshiba_acpi_dev *toshiba =dev_get_drvdata (dev); -int time =-1 ; +int time; +int ret; -if (sscanf (buf,"%i" , &time) !=1 && (time <0 || time >60 )) -return -EINVAL ; + ret =kstrtoint (buf,0 , &time); +if (ret) +return ret; -/* Set the Keyboard Backlight Timeout: 0-60 seconds */ -if (time !=-1 && toshiba->kbd_time != time) { +/* 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 ; + } + +/* Set the Keyboard Backlight Timeout */ + +/* Only make a change if the actual timeout has changed */ +if (toshiba->kbd_time != time) { +/* Shift the time to "base time" (0x3c0000 == 60 seconds) */ time = time <<HCI_MISC_SHIFT ; - time = (toshiba->kbd_mode ==SCI_KBD_MODE_AUTO ) ? - time +1 : time +2 ; -if (toshiba_kbd_illum_status_set (toshiba, time) <0 ) -return -EIO ; +/* OR the "base time" to the actual method format */ +if (toshiba->kbd_type ==1 ) + time |=SCI_KBD_MODE_FNZ ; +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 ; }
Signature · 1 line
2.0.0
Hi Azael,
Quoted 1 line · Azael Avalos
With the introduccion of the new keyboard backlight
introduction
Quoted 4 lines
implementation, the
*_timeout_storefunction is broken, as it only supports the firstkbd_type.This patch adapt such function for the new
kbd_type,
adapts
Quoted 1 line
as well as convert from using sscanf to kstrtoint.
converts
Quoted 1 line
Functional changes look good to me, thank you.
I've made a couple minor formatting corrections in the interest of time. In the future, please check your patches with checkpatch.pl and consider using a spell checker in your $EDITOR for commit messages. Using git am to apply your own patches would also have caught the whitespace error.
Quoted 1 line
Signed-off-by Azael Avalos <[email protected]>
Queued to testing, I'll push to for-next tomorrow(ish), which should give us enough time to make 3.18 since Linus pushed out the merge window a bit.
Quoted 33 lines
---
Changes since v1:
- Check for timeout values depending onkbd_type
- Removed some misleading commentsNote: I'll be out of town until the next weekend, in case something else needs to be changed, I'll catch up whenever I'm back.
drivers/platform/x86/toshiba_acpi.c | 38 ++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)drivers/platform/x86/toshiba_acpi.c +6
-5@@ -1453,18 +1453,38 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, const char *buf, size_t count) {struct toshiba_acpi_dev *toshiba =dev_get_drvdata (dev); -int time =-1 ; +int time; +int ret; -if (sscanf (buf,"%i" , &time) !=1 && (time <0 || time >60 )) -return -EINVAL ; + ret =kstrtoint (buf,0 , &time); +if (ret) +return ret; -/* Set the Keyboard Backlight Timeout: 0-60 seconds */ -if (time !=-1 && toshiba->kbd_time != time) { +/* Check for supported values depending on kbd_type */
drivers/platform/x86/toshiba_acpi.c static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, · line 1473
Quoted 10 lines
drivers/platform/x86/toshiba_acpi.c +10
-0+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 ; + } + +/* Set the Keyboard Backlight Timeout */ +
^ Tab at beginning of otherwise empty line.
Thanks,
Darren
Quoted 25 lines
drivers/platform/x86/toshiba_acpi.c +13
-4+/* Only make a change if the actual timeout has changed */ +if (toshiba->kbd_time != time) { +/* Shift the time to "base time" (0x3c0000 == 60 seconds) */ time = time <<HCI_MISC_SHIFT ; - time = (toshiba->kbd_mode ==SCI_KBD_MODE_AUTO ) ? - time +1 : time +2 ; -if (toshiba_kbd_illum_status_set (toshiba, time) <0 ) -return -EIO ; +/* OR the "base time" to the actual method format */ +if (toshiba->kbd_type ==1 ) + time |=SCI_KBD_MODE_FNZ ; +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 ; }Signature · 1 line
2.0.0
Signature · 2 lines
Darren Hart Intel Open Source Technology Center