Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PNPACPI: Add support for remote wakeup

This patch (as1354) adds remote-wakeup support to the pnpacpi driver.
The new can_wakeup method also allows other PNP protocol drivers
(pnpbios or iaspnp) to add wakeup support, but I don't know enough
about how they work to actually do it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

authored by

Alan Stern and committed by
Rafael J. Wysocki
b14e033e 2430d12c

+27
+3
drivers/pnp/core.c
··· 164 164 list_add_tail(&dev->global_list, &pnp_global); 165 165 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 166 166 spin_unlock(&pnp_lock); 167 + if (dev->protocol->can_wakeup) 168 + device_set_wakeup_capable(&dev->dev, 169 + dev->protocol->can_wakeup(dev)); 167 170 return device_register(&dev->dev); 168 171 } 169 172
+23
drivers/pnp/pnpacpi/core.c
··· 122 122 } 123 123 124 124 #ifdef CONFIG_ACPI_SLEEP 125 + static bool pnpacpi_can_wakeup(struct pnp_dev *dev) 126 + { 127 + struct acpi_device *acpi_dev = dev->data; 128 + acpi_handle handle = acpi_dev->handle; 129 + 130 + return acpi_bus_can_wakeup(handle); 131 + } 132 + 125 133 static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) 126 134 { 127 135 struct acpi_device *acpi_dev = dev->data; 128 136 acpi_handle handle = acpi_dev->handle; 129 137 int power_state; 130 138 139 + if (device_can_wakeup(&dev->dev)) { 140 + int rc = acpi_pm_device_sleep_wake(&dev->dev, 141 + device_may_wakeup(&dev->dev)); 142 + 143 + if (rc) 144 + return rc; 145 + } 131 146 power_state = acpi_pm_device_sleep_state(&dev->dev, NULL); 132 147 if (power_state < 0) 133 148 power_state = (state.event == PM_EVENT_ON) ? 134 149 ACPI_STATE_D0 : ACPI_STATE_D3; 135 150 151 + /* acpi_bus_set_power() often fails (keyboard port can't be 152 + * powered-down?), and in any case, our return value is ignored 153 + * by pnp_bus_suspend(). Hence we don't revert the wakeup 154 + * setting if the set_power fails. 155 + */ 136 156 return acpi_bus_set_power(handle, power_state); 137 157 } 138 158 ··· 161 141 struct acpi_device *acpi_dev = dev->data; 162 142 acpi_handle handle = acpi_dev->handle; 163 143 144 + if (device_may_wakeup(&dev->dev)) 145 + acpi_pm_device_sleep_wake(&dev->dev, false); 164 146 return acpi_bus_set_power(handle, ACPI_STATE_D0); 165 147 } 166 148 #endif ··· 173 151 .set = pnpacpi_set_resources, 174 152 .disable = pnpacpi_disable_resources, 175 153 #ifdef CONFIG_ACPI_SLEEP 154 + .can_wakeup = pnpacpi_can_wakeup, 176 155 .suspend = pnpacpi_suspend, 177 156 .resume = pnpacpi_resume, 178 157 #endif
+1
include/linux/pnp.h
··· 414 414 int (*disable) (struct pnp_dev *dev); 415 415 416 416 /* protocol specific suspend/resume */ 417 + bool (*can_wakeup) (struct pnp_dev *dev); 417 418 int (*suspend) (struct pnp_dev * dev, pm_message_t state); 418 419 int (*resume) (struct pnp_dev * dev); 419 420