Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / drivers / platform / x86 / asus-wireless.c
blob9ec721e26532531e69d5a1decb5da4926b402282
1 /*
2 * Asus Wireless Radio Control Driver
4 * Copyright (C) 2015-2016 Endless Mobile, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/acpi.h>
16 #include <linux/input.h>
17 #include <linux/pci_ids.h>
19 struct asus_wireless_data {
20 struct input_dev *idev;
23 static void asus_wireless_notify(struct acpi_device *adev, u32 event)
25 struct asus_wireless_data *data = acpi_driver_data(adev);
27 dev_dbg(&adev->dev, "event=%#x\n", event);
28 if (event != 0x88) {
29 dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event);
30 return;
32 input_report_key(data->idev, KEY_RFKILL, 1);
33 input_report_key(data->idev, KEY_RFKILL, 0);
34 input_sync(data->idev);
37 static int asus_wireless_add(struct acpi_device *adev)
39 struct asus_wireless_data *data;
41 data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
42 if (!data)
43 return -ENOMEM;
44 adev->driver_data = data;
46 data->idev = devm_input_allocate_device(&adev->dev);
47 if (!data->idev)
48 return -ENOMEM;
49 data->idev->name = "Asus Wireless Radio Control";
50 data->idev->phys = "asus-wireless/input0";
51 data->idev->id.bustype = BUS_HOST;
52 data->idev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
53 set_bit(EV_KEY, data->idev->evbit);
54 set_bit(KEY_RFKILL, data->idev->keybit);
55 return input_register_device(data->idev);
58 static int asus_wireless_remove(struct acpi_device *adev)
60 return 0;
63 static const struct acpi_device_id device_ids[] = {
64 {"ATK4001", 0},
65 {"ATK4002", 0},
66 {"", 0},
68 MODULE_DEVICE_TABLE(acpi, device_ids);
70 static struct acpi_driver asus_wireless_driver = {
71 .name = "Asus Wireless Radio Control Driver",
72 .class = "hotkey",
73 .ids = device_ids,
74 .ops = {
75 .add = asus_wireless_add,
76 .remove = asus_wireless_remove,
77 .notify = asus_wireless_notify,
80 module_acpi_driver(asus_wireless_driver);
82 MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
83 MODULE_AUTHOR("João Paulo Rechi Vita <jprvita@gmail.com>");
84 MODULE_LICENSE("GPL");