Commit 1a0bf3c2 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] pcmcia: use driver_find in ds

Use driver_find() in ds.c instead of legacy implementation, and make use of
its reference counting awareness.
Signed-off-by: default avatarDominik Brodowski <linux@brodo.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d56666b5
...@@ -571,11 +571,16 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) ...@@ -571,11 +571,16 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info)
(char *)bind_info->dev_info); (char *)bind_info->dev_info);
p_drv = get_pcmcia_driver(&bind_info->dev_info); p_drv = get_pcmcia_driver(&bind_info->dev_info);
if ((!p_drv) || (!try_module_get(p_drv->owner))) { if (!p_drv) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
} }
if (!try_module_get(p_drv->owner)) {
ret = -EINVAL;
goto err_put_driver;
}
/* Currently, the userspace pcmcia cardmgr detects pcmcia devices. /* Currently, the userspace pcmcia cardmgr detects pcmcia devices.
* Here this information is translated into a kernel * Here this information is translated into a kernel
* struct pcmcia_device. * struct pcmcia_device.
...@@ -636,15 +641,20 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) ...@@ -636,15 +641,20 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info)
} }
} }
put_driver(&p_drv->drv);
return 0; return 0;
err_unregister: err_unregister:
device_unregister(&p_dev->dev); device_unregister(&p_dev->dev);
module_put(p_drv->owner); module_put(p_drv->owner);
put_driver(&p_drv->drv);
return (ret); return (ret);
err_put_module: err_put_module:
module_put(p_drv->owner); module_put(p_drv->owner);
err_put_driver:
put_driver(&p_drv->drv);
err_put: err_put:
pcmcia_put_bus_socket(s); pcmcia_put_bus_socket(s);
return (ret); return (ret);
...@@ -1418,33 +1428,18 @@ static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr) ...@@ -1418,33 +1428,18 @@ static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr)
/* backwards-compatible accessing of driver --- by name! */ /* backwards-compatible accessing of driver --- by name! */
struct cmp_data {
void *dev_info;
struct pcmcia_driver *drv;
};
static int cmp_drv_callback(struct device_driver *drv, void *data)
{
struct cmp_data *cmp = data;
if (strncmp((char *)cmp->dev_info, (char *)drv->name,
DEV_NAME_LEN) == 0) {
cmp->drv = container_of(drv, struct pcmcia_driver, drv);
return -EINVAL;
}
return 0;
}
static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info)
{ {
int ret; struct device_driver *drv;
struct cmp_data cmp = { struct pcmcia_driver *p_drv;
.dev_info = dev_info,
};
ret = bus_for_each_drv(&pcmcia_bus_type, NULL, &cmp, cmp_drv_callback); drv = driver_find((char *) dev_info, &pcmcia_bus_type);
if (ret) if (!drv)
return cmp.drv;
return NULL; return NULL;
p_drv = container_of(drv, struct pcmcia_driver, drv);
return (p_drv);
} }
MODULE_ALIAS("ds"); MODULE_ALIAS("ds");
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