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 --- drivers/pcmcia/ds.c | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) Index: 2.6.10-rc3/drivers/pcmcia/ds.c =================================================================== --- 2.6.10-rc3.orig/drivers/pcmcia/ds.c 2004-12-15 16:34:35.000000000 +0100 +++ 2.6.10-rc3/drivers/pcmcia/ds.c 2004-12-15 16:40:31.392284729 +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); }