blob: 420e61b8eaaed72de60c279dfa87b7b07716a45e [file] [log] [blame]
Josh Tripletta1b93e82020-02-11 15:38:06 -08001// 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
Josh Tripletta1b93e82020-02-11 15:38:06 -08007MODULE_AUTHOR("Josh Triplett");
8MODULE_DESCRIPTION("ACPI Tiny Power Button Driver");
9MODULE_LICENSE("GPL");
10
11static int power_signal __read_mostly = CONFIG_ACPI_TINY_POWER_BUTTON_SIGNAL;
12module_param(power_signal, int, 0644);
13MODULE_PARM_DESC(power_signal, "Power button sends this signal to init");
14
15static 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};
20MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);
21
22static int acpi_noop_add_remove(struct acpi_device *device)
23{
24 return 0;
25}
26
27static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
28{
29 kill_cad_pid(power_signal, 1);
30}
31
32static struct acpi_driver acpi_tiny_power_button_driver = {
33 .name = "tiny-power-button",
34 .class = "tiny-power-button",
35 .ids = tiny_power_button_device_ids,
36 .ops = {
37 .add = acpi_noop_add_remove,
38 .remove = acpi_noop_add_remove,
39 .notify = acpi_tiny_power_button_notify,
40 },
41};
42
43module_driver(acpi_tiny_power_button_driver,
44 acpi_bus_register_driver,
45 acpi_bus_unregister_driver);