toshiba_acpi: Adapt /proc/acpi/toshiba/keys to TOS1900 devices
authorAzael Avalos <coproscefalo@gmail.com>
Thu, 23 Jul 2015 00:09:10 +0000 (18:09 -0600)
committerDarren Hart <dvhart@linux.intel.com>
Fri, 24 Jul 2015 21:12:36 +0000 (14:12 -0700)
Since the introduction of TOS1900 devices support to the driver, the
"keys" entry under the proc directory was broken, given that it only
handled TOS620X devices accordingly.

This patch adapts the code to show the hotkey values of TOS1900
devices too, and in case some programs are still using that interface,
hotkeys reporting should now work on these devices.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/toshiba_acpi.c

index 3ad7b1fa24ce5459900c4b6c966b631c4b6ddc46..c3a0c4d0c1dc4e49b60aa26d8d48a84164b4977f 100644 (file)
@@ -1499,32 +1499,10 @@ static const struct file_operations fan_proc_fops = {
 static int keys_proc_show(struct seq_file *m, void *v)
 {
        struct toshiba_acpi_dev *dev = m->private;
-       u32 hci_result;
-       u32 value;
-
-       if (!dev->key_event_valid && dev->system_event_supported) {
-               hci_result = hci_read(dev, HCI_SYSTEM_EVENT, &value);
-               if (hci_result == TOS_SUCCESS) {
-                       dev->key_event_valid = 1;
-                       dev->last_key_event = value;
-               } else if (hci_result == TOS_FIFO_EMPTY) {
-                       /* Better luck next time */
-               } else if (hci_result == TOS_NOT_SUPPORTED) {
-                       /*
-                        * This is a workaround for an unresolved issue on
-                        * some machines where system events sporadically
-                        * become disabled.
-                        */
-                       hci_result = hci_write(dev, HCI_SYSTEM_EVENT, 1);
-                       pr_notice("Re-enabled hotkeys\n");
-               } else {
-                       pr_err("Error reading hotkey status\n");
-                       return -EIO;
-               }
-       }
 
        seq_printf(m, "hotkey_ready:            %d\n", dev->key_event_valid);
        seq_printf(m, "hotkey:                  0x%04x\n", dev->last_key_event);
+
        return 0;
 }
 
@@ -2361,22 +2339,28 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
 
 static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev)
 {
-       u32 hci_result, value;
-       int retries = 3;
-       int scancode;
-
        if (dev->info_supported) {
-               scancode = toshiba_acpi_query_hotkey(dev);
-               if (scancode < 0)
+               int scancode = toshiba_acpi_query_hotkey(dev);
+
+               if (scancode < 0) {
                        pr_err("Failed to query hotkey event\n");
-               else if (scancode != 0)
+               } else if (scancode != 0) {
                        toshiba_acpi_report_hotkey(dev, scancode);
+                       dev->key_event_valid = 1;
+                       dev->last_key_event = scancode;
+               }
        } else if (dev->system_event_supported) {
+               u32 result;
+               u32 value;
+               int retries = 3;
+
                do {
-                       hci_result = hci_read(dev, HCI_SYSTEM_EVENT, &value);
-                       switch (hci_result) {
+                       result = hci_read(dev, HCI_SYSTEM_EVENT, &value);
+                       switch (result) {
                        case TOS_SUCCESS:
                                toshiba_acpi_report_hotkey(dev, (int)value);
+                               dev->key_event_valid = 1;
+                               dev->last_key_event = value;
                                break;
                        case TOS_NOT_SUPPORTED:
                                /*
@@ -2384,15 +2368,15 @@ static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev)
                                 * issue on some machines where system events
                                 * sporadically become disabled.
                                 */
-                               hci_result =
-                                       hci_write(dev, HCI_SYSTEM_EVENT, 1);
-                               pr_notice("Re-enabled hotkeys\n");
+                               result = hci_write(dev, HCI_SYSTEM_EVENT, 1);
+                               if (result == TOS_SUCCESS)
+                                       pr_notice("Re-enabled hotkeys\n");
                                /* Fall through */
                        default:
                                retries--;
                                break;
                        }
-               } while (retries && hci_result != TOS_FIFO_EMPTY);
+               } while (retries && result != TOS_FIFO_EMPTY);
        }
 }