diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-06-29 16:49:24 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2010-07-18 19:58:48 -0400 |
commit | b14e033e17d0ea0ba12668d0d2f371cd31586994 (patch) | |
tree | f7b5df8e67c091363a967a4d1fb8a1209d61cf95 /drivers/pnp/pnpacpi | |
parent | 2430d12c94ff2bafcfe4f65edf7ee5f300d2d9c6 (diff) |
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>
Diffstat (limited to 'drivers/pnp/pnpacpi')
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index f7ff628b7d94..dc4e32e031e9 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -122,17 +122,37 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | #ifdef CONFIG_ACPI_SLEEP | 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 | static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) | 133 | static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state) |
126 | { | 134 | { |
127 | struct acpi_device *acpi_dev = dev->data; | 135 | struct acpi_device *acpi_dev = dev->data; |
128 | acpi_handle handle = acpi_dev->handle; | 136 | acpi_handle handle = acpi_dev->handle; |
129 | int power_state; | 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 | power_state = acpi_pm_device_sleep_state(&dev->dev, NULL); | 146 | power_state = acpi_pm_device_sleep_state(&dev->dev, NULL); |
132 | if (power_state < 0) | 147 | if (power_state < 0) |
133 | power_state = (state.event == PM_EVENT_ON) ? | 148 | power_state = (state.event == PM_EVENT_ON) ? |
134 | ACPI_STATE_D0 : ACPI_STATE_D3; | 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 | return acpi_bus_set_power(handle, power_state); | 156 | return acpi_bus_set_power(handle, power_state); |
137 | } | 157 | } |
138 | 158 | ||
@@ -141,6 +161,8 @@ static int pnpacpi_resume(struct pnp_dev *dev) | |||
141 | struct acpi_device *acpi_dev = dev->data; | 161 | struct acpi_device *acpi_dev = dev->data; |
142 | acpi_handle handle = acpi_dev->handle; | 162 | acpi_handle handle = acpi_dev->handle; |
143 | 163 | ||
164 | if (device_may_wakeup(&dev->dev)) | ||
165 | acpi_pm_device_sleep_wake(&dev->dev, false); | ||
144 | return acpi_bus_set_power(handle, ACPI_STATE_D0); | 166 | return acpi_bus_set_power(handle, ACPI_STATE_D0); |
145 | } | 167 | } |
146 | #endif | 168 | #endif |
@@ -151,6 +173,7 @@ struct pnp_protocol pnpacpi_protocol = { | |||
151 | .set = pnpacpi_set_resources, | 173 | .set = pnpacpi_set_resources, |
152 | .disable = pnpacpi_disable_resources, | 174 | .disable = pnpacpi_disable_resources, |
153 | #ifdef CONFIG_ACPI_SLEEP | 175 | #ifdef CONFIG_ACPI_SLEEP |
176 | .can_wakeup = pnpacpi_can_wakeup, | ||
154 | .suspend = pnpacpi_suspend, | 177 | .suspend = pnpacpi_suspend, |
155 | .resume = pnpacpi_resume, | 178 | .resume = pnpacpi_resume, |
156 | #endif | 179 | #endif |