[patches 7/12] pcmcia: pcmcia_device_remove
Dominik Brodowski
linux at dominikbrodowski.net
Thu Feb 10 14:47:39 EST 2005
Move the removal of a device from a driver (a.k.a. "detach") to
a driver-model conform pcmcia_device_remove() function which is called
within device_unregister().
Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---
drivers/pcmcia/ds.c | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
Index: 2.6.11-rc3+/drivers/pcmcia/ds.c
===================================================================
--- 2.6.11-rc3+.orig/drivers/pcmcia/ds.c 2005-02-10 20:24:51.000000000 +0100
+++ 2.6.11-rc3+/drivers/pcmcia/ds.c 2005-02-10 20:24:55.000000000 +0100
@@ -286,6 +286,7 @@
* Registers a PCMCIA driver with the PCMCIA bus core.
*/
static int pcmcia_device_probe(struct device *dev);
+static int pcmcia_device_remove(struct device * dev);
int pcmcia_register_driver(struct pcmcia_driver *driver)
{
@@ -296,6 +297,7 @@
driver->drv.bus = &pcmcia_bus_type;
driver->drv.owner = driver->owner;
driver->drv.probe = pcmcia_device_probe;
+ driver->drv.remove = pcmcia_device_remove;
return driver_register(&driver->drv);
}
@@ -404,6 +406,28 @@
}
+static int pcmcia_device_remove(struct device * dev)
+{
+ struct pcmcia_device *p_dev;
+ struct pcmcia_driver *p_drv;
+
+ /* detach the "instance" */
+ p_dev = to_pcmcia_dev(dev);
+ p_drv = to_pcmcia_drv(dev->driver);
+
+ if (p_drv) {
+ if ((p_drv->detach) && (p_dev->instance)) {
+ p_drv->detach(p_dev->instance);
+ /* from pcmcia_probe_device */
+ put_device(&p_dev->dev);
+ }
+ module_put(p_drv->owner);
+ }
+
+ return 0;
+}
+
+
/*======================================================================
These manage a ring buffer of events pending for one user process
@@ -866,7 +890,6 @@
static int unbind_request(struct pcmcia_bus_socket *s)
{
struct pcmcia_device *p_dev;
- struct pcmcia_driver *p_drv;
unsigned long flags;
ds_dbg(2, "unbind_request(%d)\n", s->parent->sock);
@@ -885,17 +908,6 @@
p_dev->client.state |= CLIENT_STALE;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
- /* detach the "instance" */
- p_drv = to_pcmcia_drv(p_dev->dev.driver);
- if (p_drv) {
- if ((p_drv->detach) && (p_dev->instance)) {
- p_drv->detach(p_dev->instance);
- /* from pcmcia_probe_device */
- put_device(&p_dev->dev);
- }
- module_put(p_drv->owner);
- }
-
device_unregister(&p_dev->dev);
}
More information about the linux-pcmcia
mailing list