summaryrefslogtreecommitdiff
path: root/drivers/pnp/pnpacpi/core.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-10-16 23:31:06 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 08:43:04 -0700
commit36e02b62084efa72f1f04c95e13295a456f394c2 (patch)
tree1fc2528c4508d83c34b25a46fee7266e2ce9f183 /drivers/pnp/pnpacpi/core.c
parente8e961574b5b417d3fc277cbf436081fce4fc2e1 (diff)
downloadlwn-36e02b62084efa72f1f04c95e13295a456f394c2.tar.gz
lwn-36e02b62084efa72f1f04c95e13295a456f394c2.zip
PNP: make pnpacpi_suspend handle errors
pnpacpi_suspend() doesn't check the result returned by acpi_pm_device_sleep_state() before passing it to acpi_bus_set_power(), which may not be desirable.  Make it select the target power state of the device using its second argument if acpi_pm_device_sleep_state() fails. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Looks-ok-to: Pavel Machek <pavel@ucw.cz> Cc: Adam Belay <ambx1@neo.rr.com> Cc: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp/pnpacpi/core.c')
-rw-r--r--drivers/pnp/pnpacpi/core.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index a5a372222d69..e6a2a9fc7f0a 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -130,11 +130,16 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
#ifdef CONFIG_ACPI_SLEEP
static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
{
- return acpi_bus_set_power((acpi_handle) dev->data,
- acpi_pm_device_sleep_state(&dev->dev,
- device_may_wakeup
- (&dev->dev),
- NULL));
+ int power_state;
+
+ power_state = acpi_pm_device_sleep_state(&dev->dev,
+ device_may_wakeup(&dev->dev),
+ NULL);
+ if (power_state < 0)
+ power_state = (state.event == PM_EVENT_ON) ?
+ ACPI_STATE_D0 : ACPI_STATE_D3;
+
+ return acpi_bus_set_power((acpi_handle) dev->data, power_state);
}
static int pnpacpi_resume(struct pnp_dev *dev)