Skip to content

Commit e91f8c5

Browse files
committed
ACPI: button: Call device_init_wakeup() earlier during probe
Calling device_init_wakeup() after installing a notify handler in which wakeup events are signaled may cause a wakeup event to be missed if the device is probed right before a system suspend. To avoid this, move the device_init_wakeup() call in acpi_button_probe() before the notify handler installation and add a corresponding cleanup to the error path. Also carry out wakeup cleanup for the button in acpi_button_remove() because after that point the notify handler will not run for it and wakeup events coming from it will not be signaled. Fixes: 0d51157 ("ACPI: button: Eliminate the driver notify callback") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/12854922.O9o76ZdvQC@rafael.j.wysocki
1 parent d84e173 commit e91f8c5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/acpi/button.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ static int acpi_button_probe(struct platform_device *pdev)
625625
goto err_remove_fs;
626626
}
627627

628+
device_init_wakeup(&pdev->dev, true);
629+
628630
switch (device->device_type) {
629631
case ACPI_BUS_TYPE_POWER_BUTTON:
630632
status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
@@ -655,11 +657,11 @@ static int acpi_button_probe(struct platform_device *pdev)
655657
lid_device = device;
656658
}
657659

658-
device_init_wakeup(&pdev->dev, true);
659660
pr_info("%s [%s]\n", name, acpi_device_bid(device));
660661
return 0;
661662

662663
err_input_unregister:
664+
device_init_wakeup(&pdev->dev, false);
663665
input_unregister_device(input);
664666
err_remove_fs:
665667
acpi_button_remove_fs(button);
@@ -691,6 +693,8 @@ static void acpi_button_remove(struct platform_device *pdev)
691693
}
692694
acpi_os_wait_events_complete();
693695

696+
device_init_wakeup(&pdev->dev, false);
697+
694698
acpi_button_remove_fs(button);
695699
input_unregister_device(button->input);
696700
kfree(button);

0 commit comments

Comments
 (0)