ACPI: button: Cleanups after recent changes
Rafael J. Wysocki
maintainercover ACPI: button: Cleanups after recent changes
Hi All,
The following two patches clean up the ACPI button a bit after the changes made to it recently. They are not expected to alter functionality.
They apply on top of
Thanks!
Rafael J. Wysocki
maintainerPATCH 1/2 ACPI: button: Tweak system wakeup handling
From: Rafael J. Wysocki <[email protected]>
Modify struct acpi_button to hold a struct device pointer instead of a struct platform_device one to avoid unnecessary pointer dereferences and use that pointer consistently for system wakeup initialization, handling and cleanup.
No intentional functional impact.
--- drivers/acpi/button.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/acpi/button.c +7 -7
@@ -170,7 +170,7 @@ static struct platform_driver acpi_buttostruct acpi_button {struct acpi_device *adev; -struct platform_device *pdev; +struct device *dev;/* physical button device */ unsigned int type;struct input_dev *input;char phys[32 ];/* for input device */
@@ -398,7 +398,7 @@ static int acpi_lid_update_state(structreturn state;if (state && signal_wakeup) -acpi_pm_wakeup_event (&button->pdev->dev); +acpi_pm_wakeup_event (button->dev);return acpi_lid_notify_state (button, state); }
@@ -455,7 +455,7 @@ static void acpi_button_notify(acpi_handreturn ; } -acpi_pm_wakeup_event (&button->pdev->dev); +acpi_pm_wakeup_event (button->dev);if (button->suspended || event ==ACPI_BUTTON_NOTIFY_WAKE )return ;
@@ -550,7 +550,7 @@ static int acpi_button_probe(struct platplatform_set_drvdata (pdev, button); - button->pdev = pdev; + button->dev = &pdev->dev; button->adev = device; button->input = input =input_allocate_device ();if (!input) {
@@ -625,7 +625,7 @@ static int acpi_button_probe(struct plat goto err_remove_fs; } -device_init_wakeup (&pdev->dev, true); +device_init_wakeup (button->dev, true);switch (device->device_type) {case ACPI_BUS_TYPE_POWER_BUTTON :
@@ -661,7 +661,7 @@ static int acpi_button_probe(struct platreturn 0 ; err_input_unregister: -device_init_wakeup (&pdev->dev, false); +device_init_wakeup (button->dev, false);input_unregister_device (input); err_remove_fs:acpi_button_remove_fs (button);
@@ -693,7 +693,7 @@ static void acpi_button_remove(struct pl }acpi_os_wait_events_complete (); -device_init_wakeup (&pdev->dev, false); +device_init_wakeup (button->dev, false);acpi_button_remove_fs (button);input_unregister_device (button->input);
Rafael J. Wysocki
maintainerPATCH 2/2 ACPI: button: Tweak acpi_button_remove()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify acpi_button_remove() to get the ACPI device object pointer from button->adev instead of retrieving it with the help of the ACPI_COMPANION() macro to reduce overhead slightly.
While at it, rename the struct acpi_device pointer variable in acpi_button_remove() to adev.
No intentional functional impact.
--- drivers/acpi/button.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/button.c +3 -3
@@ -672,10 +672,10 @@ err_free_button:static void acpi_button_remove (struct platform_device *pdev) { -struct acpi_device *device =ACPI_COMPANION (&pdev->dev);struct acpi_button *button =platform_get_drvdata (pdev); +struct acpi_device *adev = button->adev; -switch (device->device_type) { +switch (adev->device_type) {case ACPI_BUS_TYPE_POWER_BUTTON :acpi_remove_fixed_event_handler (ACPI_EVENT_POWER_BUTTON , acpi_button_event);
@@ -685,7 +685,7 @@ static void acpi_button_remove(struct pl acpi_button_event);break ;default : -acpi_remove_notify_handler (device->handle,ACPI_DEVICE_NOTIFY , +acpi_remove_notify_handler (adev->handle,ACPI_DEVICE_NOTIFY , button->type ==ACPI_BUTTON_TYPE_LID ? acpi_lid_notify : acpi_button_notify);