Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202541
b: refs/heads/master
c: b14e033
h: refs/heads/master
i:
  202539: 1a1312e
v: v3
  • Loading branch information
Alan Stern authored and Rafael J. Wysocki committed Jul 18, 2010
1 parent 680644c commit 5b87db4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2430d12c94ff2bafcfe4f65edf7ee5f300d2d9c6
refs/heads/master: b14e033e17d0ea0ba12668d0d2f371cd31586994
3 changes: 3 additions & 0 deletions trunk/drivers/pnp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ int __pnp_add_device(struct pnp_dev *dev)
list_add_tail(&dev->global_list, &pnp_global);
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
spin_unlock(&pnp_lock);
if (dev->protocol->can_wakeup)
device_set_wakeup_capable(&dev->dev,
dev->protocol->can_wakeup(dev));
return device_register(&dev->dev);
}

Expand Down
23 changes: 23 additions & 0 deletions trunk/drivers/pnp/pnpacpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,37 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
}

#ifdef CONFIG_ACPI_SLEEP
static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
{
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;

return acpi_bus_can_wakeup(handle);
}

static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
{
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;
int power_state;

if (device_can_wakeup(&dev->dev)) {
int rc = acpi_pm_device_sleep_wake(&dev->dev,
device_may_wakeup(&dev->dev));

if (rc)
return rc;
}
power_state = acpi_pm_device_sleep_state(&dev->dev, NULL);
if (power_state < 0)
power_state = (state.event == PM_EVENT_ON) ?
ACPI_STATE_D0 : ACPI_STATE_D3;

/* acpi_bus_set_power() often fails (keyboard port can't be
* powered-down?), and in any case, our return value is ignored
* by pnp_bus_suspend(). Hence we don't revert the wakeup
* setting if the set_power fails.
*/
return acpi_bus_set_power(handle, power_state);
}

Expand All @@ -141,6 +161,8 @@ static int pnpacpi_resume(struct pnp_dev *dev)
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;

if (device_may_wakeup(&dev->dev))
acpi_pm_device_sleep_wake(&dev->dev, false);
return acpi_bus_set_power(handle, ACPI_STATE_D0);
}
#endif
Expand All @@ -151,6 +173,7 @@ struct pnp_protocol pnpacpi_protocol = {
.set = pnpacpi_set_resources,
.disable = pnpacpi_disable_resources,
#ifdef CONFIG_ACPI_SLEEP
.can_wakeup = pnpacpi_can_wakeup,
.suspend = pnpacpi_suspend,
.resume = pnpacpi_resume,
#endif
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/pnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ struct pnp_protocol {
int (*disable) (struct pnp_dev *dev);

/* protocol specific suspend/resume */
bool (*can_wakeup) (struct pnp_dev *dev);
int (*suspend) (struct pnp_dev * dev, pm_message_t state);
int (*resume) (struct pnp_dev * dev);

Expand Down

0 comments on commit 5b87db4

Please sign in to comment.