1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * button.c - ACPI Button Driver
4 *
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 */
8
9 #define pr_fmt(fmt) "ACPI: button: " fmt
10
11 #include <linux/compiler.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/types.h>
16 #include <linux/proc_fs.h>
17 #include <linux/seq_file.h>
18 #include <linux/input.h>
19 #include <linux/slab.h>
20 #include <linux/acpi.h>
21 #include <linux/dmi.h>
22 #include <acpi/button.h>
23
24 #define ACPI_BUTTON_CLASS "button"
25 #define ACPI_BUTTON_FILE_STATE "state"
26 #define ACPI_BUTTON_TYPE_UNKNOWN 0x00
27 #define ACPI_BUTTON_NOTIFY_STATUS 0x80
28
29 #define ACPI_BUTTON_SUBCLASS_POWER "power"
30 #define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button"
31 #define ACPI_BUTTON_TYPE_POWER 0x01
32
33 #define ACPI_BUTTON_SUBCLASS_SLEEP "sleep"
34 #define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button"
35 #define ACPI_BUTTON_TYPE_SLEEP 0x03
36
37 #define ACPI_BUTTON_SUBCLASS_LID "lid"
38 #define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch"
39 #define ACPI_BUTTON_TYPE_LID 0x05
40
41 enum {
42 ACPI_BUTTON_LID_INIT_IGNORE,
43 ACPI_BUTTON_LID_INIT_OPEN,
44 ACPI_BUTTON_LID_INIT_METHOD,
45 ACPI_BUTTON_LID_INIT_DISABLED,
46 };
47
48 static const char * const lid_init_state_str[] = {
49 [ACPI_BUTTON_LID_INIT_IGNORE] = "ignore",
50 [ACPI_BUTTON_LID_INIT_OPEN] = "open",
51 [ACPI_BUTTON_LID_INIT_METHOD] = "method",
52 [ACPI_BUTTON_LID_INIT_DISABLED] = "disabled",
53 };
54
55 MODULE_AUTHOR("Paul Diefenbaugh");
56 MODULE_DESCRIPTION("ACPI Button Driver");
57 MODULE_LICENSE("GPL");
58
59 static const struct acpi_device_id button_device_ids[] = {
60 {ACPI_BUTTON_HID_LID, 0},
61 {ACPI_BUTTON_HID_SLEEP, 0},
62 {ACPI_BUTTON_HID_SLEEPF, 0},
63 {ACPI_BUTTON_HID_POWER, 0},
64 {ACPI_BUTTON_HID_POWERF, 0},
65 {"", 0},
66 };
67 MODULE_DEVICE_TABLE(acpi, button_device_ids);
68
69 /* Please keep this list sorted alphabetically by vendor and model */
70 static const struct dmi_system_id dmi_lid_quirks[] = {
71 {
72 /* GP-electronic T701, _LID method points to a floating GPIO */
73 .matches = {
74 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
75 DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
76 DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
77 },
78 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
79 },
80 {
81 /* Nextbook Ares 8A tablet, _LID device always reports lid closed */
82 .matches = {
83 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
84 DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
85 DMI_MATCH(DMI_BIOS_VERSION, "M882"),
86 },
87 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
88 },
89 {
90 /*
91 * Lenovo Yoga 9 14ITL5, initial notification of the LID device
92 * never happens.
93 */
94 .matches = {
95 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
96 DMI_MATCH(DMI_PRODUCT_NAME, "82BG"),
97 },
98 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
99 },
100 {
101 /*
102 * Medion Akoya E2215T, notification of the LID device only
103 * happens on close, not on open and _LID always returns closed.
104 */
105 .matches = {
106 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
107 DMI_MATCH(DMI_PRODUCT_NAME, "E2215T"),
108 },
109 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
110 },
111 {
112 /*
113 * Medion Akoya E2228T, notification of the LID device only
114 * happens on close, not on open and _LID always returns closed.
115 */
116 .matches = {
117 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
118 DMI_MATCH(DMI_PRODUCT_NAME, "E2228T"),
119 },
120 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
121 },
122 {
123 /*
124 * Razer Blade Stealth 13 late 2019, notification of the LID device
125 * only happens on close, not on open and _LID always returns closed.
126 */
127 .matches = {
128 DMI_MATCH(DMI_SYS_VENDOR, "Razer"),
129 DMI_MATCH(DMI_PRODUCT_NAME, "Razer Blade Stealth 13 Late 2019"),
130 },
131 .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN,
132 },
133 {}
134 };
135
136 static int acpi_button_add(struct acpi_device *device);
137 static int acpi_button_remove(struct acpi_device *device);
138 static void acpi_button_notify(struct acpi_device *device, u32 event);
139
140 #ifdef CONFIG_PM_SLEEP
141 static int acpi_button_suspend(struct device *dev);
142 static int acpi_button_resume(struct device *dev);
143 #else
144 #define acpi_button_suspend NULL
145 #define acpi_button_resume NULL
146 #endif
147 static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
148
149 static struct acpi_driver acpi_button_driver = {
150 .name = "button",
151 .class = ACPI_BUTTON_CLASS,
152 .ids = button_device_ids,
153 .ops = {
154 .add = acpi_button_add,
155 .remove = acpi_button_remove,
156 .notify = acpi_button_notify,
157 },
158 .drv.pm = &acpi_button_pm,
159 };
160
161 struct acpi_button {
162 unsigned int type;
163 struct input_dev *input;
164 char phys[32]; /* for input device */
165 unsigned long pushed;
166 int last_state;
167 ktime_t last_time;
168 bool suspended;
169 bool lid_state_initialized;
170 };
171
172 static struct acpi_device *lid_device;
173 static long lid_init_state = -1;
174
175 static unsigned long lid_report_interval __read_mostly = 500;
176 module_param(lid_report_interval, ulong, 0644);
177 MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
178
179 /* FS Interface (/proc) */
180 static struct proc_dir_entry *acpi_button_dir;
181 static struct proc_dir_entry *acpi_lid_dir;
182
acpi_lid_evaluate_state(struct acpi_device * device)183 static int acpi_lid_evaluate_state(struct acpi_device *device)
184 {
185 unsigned long long lid_state;
186 acpi_status status;
187
188 status = acpi_evaluate_integer(device->handle, "_LID", NULL, &lid_state);
189 if (ACPI_FAILURE(status))
190 return -ENODEV;
191
192 return lid_state ? 1 : 0;
193 }
194
acpi_lid_notify_state(struct acpi_device * device,int state)195 static int acpi_lid_notify_state(struct acpi_device *device, int state)
196 {
197 struct acpi_button *button = acpi_driver_data(device);
198 ktime_t next_report;
199 bool do_update;
200
201 /*
202 * In lid_init_state=ignore mode, if user opens/closes lid
203 * frequently with "open" missing, and "last_time" is also updated
204 * frequently, "close" cannot be delivered to the userspace.
205 * So "last_time" is only updated after a timeout or an actual
206 * switch.
207 */
208 if (lid_init_state != ACPI_BUTTON_LID_INIT_IGNORE ||
209 button->last_state != !!state)
210 do_update = true;
211 else
212 do_update = false;
213
214 next_report = ktime_add(button->last_time,
215 ms_to_ktime(lid_report_interval));
216 if (button->last_state == !!state &&
217 ktime_after(ktime_get(), next_report)) {
218 /* Complain the buggy firmware */
219 pr_warn_once("The lid device is not compliant to SW_LID.\n");
220
221 /*
222 * Send the unreliable complement switch event:
223 *
224 * On most platforms, the lid device is reliable. However
225 * there are exceptions:
226 * 1. Platforms returning initial lid state as "close" by
227 * default after booting/resuming:
228 * https://bugzilla.kernel.org/show_bug.cgi?id=89211
229 * https://bugzilla.kernel.org/show_bug.cgi?id=106151
230 * 2. Platforms never reporting "open" events:
231 * https://bugzilla.kernel.org/show_bug.cgi?id=106941
232 * On these buggy platforms, the usage model of the ACPI
233 * lid device actually is:
234 * 1. The initial returning value of _LID may not be
235 * reliable.
236 * 2. The open event may not be reliable.
237 * 3. The close event is reliable.
238 *
239 * But SW_LID is typed as input switch event, the input
240 * layer checks if the event is redundant. Hence if the
241 * state is not switched, the userspace cannot see this
242 * platform triggered reliable event. By inserting a
243 * complement switch event, it then is guaranteed that the
244 * platform triggered reliable one can always be seen by
245 * the userspace.
246 */
247 if (lid_init_state == ACPI_BUTTON_LID_INIT_IGNORE) {
248 do_update = true;
249 /*
250 * Do generate complement switch event for "close"
251 * as "close" is reliable and wrong "open" won't
252 * trigger unexpected behaviors.
253 * Do not generate complement switch event for
254 * "open" as "open" is not reliable and wrong
255 * "close" will trigger unexpected behaviors.
256 */
257 if (!state) {
258 input_report_switch(button->input,
259 SW_LID, state);
260 input_sync(button->input);
261 }
262 }
263 }
264 /* Send the platform triggered reliable event */
265 if (do_update) {
266 acpi_handle_debug(device->handle, "ACPI LID %s\n",
267 state ? "open" : "closed");
268 input_report_switch(button->input, SW_LID, !state);
269 input_sync(button->input);
270 button->last_state = !!state;
271 button->last_time = ktime_get();
272 }
273
274 return 0;
275 }
276
acpi_button_state_seq_show(struct seq_file * seq,void * offset)277 static int __maybe_unused acpi_button_state_seq_show(struct seq_file *seq,
278 void *offset)
279 {
280 struct acpi_device *device = seq->private;
281 int state;
282
283 state = acpi_lid_evaluate_state(device);
284 seq_printf(seq, "state: %s\n",
285 state < 0 ? "unsupported" : (state ? "open" : "closed"));
286 return 0;
287 }
288
acpi_button_add_fs(struct acpi_device * device)289 static int acpi_button_add_fs(struct acpi_device *device)
290 {
291 struct acpi_button *button = acpi_driver_data(device);
292 struct proc_dir_entry *entry = NULL;
293 int ret = 0;
294
295 /* procfs I/F for ACPI lid device only */
296 if (button->type != ACPI_BUTTON_TYPE_LID)
297 return 0;
298
299 if (acpi_button_dir || acpi_lid_dir) {
300 pr_info("More than one Lid device found!\n");
301 return -EEXIST;
302 }
303
304 /* create /proc/acpi/button */
305 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
306 if (!acpi_button_dir)
307 return -ENODEV;
308
309 /* create /proc/acpi/button/lid */
310 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
311 if (!acpi_lid_dir) {
312 ret = -ENODEV;
313 goto remove_button_dir;
314 }
315
316 /* create /proc/acpi/button/lid/LID/ */
317 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_lid_dir);
318 if (!acpi_device_dir(device)) {
319 ret = -ENODEV;
320 goto remove_lid_dir;
321 }
322
323 /* create /proc/acpi/button/lid/LID/state */
324 entry = proc_create_single_data(ACPI_BUTTON_FILE_STATE, S_IRUGO,
325 acpi_device_dir(device), acpi_button_state_seq_show,
326 device);
327 if (!entry) {
328 ret = -ENODEV;
329 goto remove_dev_dir;
330 }
331
332 done:
333 return ret;
334
335 remove_dev_dir:
336 remove_proc_entry(acpi_device_bid(device),
337 acpi_lid_dir);
338 acpi_device_dir(device) = NULL;
339 remove_lid_dir:
340 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
341 acpi_lid_dir = NULL;
342 remove_button_dir:
343 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
344 acpi_button_dir = NULL;
345 goto done;
346 }
347
acpi_button_remove_fs(struct acpi_device * device)348 static int acpi_button_remove_fs(struct acpi_device *device)
349 {
350 struct acpi_button *button = acpi_driver_data(device);
351
352 if (button->type != ACPI_BUTTON_TYPE_LID)
353 return 0;
354
355 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
356 acpi_device_dir(device));
357 remove_proc_entry(acpi_device_bid(device),
358 acpi_lid_dir);
359 acpi_device_dir(device) = NULL;
360 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
361 acpi_lid_dir = NULL;
362 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
363 acpi_button_dir = NULL;
364
365 return 0;
366 }
367
368 /* Driver Interface */
acpi_lid_open(void)369 int acpi_lid_open(void)
370 {
371 if (!lid_device)
372 return -ENODEV;
373
374 return acpi_lid_evaluate_state(lid_device);
375 }
376 EXPORT_SYMBOL(acpi_lid_open);
377
acpi_lid_update_state(struct acpi_device * device,bool signal_wakeup)378 static int acpi_lid_update_state(struct acpi_device *device,
379 bool signal_wakeup)
380 {
381 int state;
382
383 state = acpi_lid_evaluate_state(device);
384 if (state < 0)
385 return state;
386
387 if (state && signal_wakeup)
388 acpi_pm_wakeup_event(&device->dev);
389
390 return acpi_lid_notify_state(device, state);
391 }
392
acpi_lid_initialize_state(struct acpi_device * device)393 static void acpi_lid_initialize_state(struct acpi_device *device)
394 {
395 struct acpi_button *button = acpi_driver_data(device);
396
397 switch (lid_init_state) {
398 case ACPI_BUTTON_LID_INIT_OPEN:
399 (void)acpi_lid_notify_state(device, 1);
400 break;
401 case ACPI_BUTTON_LID_INIT_METHOD:
402 (void)acpi_lid_update_state(device, false);
403 break;
404 case ACPI_BUTTON_LID_INIT_IGNORE:
405 default:
406 break;
407 }
408
409 button->lid_state_initialized = true;
410 }
411
acpi_button_notify(struct acpi_device * device,u32 event)412 static void acpi_button_notify(struct acpi_device *device, u32 event)
413 {
414 struct acpi_button *button = acpi_driver_data(device);
415 struct input_dev *input;
416
417 switch (event) {
418 case ACPI_FIXED_HARDWARE_EVENT:
419 event = ACPI_BUTTON_NOTIFY_STATUS;
420 fallthrough;
421 case ACPI_BUTTON_NOTIFY_STATUS:
422 input = button->input;
423 if (button->type == ACPI_BUTTON_TYPE_LID) {
424 if (button->lid_state_initialized)
425 acpi_lid_update_state(device, true);
426 } else {
427 int keycode;
428
429 acpi_pm_wakeup_event(&device->dev);
430 if (button->suspended)
431 break;
432
433 keycode = test_bit(KEY_SLEEP, input->keybit) ?
434 KEY_SLEEP : KEY_POWER;
435 input_report_key(input, keycode, 1);
436 input_sync(input);
437 input_report_key(input, keycode, 0);
438 input_sync(input);
439
440 acpi_bus_generate_netlink_event(
441 device->pnp.device_class,
442 dev_name(&device->dev),
443 event, ++button->pushed);
444 }
445 break;
446 default:
447 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n",
448 event);
449 break;
450 }
451 }
452
453 #ifdef CONFIG_PM_SLEEP
acpi_button_suspend(struct device * dev)454 static int acpi_button_suspend(struct device *dev)
455 {
456 struct acpi_device *device = to_acpi_device(dev);
457 struct acpi_button *button = acpi_driver_data(device);
458
459 button->suspended = true;
460 return 0;
461 }
462
acpi_button_resume(struct device * dev)463 static int acpi_button_resume(struct device *dev)
464 {
465 struct acpi_device *device = to_acpi_device(dev);
466 struct acpi_button *button = acpi_driver_data(device);
467
468 button->suspended = false;
469 if (button->type == ACPI_BUTTON_TYPE_LID) {
470 button->last_state = !!acpi_lid_evaluate_state(device);
471 button->last_time = ktime_get();
472 acpi_lid_initialize_state(device);
473 }
474 return 0;
475 }
476 #endif
477
acpi_lid_input_open(struct input_dev * input)478 static int acpi_lid_input_open(struct input_dev *input)
479 {
480 struct acpi_device *device = input_get_drvdata(input);
481 struct acpi_button *button = acpi_driver_data(device);
482
483 button->last_state = !!acpi_lid_evaluate_state(device);
484 button->last_time = ktime_get();
485 acpi_lid_initialize_state(device);
486
487 return 0;
488 }
489
acpi_button_add(struct acpi_device * device)490 static int acpi_button_add(struct acpi_device *device)
491 {
492 struct acpi_button *button;
493 struct input_dev *input;
494 const char *hid = acpi_device_hid(device);
495 char *name, *class;
496 int error;
497
498 if (!strcmp(hid, ACPI_BUTTON_HID_LID) &&
499 lid_init_state == ACPI_BUTTON_LID_INIT_DISABLED)
500 return -ENODEV;
501
502 button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
503 if (!button)
504 return -ENOMEM;
505
506 device->driver_data = button;
507
508 button->input = input = input_allocate_device();
509 if (!input) {
510 error = -ENOMEM;
511 goto err_free_button;
512 }
513
514 name = acpi_device_name(device);
515 class = acpi_device_class(device);
516
517 if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
518 !strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
519 button->type = ACPI_BUTTON_TYPE_POWER;
520 strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
521 sprintf(class, "%s/%s",
522 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
523 } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
524 !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
525 button->type = ACPI_BUTTON_TYPE_SLEEP;
526 strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
527 sprintf(class, "%s/%s",
528 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
529 } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
530 button->type = ACPI_BUTTON_TYPE_LID;
531 strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
532 sprintf(class, "%s/%s",
533 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
534 input->open = acpi_lid_input_open;
535 } else {
536 pr_info("Unsupported hid [%s]\n", hid);
537 error = -ENODEV;
538 goto err_free_input;
539 }
540
541 error = acpi_button_add_fs(device);
542 if (error)
543 goto err_free_input;
544
545 snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
546
547 input->name = name;
548 input->phys = button->phys;
549 input->id.bustype = BUS_HOST;
550 input->id.product = button->type;
551 input->dev.parent = &device->dev;
552
553 switch (button->type) {
554 case ACPI_BUTTON_TYPE_POWER:
555 input_set_capability(input, EV_KEY, KEY_POWER);
556 break;
557
558 case ACPI_BUTTON_TYPE_SLEEP:
559 input_set_capability(input, EV_KEY, KEY_SLEEP);
560 break;
561
562 case ACPI_BUTTON_TYPE_LID:
563 input_set_capability(input, EV_SW, SW_LID);
564 break;
565 }
566
567 input_set_drvdata(input, device);
568 error = input_register_device(input);
569 if (error)
570 goto err_remove_fs;
571 if (button->type == ACPI_BUTTON_TYPE_LID) {
572 /*
573 * This assumes there's only one lid device, or if there are
574 * more we only care about the last one...
575 */
576 lid_device = device;
577 }
578
579 device_init_wakeup(&device->dev, true);
580 pr_info("%s [%s]\n", name, acpi_device_bid(device));
581 return 0;
582
583 err_remove_fs:
584 acpi_button_remove_fs(device);
585 err_free_input:
586 input_free_device(input);
587 err_free_button:
588 kfree(button);
589 return error;
590 }
591
acpi_button_remove(struct acpi_device * device)592 static int acpi_button_remove(struct acpi_device *device)
593 {
594 struct acpi_button *button = acpi_driver_data(device);
595
596 acpi_button_remove_fs(device);
597 input_unregister_device(button->input);
598 kfree(button);
599 return 0;
600 }
601
param_set_lid_init_state(const char * val,const struct kernel_param * kp)602 static int param_set_lid_init_state(const char *val,
603 const struct kernel_param *kp)
604 {
605 int i;
606
607 i = sysfs_match_string(lid_init_state_str, val);
608 if (i < 0)
609 return i;
610
611 lid_init_state = i;
612 pr_info("Initial lid state set to '%s'\n", lid_init_state_str[i]);
613 return 0;
614 }
615
param_get_lid_init_state(char * buf,const struct kernel_param * kp)616 static int param_get_lid_init_state(char *buf, const struct kernel_param *kp)
617 {
618 int i, c = 0;
619
620 for (i = 0; i < ARRAY_SIZE(lid_init_state_str); i++)
621 if (i == lid_init_state)
622 c += sprintf(buf + c, "[%s] ", lid_init_state_str[i]);
623 else
624 c += sprintf(buf + c, "%s ", lid_init_state_str[i]);
625
626 buf[c - 1] = '\n'; /* Replace the final space with a newline */
627
628 return c;
629 }
630
631 module_param_call(lid_init_state,
632 param_set_lid_init_state, param_get_lid_init_state,
633 NULL, 0644);
634 MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state");
635
acpi_button_register_driver(struct acpi_driver * driver)636 static int acpi_button_register_driver(struct acpi_driver *driver)
637 {
638 const struct dmi_system_id *dmi_id;
639
640 if (lid_init_state == -1) {
641 dmi_id = dmi_first_match(dmi_lid_quirks);
642 if (dmi_id)
643 lid_init_state = (long)dmi_id->driver_data;
644 else
645 lid_init_state = ACPI_BUTTON_LID_INIT_METHOD;
646 }
647
648 /*
649 * Modules such as nouveau.ko and i915.ko have a link time dependency
650 * on acpi_lid_open(), and would therefore not be loadable on ACPI
651 * capable kernels booted in non-ACPI mode if the return value of
652 * acpi_bus_register_driver() is returned from here with ACPI disabled
653 * when this driver is built as a module.
654 */
655 if (acpi_disabled)
656 return 0;
657
658 return acpi_bus_register_driver(driver);
659 }
660
acpi_button_unregister_driver(struct acpi_driver * driver)661 static void acpi_button_unregister_driver(struct acpi_driver *driver)
662 {
663 if (!acpi_disabled)
664 acpi_bus_unregister_driver(driver);
665 }
666
667 module_driver(acpi_button_driver, acpi_button_register_driver,
668 acpi_button_unregister_driver);
669