summaryrefslogtreecommitdiff
path: root/drivers/pnp/driver.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus-list@drzeus.cx>2005-11-29 09:09:32 +0100
committerJaroslav Kysela <perex@suse.cz>2006-01-03 12:31:30 +0100
commit68094e3251a664ee1389fcf179497237cbf78331 (patch)
tree1f38ff587622bab4b1063c19447832f6cbff8a6f /drivers/pnp/driver.c
parent4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9 (diff)
downloadlinux-3.10-68094e3251a664ee1389fcf179497237cbf78331.tar.gz
linux-3.10-68094e3251a664ee1389fcf179497237cbf78331.tar.bz2
linux-3.10-68094e3251a664ee1389fcf179497237cbf78331.zip
[ALSA] [PATCH] alsa: Improved PnP suspend support
Also use the PnP functions to start/stop the devices during the suspend so that drivers will not have to duplicate this code. Cc: Adam Belay <ambx1@neo.rr.com> Cc: Jaroslav Kysela <perex@suse.cz> Cc: Takashi Iwai <tiwai@suse.de> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'drivers/pnp/driver.c')
-rw-r--r--drivers/pnp/driver.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index ea2cb9a8b21..15fb758a9e5 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -150,19 +150,46 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state)
{
struct pnp_dev * pnp_dev = to_pnp_dev(dev);
struct pnp_driver * pnp_drv = pnp_dev->driver;
+ int error;
+
+ if (!pnp_drv)
+ return 0;
+
+ if (pnp_drv->suspend) {
+ error = pnp_drv->suspend(pnp_dev, state);
+ if (error)
+ return error;
+ }
+
+ if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) &&
+ pnp_can_disable(pnp_dev)) {
+ error = pnp_stop_dev(pnp_dev);
+ if (error)
+ return error;
+ }
- if (pnp_drv && pnp_drv->suspend)
- return pnp_drv->suspend(pnp_dev, state);
return 0;
}
-static void pnp_bus_resume(struct device *dev)
+static int pnp_bus_resume(struct device *dev)
{
struct pnp_dev * pnp_dev = to_pnp_dev(dev);
struct pnp_driver * pnp_drv = pnp_dev->driver;
+ int error;
+
+ if (!pnp_drv)
+ return 0;
+
+ if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) {
+ error = pnp_start_dev(pnp_dev);
+ if (error)
+ return error;
+ }
- if (pnp_drv && pnp_drv->resume)
- pnp_drv->resume(pnp_dev);
+ if (pnp_drv->resume)
+ return pnp_drv->resume(pnp_dev);
+
+ return 0;
}
struct bus_type pnp_bus_type = {