14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/kernel.h>
17 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/input.h>
24 #define MODULE_NAME "xo15-ebook"
26 #define XO15_EBOOK_CLASS MODULE_NAME
27 #define XO15_EBOOK_TYPE_UNKNOWN 0x00
28 #define XO15_EBOOK_NOTIFY_STATUS 0x80
30 #define XO15_EBOOK_SUBCLASS "ebook"
31 #define XO15_EBOOK_HID "XO15EBK"
32 #define XO15_EBOOK_DEVICE_NAME "EBook Switch"
50 static int ebook_send_state(
struct acpi_device *
device)
53 unsigned long long state;
62 input_sync(button->
input);
66 static void ebook_switch_notify(
struct acpi_device *
device,
u32 event)
71 ebook_send_state(device);
75 "Unsupported event [0x%x]\n", event));
80 #ifdef CONFIG_PM_SLEEP
81 static int ebook_switch_resume(
struct device *
dev)
83 return ebook_send_state(to_acpi_device(dev));
89 static int ebook_switch_add(
struct acpi_device *device)
92 struct input_dev *
input;
101 device->driver_data =
button;
103 button->
input = input = input_allocate_device();
106 goto err_free_button;
109 name = acpi_device_name(device);
110 class = acpi_device_class(device);
113 pr_err(
"Unsupported hid [%s]\n", hid);
124 input->phys = button->
phys;
126 input->dev.parent = &device->dev;
131 error = input_register_device(input);
135 ebook_send_state(device);
137 if (device->wakeup.flags.valid) {
140 device->wakeup.gpe_number);
147 input_free_device(input);
153 static int ebook_switch_remove(
struct acpi_device *device,
int type)
157 input_unregister_device(button->
input);
162 static struct acpi_driver xo15_ebook_driver = {
165 .ids = ebook_device_ids,
167 .add = ebook_switch_add,
168 .remove = ebook_switch_remove,
169 .notify = ebook_switch_notify,
171 .drv.pm = &ebook_switch_pm,