root/drivers/platform/x86/hp-wireless.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. hp_wireless_input_setup
  2. hp_wireless_input_destroy
  3. hpwl_notify
  4. hpwl_add
  5. hpwl_remove

   1 // SPDX-License-Identifier: GPL-2.0-or-later
   2 /*
   3  *  Airplane mode button for HP & Xiaomi laptops
   4  *
   5  *  Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
   6  */
   7 
   8 #include <linux/kernel.h>
   9 #include <linux/module.h>
  10 #include <linux/init.h>
  11 #include <linux/input.h>
  12 #include <linux/platform_device.h>
  13 #include <linux/acpi.h>
  14 #include <acpi/acpi_bus.h>
  15 
  16 MODULE_LICENSE("GPL");
  17 MODULE_AUTHOR("Alex Hung");
  18 MODULE_ALIAS("acpi*:HPQ6001:*");
  19 MODULE_ALIAS("acpi*:WSTADEF:*");
  20 
  21 static struct input_dev *hpwl_input_dev;
  22 
  23 static const struct acpi_device_id hpwl_ids[] = {
  24         {"HPQ6001", 0},
  25         {"WSTADEF", 0},
  26         {"", 0},
  27 };
  28 
  29 static int hp_wireless_input_setup(void)
  30 {
  31         int err;
  32 
  33         hpwl_input_dev = input_allocate_device();
  34         if (!hpwl_input_dev)
  35                 return -ENOMEM;
  36 
  37         hpwl_input_dev->name = "HP Wireless hotkeys";
  38         hpwl_input_dev->phys = "hpq6001/input0";
  39         hpwl_input_dev->id.bustype = BUS_HOST;
  40         hpwl_input_dev->evbit[0] = BIT(EV_KEY);
  41         set_bit(KEY_RFKILL, hpwl_input_dev->keybit);
  42 
  43         err = input_register_device(hpwl_input_dev);
  44         if (err)
  45                 goto err_free_dev;
  46 
  47         return 0;
  48 
  49 err_free_dev:
  50         input_free_device(hpwl_input_dev);
  51         return err;
  52 }
  53 
  54 static void hp_wireless_input_destroy(void)
  55 {
  56         input_unregister_device(hpwl_input_dev);
  57 }
  58 
  59 static void hpwl_notify(struct acpi_device *acpi_dev, u32 event)
  60 {
  61         if (event != 0x80) {
  62                 pr_info("Received unknown event (0x%x)\n", event);
  63                 return;
  64         }
  65 
  66         input_report_key(hpwl_input_dev, KEY_RFKILL, 1);
  67         input_sync(hpwl_input_dev);
  68         input_report_key(hpwl_input_dev, KEY_RFKILL, 0);
  69         input_sync(hpwl_input_dev);
  70 }
  71 
  72 static int hpwl_add(struct acpi_device *device)
  73 {
  74         int err;
  75 
  76         err = hp_wireless_input_setup();
  77         if (err)
  78                 pr_err("Failed to setup hp wireless hotkeys\n");
  79 
  80         return err;
  81 }
  82 
  83 static int hpwl_remove(struct acpi_device *device)
  84 {
  85         hp_wireless_input_destroy();
  86         return 0;
  87 }
  88 
  89 static struct acpi_driver hpwl_driver = {
  90         .name   = "hp-wireless",
  91         .owner  = THIS_MODULE,
  92         .ids    = hpwl_ids,
  93         .ops    = {
  94                 .add    = hpwl_add,
  95                 .remove = hpwl_remove,
  96                 .notify = hpwl_notify,
  97         },
  98 };
  99 
 100 module_acpi_driver(hpwl_driver);

/* [<][>][^][v][top][bottom][index][help] */