xref: /linux/drivers/acpi/tiny-power-button.c (revision c894ec016c9d0418dd832202225a8c64f450d71e)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #include <linux/module.h>
3 #include <linux/sched/signal.h>
4 #include <linux/acpi.h>
5 #include <acpi/button.h>
6 
7 MODULE_AUTHOR("Josh Triplett");
8 MODULE_DESCRIPTION("ACPI Tiny Power Button Driver");
9 MODULE_LICENSE("GPL");
10 
11 static int power_signal __read_mostly = CONFIG_ACPI_TINY_POWER_BUTTON_SIGNAL;
12 module_param(power_signal, int, 0644);
13 MODULE_PARM_DESC(power_signal, "Power button sends this signal to init");
14 
15 static const struct acpi_device_id tiny_power_button_device_ids[] = {
16 	{ ACPI_BUTTON_HID_POWER, 0 },
17 	{ ACPI_BUTTON_HID_POWERF, 0 },
18 	{ "", 0 },
19 };
20 MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);
21 
22 static int acpi_noop_add(struct acpi_device *device)
23 {
24 	return 0;
25 }
26 
27 static void acpi_noop_remove(struct acpi_device *device)
28 {
29 }
30 
31 static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
32 {
33 	kill_cad_pid(power_signal, 1);
34 }
35 
36 static struct acpi_driver acpi_tiny_power_button_driver = {
37 	.name = "tiny-power-button",
38 	.class = "tiny-power-button",
39 	.ids = tiny_power_button_device_ids,
40 	.ops = {
41 		.add = acpi_noop_add,
42 		.remove = acpi_noop_remove,
43 		.notify = acpi_tiny_power_button_notify,
44 	},
45 };
46 
47 module_acpi_driver(acpi_tiny_power_button_driver);
48