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 | |
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')
-rw-r--r-- | drivers/pnp/core.c | 3 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 5dba90995d9e..88b3cde52596 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -164,6 +164,9 @@ int __pnp_add_device(struct pnp_dev *dev) | |||
164 | list_add_tail(&dev->global_list, &pnp_global); | 164 | list_add_tail(&dev->global_list, &pnp_global); |
165 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); | 165 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); |
166 | spin_unlock(&pnp_lock); | 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 | return device_register(&dev->dev); | 170 | return device_register(&dev->dev); |
168 | } | 171 | } |
169 | 172 | ||
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 |