Commit bd6d3a0f authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] pcmcia: pcmcia_device_remove

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: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 10008a57
......@@ -286,6 +286,7 @@ static struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket
* 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 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
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_probe(struct device * dev)
}
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 get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info,
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 @@ static int unbind_request(struct pcmcia_bus_socket *s)
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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment