diff options
| -rw-r--r-- | drivers/pnp/core.c | 3 | ||||
| -rw-r--r-- | drivers/pnp/pnpacpi/core.c | 23 | ||||
| -rw-r--r-- | include/linux/pnp.h | 1 |
3 files changed, 27 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 |
diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 7c4193eb0072..1bc1338b817b 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h | |||
| @@ -414,6 +414,7 @@ struct pnp_protocol { | |||
| 414 | int (*disable) (struct pnp_dev *dev); | 414 | int (*disable) (struct pnp_dev *dev); |
| 415 | 415 | ||
| 416 | /* protocol specific suspend/resume */ | 416 | /* protocol specific suspend/resume */ |
| 417 | bool (*can_wakeup) (struct pnp_dev *dev); | ||
| 417 | int (*suspend) (struct pnp_dev * dev, pm_message_t state); | 418 | int (*suspend) (struct pnp_dev * dev, pm_message_t state); |
| 418 | int (*resume) (struct pnp_dev * dev); | 419 | int (*resume) (struct pnp_dev * dev); |
| 419 | 420 | ||
