[RFC PATCH 7/11] pcmcia updates (post 2.6.16): default suspend and
resume handling
Dominik Brodowski
linux at dominikbrodowski.net
Sun Jan 15 14:29:54 EST 2006
Subject: [PATCH] pcmcia: default suspend and resume handling
From: Dominik Brodowski <linux at dominikbrodowski.net>
Date: 1137318341 +0100
In all but one case, the suspend and resume functions of PCMCIA drivers
contain mostly of calls to pcmcia_release_configuration() and
pcmcia_request_configuration(). Therefore, move this code out of the
drivers and into the core.
Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---
drivers/bluetooth/bluecard_cs.c | 24 --------------------
drivers/bluetooth/bt3c_cs.c | 24 --------------------
drivers/bluetooth/btuart_cs.c | 25 --------------------
drivers/bluetooth/dtl1_cs.c | 24 --------------------
drivers/char/pcmcia/cm4000_cs.c | 9 -------
drivers/char/pcmcia/cm4040_cs.c | 24 --------------------
drivers/char/pcmcia/synclink_cs.c | 6 -----
drivers/ide/legacy/ide-cs.c | 23 -------------------
drivers/isdn/hardware/avm/avm_cs.c | 38 -------------------------------
drivers/isdn/hisax/avma1_cs.c | 26 +--------------------
drivers/isdn/hisax/elsa_cs.c | 6 -----
drivers/isdn/hisax/sedlbauer_cs.c | 6 -----
drivers/isdn/hisax/teles_cs.c | 6 -----
drivers/net/pcmcia/3c574_cs.c | 18 ++++-----------
drivers/net/pcmcia/3c589_cs.c | 18 ++++-----------
drivers/net/pcmcia/axnet_cs.c | 18 ++++-----------
drivers/net/pcmcia/com20020_cs.c | 23 ++++++-------------
drivers/net/pcmcia/fmvj18x_cs.c | 19 ++++------------
drivers/net/pcmcia/ibmtr_cs.c | 20 +++++-----------
drivers/net/pcmcia/nmclan_cs.c | 19 ++++------------
drivers/net/pcmcia/pcnet_cs.c | 20 +++++-----------
drivers/net/pcmcia/smc91c92_cs.c | 2 --
drivers/net/pcmcia/xirc2ps_cs.c | 16 +++----------
drivers/net/wireless/airo_cs.c | 9 ++-----
drivers/net/wireless/atmel_cs.c | 7 +-----
drivers/net/wireless/hostap/hostap_cs.c | 6 -----
drivers/net/wireless/netwave_cs.c | 18 ++++-----------
drivers/net/wireless/orinoco_cs.c | 8 -------
drivers/net/wireless/ray_cs.c | 22 +++++-------------
drivers/net/wireless/spectrum_cs.c | 7 ------
drivers/net/wireless/wavelan_cs.c | 24 +++++---------------
drivers/net/wireless/wl3501_cs.c | 18 ++++-----------
drivers/parport/parport_cs.c | 23 -------------------
drivers/pcmcia/ds.c | 30 +++++++++++++++++++++---
drivers/scsi/pcmcia/aha152x_stub.c | 14 -----------
drivers/scsi/pcmcia/fdomain_stub.c | 17 +-------------
drivers/scsi/pcmcia/nsp_cs.c | 10 --------
drivers/scsi/pcmcia/qlogic_stub.c | 13 -----------
drivers/scsi/pcmcia/sym53c500_cs.c | 15 ------------
drivers/serial/serial_cs.c | 9 ++-----
drivers/telephony/ixj_pcmcia.c | 24 --------------------
drivers/usb/host/sl811_cs.c | 24 --------------------
include/pcmcia/ds.h | 3 +-
sound/pcmcia/pdaudiocf/pdaudiocf.c | 10 --------
sound/pcmcia/vx/vxpocket.c | 9 -------
45 files changed, 104 insertions(+), 630 deletions(-)
Full patch at:
http://www.kernel.org/git/?p=linux/kernel/git/brodo/pcmcia-2.6.git;a=commit;h=66b91eb48d18d4781bddcf8f0ac872e2405903fc
26466b05a454c41ad69bad472bbe659c023cd53a
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 128e416..bb833b2 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -1005,28 +1005,6 @@ static void bluecard_release(dev_link_t
pcmcia_disable_device(link->handle);
}
-static int bluecard_suspend(struct pcmcia_device *dev)
-{
- dev_link_t *link = dev_to_instance(dev);
-
- link->state |= DEV_SUSPEND;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
-
- return 0;
-}
-
-static int bluecard_resume(struct pcmcia_device *dev)
-{
- dev_link_t *link = dev_to_instance(dev);
-
- link->state &= ~DEV_SUSPEND;
- if (DEV_OK(link))
- pcmcia_request_configuration(link->handle, &link->conf);
-
- return 0;
-}
-
static struct pcmcia_device_id bluecard_ids[] = {
PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),
PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),
@@ -1043,8 +1021,6 @@ static struct pcmcia_driver bluecard_dri
.probe = bluecard_attach,
.remove = bluecard_detach,
.id_table = bluecard_ids,
- .suspend = bluecard_suspend,
- .resume = bluecard_resume,
};
static int __init init_bluecard_cs(void)
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 31739d3..a0546b7 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -10,7 +10,7 @@
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
*
* (C) 1999 David A. Hinds
- * (C) 2003 - 2005 Dominik Brodowski
+ * (C) 2003 - 2006 Dominik Brodowski
*/
#include <linux/kernel.h>
@@ -1025,12 +1025,22 @@ static int pcmcia_dev_suspend(struct dev
{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
struct pcmcia_driver *p_drv = NULL;
+ int ret;
if (dev->driver)
p_drv = to_pcmcia_drv(dev->driver);
- if (p_drv && p_drv->suspend)
- return p_drv->suspend(p_dev);
+ if (p_drv && p_drv->suspend) {
+ ret = p_drv->suspend(p_dev);
+ if (ret)
+ return ret;
+ if (p_dev->instance) {
+ p_dev->instance->state |= DEV_SUSPEND;
+ if ((p_dev->instance->state & DEV_CONFIG) &&
+ !(p_dev->instance->state & DEV_SUSPEND_NORELEASE))
+ pcmcia_release_configuration(p_dev);
+ }
+ }
return 0;
}
@@ -1040,12 +1050,24 @@ static int pcmcia_dev_resume(struct devi
{
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
struct pcmcia_driver *p_drv = NULL;
+ int ret;
if (dev->driver)
p_drv = to_pcmcia_drv(dev->driver);
- if (p_drv && p_drv->resume)
+ if (p_drv && p_drv->resume) {
+ if (p_dev->instance) {
+ p_dev->instance->state &= ~DEV_SUSPEND;
+ if ((p_dev->instance->state & DEV_CONFIG) &&
+ !(p_dev->instance->state & DEV_SUSPEND_NORELEASE)){
+ ret = pcmcia_request_configuration(p_dev,
+ &p_dev->instance->conf);
+ if (ret)
+ return ret;
+ }
+ }
return p_drv->resume(p_dev);
+ }
return 0;
}
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index ce76ab5..8a6a95e 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -118,8 +118,7 @@ typedef struct dev_link_t {
/* Flags for device state */
#define DEV_PRESENT 0x01
#define DEV_CONFIG 0x02
-#define DEV_STALE_CONFIG 0x04 /* release on close */
-#define DEV_STALE_LINK 0x08 /* detach on release */
+#define DEV_SUSPEND_NORELEASE 0x04
#define DEV_CONFIG_PENDING 0x10
#define DEV_RELEASE_PENDING 0x20
#define DEV_SUSPEND 0x40
--
1.1.2
More information about the linux-pcmcia
mailing list