0001
0002 #include <linux/module.h>
0003 #include <linux/sched/signal.h>
0004 #include <linux/acpi.h>
0005 #include <acpi/button.h>
0006
0007 MODULE_AUTHOR("Josh Triplett");
0008 MODULE_DESCRIPTION("ACPI Tiny Power Button Driver");
0009 MODULE_LICENSE("GPL");
0010
0011 static int power_signal __read_mostly = CONFIG_ACPI_TINY_POWER_BUTTON_SIGNAL;
0012 module_param(power_signal, int, 0644);
0013 MODULE_PARM_DESC(power_signal, "Power button sends this signal to init");
0014
0015 static const struct acpi_device_id tiny_power_button_device_ids[] = {
0016 { ACPI_BUTTON_HID_POWER, 0 },
0017 { ACPI_BUTTON_HID_POWERF, 0 },
0018 { "", 0 },
0019 };
0020 MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);
0021
0022 static int acpi_noop_add_remove(struct acpi_device *device)
0023 {
0024 return 0;
0025 }
0026
0027 static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
0028 {
0029 kill_cad_pid(power_signal, 1);
0030 }
0031
0032 static struct acpi_driver acpi_tiny_power_button_driver = {
0033 .name = "tiny-power-button",
0034 .class = "tiny-power-button",
0035 .ids = tiny_power_button_device_ids,
0036 .ops = {
0037 .add = acpi_noop_add_remove,
0038 .remove = acpi_noop_add_remove,
0039 .notify = acpi_tiny_power_button_notify,
0040 },
0041 };
0042
0043 module_acpi_driver(acpi_tiny_power_button_driver);