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