12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/module.h>
15 #include <linux/input.h>
16 #include <linux/slab.h>
18 #include <linux/tty.h>
23 static void system_power_event(
unsigned int keycode)
28 pr_info(
"Requesting system suspend...\n");
35 static void apmpower_event(
struct input_handle *
handle,
unsigned int type,
44 system_power_event(code);
52 static int apmpower_connect(
struct input_handler *handler,
53 struct input_dev *
dev,
56 struct input_handle *
handle;
59 handle = kzalloc(
sizeof(
struct input_handle),
GFP_KERNEL);
64 handle->handler = handler;
65 handle->name =
"apm-power";
67 error = input_register_handle(handle);
69 pr_err(
"Failed to register input power handler, error %d\n",
75 error = input_open_device(handle);
77 pr_err(
"Failed to open input power device, error %d\n", error);
78 input_unregister_handle(handle);
86 static void apmpower_disconnect(
struct input_handle *handle)
88 input_close_device(handle);
89 input_unregister_handle(handle);
103 static struct input_handler apmpower_handler = {
104 .event = apmpower_event,
105 .connect = apmpower_connect,
106 .disconnect = apmpower_disconnect,
108 .id_table = apmpower_ids,
111 static int __init apmpower_init(
void)
113 return input_register_handler(&apmpower_handler);
116 static void __exit apmpower_exit(
void)
118 input_unregister_handler(&apmpower_handler);