26 #define QUICKSTART_VERSION "1.04"
28 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 #include <linux/kernel.h>
31 #include <linux/module.h>
33 #include <linux/types.h>
36 #include <linux/input.h>
42 #define QUICKSTART_ACPI_DEVICE_NAME "quickstart"
43 #define QUICKSTART_ACPI_CLASS "quickstart"
44 #define QUICKSTART_ACPI_HID "PNP0C32"
46 #define QUICKSTART_PF_DRIVER_NAME "quickstart"
47 #define QUICKSTART_PF_DEVICE_NAME "quickstart"
54 #define QUICKSTART_EVENT_WAKE 0x02
55 #define QUICKSTART_EVENT_RUNTIME 0x80
71 static struct input_dev *quickstart_input;
97 static ssize_t quickstart_pressed_button_show(
struct device *dev,
102 (pressed ? pressed->
name :
"none"));
106 static ssize_t quickstart_pressed_button_store(
struct device *dev,
108 const char *buf,
size_t count)
144 static void quickstart_buttons_free(
void)
149 quickstart_button_del(b);
162 pressed = quickstart->
button;
165 input_report_key(quickstart_input, quickstart->
button->id, 1);
166 input_sync(quickstart_input);
167 input_report_key(quickstart_input, quickstart->
button->id, 0);
168 input_sync(quickstart_input);
171 pr_err(
"Unexpected ACPI event notify (%u)\n", event);
189 pr_err(
"%s GHID method failed\n", quickstart->
button->name);
212 pr_err(
"%s GHID method returned buffer of unexpected length %lu\n",
214 (
unsigned long)buffer.
length);
226 char *
bid = acpi_device_bid(quickstart->
device);
234 quickstart->
button = quickstart_buttons_add();
235 if (!quickstart->
button) {
246 static int quickstart_acpi_add(
struct acpi_device *
device)
255 quickstart = kzalloc(
sizeof(*quickstart),
GFP_KERNEL);
263 device->driver_data = quickstart;
266 ret = quickstart_acpi_config(quickstart);
271 quickstart_acpi_notify,
274 pr_err(
"Notify handler install error\n");
276 goto fail_installnotify;
279 ret = quickstart_acpi_ghid(quickstart);
287 quickstart_acpi_notify);
290 quickstart_button_del(quickstart->
button);
299 static int quickstart_acpi_remove(
struct acpi_device *device,
int type)
307 quickstart = acpi_driver_data(device);
312 quickstart_acpi_notify);
314 pr_err(
"Error removing notify handler\n");
322 static DEVICE_ATTR(pressed_button, 0666, quickstart_pressed_button_show,
323 quickstart_pressed_button_store);
338 static struct acpi_driver quickstart_acpi_driver = {
339 .name =
"quickstart",
341 .ids = quickstart_device_ids,
343 .add = quickstart_acpi_add,
344 .remove = quickstart_acpi_remove,
349 static void quickstart_exit(
void)
351 input_unregister_device(quickstart_input);
362 quickstart_buttons_free();
365 static int __init quickstart_init_input(
void)
370 quickstart_input = input_allocate_device();
372 if (!quickstart_input)
375 quickstart_input->name =
"Quickstart ACPI Buttons";
376 quickstart_input->id.bustype =
BUS_HOST;
380 set_bit(b->
id, quickstart_input->keybit);
383 ret = input_register_device(quickstart_input);
385 input_free_device(quickstart_input);
392 static int __init quickstart_init(
void)
420 goto fail_pfdev_alloc;
436 ret = quickstart_init_input();