summaryrefslogtreecommitdiff
path: root/drivers/pnp/card.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-29 11:09:32 +0300
committerJaroslav Kysela <perex@suse.cz>2006-01-03 14:31:19 +0300
commit4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9 (patch)
tree4ad45704bcf9e43085164d8d7ca6f07d6f1884dd /drivers/pnp/card.c
parent0ba656d0b2319b76fbebd01c1c9ba5ca8eb33fb1 (diff)
downloadlinux-4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9.tar.xz
[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/pnp/card.c')
-rw-r--r--drivers/pnp/card.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index bd7c966ea2d7..0ecbe4edbec1 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);