diff options
| author | Azael Avalos <coproscefalo@gmail.com> | 2014-12-04 22:22:45 -0500 |
|---|---|---|
| committer | Darren Hart <dvhart@linux.intel.com> | 2014-12-03 13:10:17 -0500 |
| commit | 1f28f2908e40f56794f2fa6bd1fa0e7beaba1a5d (patch) | |
| tree | f828343c0db7ffaa5b397a8219fb6ec963a131f6 | |
| parent | 8cb8e63b5698954877071b7a0d259b7c4c9040dc (diff) | |
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: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
| -rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index f0011a5e9672..0327cf79baca 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
| @@ -1574,6 +1574,28 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, | |||
| 1574 | return exists ? attr->mode : 0; | 1574 | return exists ? attr->mode : 0; |
| 1575 | } | 1575 | } |
| 1576 | 1576 | ||
| 1577 | /* | ||
| 1578 | * Hotkeys | ||
| 1579 | */ | ||
| 1580 | static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev) | ||
| 1581 | { | ||
| 1582 | acpi_status status; | ||
| 1583 | u32 result; | ||
| 1584 | |||
| 1585 | status = acpi_evaluate_object(dev->acpi_dev->handle, | ||
| 1586 | "ENAB", NULL, NULL); | ||
| 1587 | if (ACPI_FAILURE(status)) | ||
| 1588 | return -ENODEV; | ||
| 1589 | |||
| 1590 | result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE); | ||
| 1591 | if (result == TOS_FAILURE) | ||
| 1592 | return -EIO; | ||
| 1593 | else if (result == TOS_NOT_SUPPORTED) | ||
| 1594 | return -ENODEV; | ||
| 1595 | |||
| 1596 | return 0; | ||
| 1597 | } | ||
| 1598 | |||
| 1577 | static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str, | 1599 | static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str, |
| 1578 | struct serio *port) | 1600 | struct serio *port) |
| 1579 | { | 1601 | { |
| @@ -1638,7 +1660,6 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev, | |||
| 1638 | 1660 | ||
| 1639 | static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | 1661 | static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) |
| 1640 | { | 1662 | { |
| 1641 | acpi_status status; | ||
| 1642 | acpi_handle ec_handle; | 1663 | acpi_handle ec_handle; |
| 1643 | int error; | 1664 | int error; |
| 1644 | u32 hci_result; | 1665 | u32 hci_result; |
| @@ -1665,7 +1686,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | |||
| 1665 | * supported, so if it's present set up an i8042 key filter | 1686 | * supported, so if it's present set up an i8042 key filter |
| 1666 | * for this purpose. | 1687 | * for this purpose. |
| 1667 | */ | 1688 | */ |
| 1668 | status = AE_ERROR; | ||
| 1669 | ec_handle = ec_get_handle(); | 1689 | ec_handle = ec_get_handle(); |
| 1670 | if (ec_handle && acpi_has_method(ec_handle, "NTFY")) { | 1690 | if (ec_handle && acpi_has_method(ec_handle, "NTFY")) { |
| 1671 | INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); | 1691 | 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 | goto err_remove_filter; | 1716 | goto err_remove_filter; |
| 1697 | } | 1717 | } |
| 1698 | 1718 | ||
| 1699 | status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, NULL); | 1719 | error = toshiba_acpi_enable_hotkeys(dev); |
| 1700 | if (ACPI_FAILURE(status)) { | 1720 | if (error) { |
| 1701 | pr_info("Unable to enable hotkeys\n"); | 1721 | pr_info("Unable to enable hotkeys\n"); |
| 1702 | error = -ENODEV; | ||
| 1703 | goto err_remove_filter; | 1722 | goto err_remove_filter; |
| 1704 | } | 1723 | } |
| 1705 | 1724 | ||
| @@ -1709,7 +1728,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | |||
| 1709 | goto err_remove_filter; | 1728 | goto err_remove_filter; |
| 1710 | } | 1729 | } |
| 1711 | 1730 | ||
| 1712 | hci_result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE); | ||
| 1713 | return 0; | 1731 | return 0; |
| 1714 | 1732 | ||
| 1715 | err_remove_filter: | 1733 | err_remove_filter: |
| @@ -2007,16 +2025,12 @@ static int toshiba_acpi_suspend(struct device *device) | |||
| 2007 | static int toshiba_acpi_resume(struct device *device) | 2025 | static int toshiba_acpi_resume(struct device *device) |
| 2008 | { | 2026 | { |
| 2009 | struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device)); | 2027 | struct toshiba_acpi_dev *dev = acpi_driver_data(to_acpi_device(device)); |
| 2010 | u32 result; | 2028 | int error; |
| 2011 | acpi_status status; | ||
| 2012 | 2029 | ||
| 2013 | if (dev->hotkey_dev) { | 2030 | if (dev->hotkey_dev) { |
| 2014 | status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", | 2031 | error = toshiba_acpi_enable_hotkeys(dev); |
| 2015 | NULL, NULL); | 2032 | if (error) |
| 2016 | if (ACPI_FAILURE(status)) | ||
| 2017 | pr_info("Unable to re-enable hotkeys\n"); | 2033 | pr_info("Unable to re-enable hotkeys\n"); |
| 2018 | |||
| 2019 | result = hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE); | ||
| 2020 | } | 2034 | } |
| 2021 | 2035 | ||
| 2022 | return 0; | 2036 | return 0; |
