diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-29 09:09:32 +0100 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 12:31:19 +0100 |
commit | 4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9 (patch) | |
tree | 4ad45704bcf9e43085164d8d7ca6f07d6f1884dd /drivers | |
parent | 0ba656d0b2319b76fbebd01c1c9ba5ca8eb33fb1 (diff) | |
download | kernel_samsung_crespo-4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9.zip kernel_samsung_crespo-4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9.tar.gz kernel_samsung_crespo-4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9.tar.bz2 |
[ALSA] PATCH] Add PM support to PnP drivers
Add suspend/resume callback to pnp_driver and pnp_card_driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/card.c | 25 | ||||
-rw-r--r-- | drivers/pnp/driver.c | 20 |
2 files changed, 45 insertions, 0 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index bd7c966..0ecbe4e 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -69,6 +69,7 @@ static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv) return 0; clink->card = card; clink->driver = drv; + clink->pm_state = PMSG_ON; if (drv->probe) { if (drv->probe(clink, id)>=0) return 1; @@ -333,6 +334,28 @@ void pnp_release_card_device(struct pnp_dev * dev) up_write(&dev->dev.bus->subsys.rwsem); } +/* + * suspend/resume callbacks + */ +static int card_suspend(struct pnp_dev *dev, pm_message_t state) +{ + struct pnp_card_link *link = dev->card_link; + if (link->pm_state.event == state.event) + return 0; + link->pm_state = state; + return link->driver->suspend(link, state); +} + +static int card_resume(struct pnp_dev *dev) +{ + struct pnp_card_link *link = dev->card_link; + if (link->pm_state.event == PM_EVENT_ON) + return 0; + link->pm_state = PMSG_ON; + link->driver->resume(link); + return 0; +} + /** * pnp_register_card_driver - registers a PnP card driver with the PnP Layer * @drv: pointer to the driver to register @@ -348,6 +371,8 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) drv->link.flags = drv->flags; drv->link.probe = NULL; drv->link.remove = &card_remove_first; + drv->link.suspend = drv->suspend ? card_suspend : NULL; + drv->link.resume = drv->resume ? card_resume : NULL; spin_lock(&pnp_lock); list_add_tail(&drv->global_list, &pnp_card_drivers); diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index d3ccce7..ea2cb9a 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -146,10 +146,30 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv) return 1; } +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; + + if (pnp_drv && pnp_drv->suspend) + return pnp_drv->suspend(pnp_dev, state); + return 0; +} + +static void pnp_bus_resume(struct device *dev) +{ + struct pnp_dev * pnp_dev = to_pnp_dev(dev); + struct pnp_driver * pnp_drv = pnp_dev->driver; + + if (pnp_drv && pnp_drv->resume) + pnp_drv->resume(pnp_dev); +} struct bus_type pnp_bus_type = { .name = "pnp", .match = pnp_bus_match, + .suspend = pnp_bus_suspend, + .resume = pnp_bus_resume, }; |