summaryrefslogtreecommitdiff
path: root/drivers/char/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 21:23:14 +0100
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-06 00:03:10 +0100
commitcc3b4866bee996c922e875b8c8efe9f0d8803aae (patch)
tree6632837b6986f33566f75ed971cecbdc210e3201 /drivers/char/pcmcia
parent8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (diff)
downloadlinux-3.10-cc3b4866bee996c922e875b8c8efe9f0d8803aae.tar.gz
linux-3.10-cc3b4866bee996c922e875b8c8efe9f0d8803aae.tar.bz2
linux-3.10-cc3b4866bee996c922e875b8c8efe9f0d8803aae.zip
[PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback
Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function. Old functionality is preserved, for the moment. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c55
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c52
-rw-r--r--drivers/char/pcmcia/synclink_cs.c34
3 files changed, 42 insertions, 99 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 05e93054c98..8a064f2f005 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -66,7 +66,7 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
#define T_100MSEC msecs_to_jiffies(100)
#define T_500MSEC msecs_to_jiffies(500)
-static void cm4000_detach(dev_link_t *link);
+static void cm4000_detach(struct pcmcia_device *p_dev);
static void cm4000_release(dev_link_t *link);
static int major; /* major number we get from the kernel */
@@ -1888,11 +1888,6 @@ static int cm4000_event(event_t event, int priority,
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
cm4000_config(link, devno);
break;
- case CS_EVENT_CARD_REMOVAL:
- DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
- link->state &= ~DEV_PRESENT;
- stop_monitor(dev);
- break;
default:
DEBUGP(5, dev, "unknown event %.2x\n", event);
break;
@@ -1978,7 +1973,7 @@ static dev_link_t *cm4000_attach(void)
i = pcmcia_register_client(&link->handle, &client_reg);
if (i) {
cs_error(link->handle, RegisterClient, i);
- cm4000_detach(link);
+ cm4000_detach(link->handle);
return NULL;
}
@@ -1990,39 +1985,28 @@ static dev_link_t *cm4000_attach(void)
return link;
}
-static void cm4000_detach_by_devno(int devno, dev_link_t * link)
+static void cm4000_detach(struct pcmcia_device *p_dev)
{
+ dev_link_t *link = dev_to_instance(p_dev);
struct cm4000_dev *dev = link->priv;
+ int devno;
- DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno);
+ /* find device */
+ for (devno = 0; devno < CM4000_MAX_DEV; devno++)
+ if (dev_table[devno] == link)
+ break;
+ if (devno == CM4000_MAX_DEV)
+ return;
- if (link->state & DEV_CONFIG) {
- DEBUGP(5, dev, "device still configured (try to release it)\n");
- cm4000_release(link);
- }
+ link->state &= ~DEV_PRESENT;
+ stop_monitor(dev);
- if (link->handle) {
- pcmcia_deregister_client(link->handle);
- }
+ if (link->state & DEV_CONFIG)
+ cm4000_release(link);
dev_table[devno] = NULL;
- kfree(dev);
- return;
-}
-
-static void cm4000_detach(dev_link_t * link)
-{
- int i;
+ kfree(dev);
- /* find device */
- for (i = 0; i < CM4000_MAX_DEV; i++)
- if (dev_table[i] == link)
- break;
-
- if (i == CM4000_MAX_DEV)
- return;
-
- cm4000_detach_by_devno(i, link);
return;
}
@@ -2048,7 +2032,7 @@ static struct pcmcia_driver cm4000_driver = {
.name = "cm4000_cs",
},
.attach = cm4000_attach,
- .detach = cm4000_detach,
+ .remove = cm4000_detach,
.suspend = cm4000_suspend,
.resume = cm4000_resume,
.event = cm4000_event,
@@ -2071,13 +2055,8 @@ static int __init cmm_init(void)
static void __exit cmm_exit(void)
{
- int i;
-
printk(KERN_INFO MODULE_NAME ": unloading\n");
pcmcia_unregister_driver(&cm4000_driver);
- for (i = 0; i < CM4000_MAX_DEV; i++)
- if (dev_table[i])
- cm4000_detach_by_devno(i, dev_table[i]);
unregister_chrdev(major, DEVICE_NAME);
};
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 3622fd39c47..e08ab949c11 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -65,7 +65,7 @@ static char *version =
#define POLL_PERIOD msecs_to_jiffies(10)
static void reader_release(dev_link_t *link);
-static void reader_detach(dev_link_t *link);
+static void reader_detach(struct pcmcia_device *p_dev);
static int major;
@@ -652,10 +652,6 @@ static int reader_event(event_t event, int priority,
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
reader_config(link, devno);
break;
- case CS_EVENT_CARD_REMOVAL:
- DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
- link->state &= ~DEV_PRESENT;
- break;
default:
DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
@@ -734,7 +730,7 @@ static dev_link_t *reader_attach(void)
i = pcmcia_register_client(&link->handle, &client_reg);
if (i) {
cs_error(link->handle, RegisterClient, i);
- reader_detach(link);
+ reader_detach(link->handle);
return NULL;
}
init_waitqueue_head(&dev->devq);
@@ -747,36 +743,28 @@ static dev_link_t *reader_attach(void)
return link;
}
-static void reader_detach_by_devno(int devno, dev_link_t *link)
+static void reader_detach(struct pcmcia_device *p_dev)
{
+ dev_link_t *link = dev_to_instance(p_dev);
struct reader_dev *dev = link->priv;
-
- if (link->state & DEV_CONFIG) {
- DEBUGP(5, dev, "device still configured (try to release it)\n");
- reader_release(link);
- }
-
- pcmcia_deregister_client(link->handle);
- dev_table[devno] = NULL;
- DEBUGP(5, dev, "freeing dev=%p\n", dev);
- cm4040_stop_poll(dev);
- kfree(dev);
- return;
-}
-
-static void reader_detach(dev_link_t *link)
-{
- int i;
+ int devno;
/* find device */
- for (i = 0; i < CM_MAX_DEV; i++) {
- if (dev_table[i] == link)
+ for (devno = 0; devno < CM_MAX_DEV; devno++) {
+ if (dev_table[devno] == link)
break;
}
- if (i == CM_MAX_DEV)
+ if (devno == CM_MAX_DEV)
return;
- reader_detach_by_devno(i, link);
+ link->state &= ~DEV_PRESENT;
+
+ if (link->state & DEV_CONFIG)
+ reader_release(link);
+
+ dev_table[devno] = NULL;
+ kfree(dev);
+
return;
}
@@ -803,7 +791,7 @@ static struct pcmcia_driver reader_driver = {
.name = "cm4040_cs",
},
.attach = reader_attach,
- .detach = reader_detach,
+ .remove = reader_detach,
.suspend = reader_suspend,
.resume = reader_resume,
.event = reader_event,
@@ -825,14 +813,8 @@ static int __init cm4040_init(void)
static void __exit cm4040_exit(void)
{
- int i;
-
printk(KERN_INFO MODULE_NAME ": unloading\n");
pcmcia_unregister_driver(&reader_driver);
- for (i = 0; i < CM_MAX_DEV; i++) {
- if (dev_table[i])
- reader_detach_by_devno(i, dev_table[i]);
- }
unregister_chrdev(major, DEVICE_NAME);
}
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 776103e5604..34597144d9c 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -489,7 +489,7 @@ static void mgslpc_release(u_long arg);
static int mgslpc_event(event_t event, int priority,
event_callback_args_t *args);
static dev_link_t *mgslpc_attach(void);
-static void mgslpc_detach(dev_link_t *);
+static void mgslpc_detach(struct pcmcia_device *p_dev);
static dev_info_t dev_info = "synclink_cs";
static dev_link_t *dev_list = NULL;
@@ -598,7 +598,7 @@ static dev_link_t *mgslpc_attach(void)
ret = pcmcia_register_client(&link->handle, &client_reg);
if (ret != CS_SUCCESS) {
cs_error(link->handle, RegisterClient, ret);
- mgslpc_detach(link);
+ mgslpc_detach(link->handle);
return NULL;
}
@@ -736,17 +736,16 @@ static void mgslpc_release(u_long arg)
pcmcia_release_io(link->handle, &link->io);
if (link->irq.AssignedIRQ)
pcmcia_release_irq(link->handle, &link->irq);
- if (link->state & DEV_STALE_LINK)
- mgslpc_detach(link);
}
-static void mgslpc_detach(dev_link_t *link)
+static void mgslpc_detach(struct pcmcia_device *p_dev)
{
+ dev_link_t *link = dev_to_instance(p_dev);
dev_link_t **linkp;
if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_detach(0x%p)\n", link);
-
+
/* find device */
for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
if (*linkp == link) break;
@@ -754,20 +753,10 @@ static void mgslpc_detach(dev_link_t *link)
return;
if (link->state & DEV_CONFIG) {
- /* device is configured/active, mark it so when
- * release() is called a proper detach() occurs.
- */
- if (debug_level >= DEBUG_LEVEL_INFO)
- printk(KERN_DEBUG "synclinkpc: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
- link->state |= DEV_STALE_LINK;
- return;
+ ((MGSLPC_INFO *)link->priv)->stop = 1;
+ mgslpc_release((u_long)link);
}
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-
/* Unlink device structure, and free it */
*linkp = link->next;
mgslpc_remove_device((MGSLPC_INFO *)link->priv);
@@ -809,13 +798,6 @@ static int mgslpc_event(event_t event, int priority,
printk("mgslpc_event(0x%06x)\n", event);
switch (event) {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG) {
- ((MGSLPC_INFO *)link->priv)->stop = 1;
- mgslpc_release((u_long)link);
- }
- break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
mgslpc_config(link);
@@ -3102,7 +3084,7 @@ static struct pcmcia_driver mgslpc_driver = {
},
.attach = mgslpc_attach,
.event = mgslpc_event,
- .detach = mgslpc_detach,
+ .remove = mgslpc_detach,
.id_table = mgslpc_ids,
.suspend = mgslpc_suspend,
.resume = mgslpc_resume,