aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2015-09-09 13:28:19 -0400
committerDarren Hart <dvhart@linux.intel.com>2015-10-03 11:40:44 -0400
commitb116fd009a73fc83f05241152ea9300304e6826c (patch)
tree0b327f8306f5f65e6f60f177f24160da075e9eec /drivers/platform
parent9ffecb10283508260936b96022d4ee43a7798b4c (diff)
toshiba_acpi: Unify hotkey enabling functions
Currently the driver has two functions enabling hotkeys support, but these two functions can be merged into one. This patch merges these two functions, moving some checks to the *enable_hotkeys function, simplifying code in the process. 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.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index f2372f400ddb..5510d3f593f4 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -198,6 +198,7 @@ struct toshiba_acpi_dev {
198 unsigned int panel_power_on_supported:1; 198 unsigned int panel_power_on_supported:1;
199 unsigned int usb_three_supported:1; 199 unsigned int usb_three_supported:1;
200 unsigned int sysfs_created:1; 200 unsigned int sysfs_created:1;
201 unsigned int special_functions;
201 202
202 bool kbd_led_registered; 203 bool kbd_led_registered;
203 bool illumination_led_registered; 204 bool illumination_led_registered;
@@ -2253,7 +2254,16 @@ static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)
2253 if (ACPI_FAILURE(status)) 2254 if (ACPI_FAILURE(status))
2254 return -ENODEV; 2255 return -ENODEV;
2255 2256
2256 result = hci_write(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE); 2257 /*
2258 * Enable the "Special Functions" mode only if they are
2259 * supported and if they are activated.
2260 */
2261 if (dev->kbd_function_keys_supported && dev->special_functions)
2262 result = hci_write(dev, HCI_HOTKEY_EVENT,
2263 HCI_HOTKEY_SPECIAL_FUNCTIONS);
2264 else
2265 result = hci_write(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
2266
2257 if (result == TOS_FAILURE) 2267 if (result == TOS_FAILURE)
2258 return -EIO; 2268 return -EIO;
2259 else if (result == TOS_NOT_SUPPORTED) 2269 else if (result == TOS_NOT_SUPPORTED)
@@ -2262,20 +2272,6 @@ static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)
2262 return 0; 2272 return 0;
2263} 2273}
2264 2274
2265static void toshiba_acpi_enable_special_functions(struct toshiba_acpi_dev *dev)
2266{
2267 u32 result;
2268
2269 /*
2270 * Re-activate the hotkeys, but this time, we are using the
2271 * "Special Functions" mode.
2272 */
2273 result = hci_write(dev, HCI_HOTKEY_EVENT,
2274 HCI_HOTKEY_SPECIAL_FUNCTIONS);
2275 if (result != TOS_SUCCESS)
2276 pr_err("Could not enable the Special Function mode\n");
2277}
2278
2279static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str, 2275static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
2280 struct serio *port) 2276 struct serio *port)
2281{ 2277{
@@ -2631,7 +2627,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
2631{ 2627{
2632 struct toshiba_acpi_dev *dev; 2628 struct toshiba_acpi_dev *dev;
2633 const char *hci_method; 2629 const char *hci_method;
2634 u32 special_functions;
2635 u32 dummy; 2630 u32 dummy;
2636 int ret = 0; 2631 int ret = 0;
2637 2632
@@ -2673,7 +2668,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
2673 * with the new keyboard layout, query for its presence to help 2668 * with the new keyboard layout, query for its presence to help
2674 * determine the keymap layout to use. 2669 * determine the keymap layout to use.
2675 */ 2670 */
2676 ret = toshiba_function_keys_get(dev, &special_functions); 2671 ret = toshiba_function_keys_get(dev, &dev->special_functions);
2677 dev->kbd_function_keys_supported = !ret; 2672 dev->kbd_function_keys_supported = !ret;
2678 2673
2679 if (toshiba_acpi_setup_keyboard(dev)) 2674 if (toshiba_acpi_setup_keyboard(dev))
@@ -2748,13 +2743,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
2748 2743
2749 print_supported_features(dev); 2744 print_supported_features(dev);
2750 2745
2751 /*
2752 * Enable the "Special Functions" mode only if they are
2753 * supported and if they are activated.
2754 */
2755 if (dev->kbd_function_keys_supported && special_functions)
2756 toshiba_acpi_enable_special_functions(dev);
2757
2758 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj, 2746 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj,
2759 &toshiba_attr_group); 2747 &toshiba_attr_group);
2760 if (ret) { 2748 if (ret) {