Commit 1f28f290 authored by Azael Avalos's avatar Azael Avalos Committed by Darren Hart

toshiba_acpi: Move hotkey enabling code to its own function

The hotkey enabling code is being used by *_setup_keyboard and also by
*_resume.

This patch creates a new function called toshiba_acpi_enable_hotkeys to
be used by these two functions to avoid duplicating code.
Signed-off-by: default avatarAzael Avalos <coproscefalo@gmail.com>
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent 8cb8e63b
...@@ -1574,6 +1574,28 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, ...@@ -1574,6 +1574,28 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
return exists ? attr->mode : 0; return exists ? attr->mode : 0;
} }
/*
* Hotkeys
*/
static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)
{
acpi_status status;
u32 result;
status = acpi_evaluate_object(dev->acpi_dev->handle,
"ENAB", NULL, NULL);
if (ACPI_FAILURE(status))
return -ENODEV;
result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
if (result == TOS_FAILURE)
return -EIO;
else if (result == TOS_NOT_SUPPORTED)
return -ENODEV;
return 0;
}
static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str, static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
struct serio *port) struct serio *port)
{ {
...@@ -1638,7 +1660,6 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev, ...@@ -1638,7 +1660,6 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
{ {
acpi_status status;
acpi_handle ec_handle; acpi_handle ec_handle;
int error; int error;
u32 hci_result; u32 hci_result;
...@@ -1665,7 +1686,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) ...@@ -1665,7 +1686,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
* supported, so if it's present set up an i8042 key filter * supported, so if it's present set up an i8042 key filter
* for this purpose. * for this purpose.
*/ */
status = AE_ERROR;
ec_handle = ec_get_handle(); ec_handle = ec_get_handle();
if (ec_handle && acpi_has_method(ec_handle, "NTFY")) { if (ec_handle && acpi_has_method(ec_handle, "NTFY")) {
INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work);
...@@ -1696,10 +1716,9 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) ...@@ -1696,10 +1716,9 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
goto err_remove_filter; goto err_remove_filter;
} }
status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, NULL); error = toshiba_acpi_enable_hotkeys(dev);
if (ACPI_FAILURE(status)) { if (error) {
pr_info("Unable to enable hotkeys\n"); pr_info("Unable to enable hotkeys\n");
error = -ENODEV;
goto err_remove_filter; goto err_remove_filter;
} }
...@@ -1709,7 +1728,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) ...@@ -1709,7 +1728,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
goto err_remove_filter; goto err_remove_filter;
} }
hci_result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
return 0; return 0;
err_remove_filter: err_remove_filter:
...@@ -2007,16 +2025,12 @@ static int toshiba_acpi_suspend(struct device *device) ...@@ -2007,16 +2025,12 @@ static int toshiba_acpi_suspend(struct device *device)
static int toshiba_acpi_resume(struct device *device) static int toshiba_acpi_resume(struct device *device)
{ {
struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device)); struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device));
u32 result; int error;
acpi_status status;
if (dev->hotkey_dev) { if (dev->hotkey_dev) {
status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", error = toshiba_acpi_enable_hotkeys(dev);
NULL, NULL); if (error)
if (ACPI_FAILURE(status))
pr_info("Unable to re-enable hotkeys\n"); pr_info("Unable to re-enable hotkeys\n");
result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE);
} }
return 0; return 0;
......
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