[UPDATED PATCH 17-8] fix refcount for non-modular case
Dominik Brodowski
linux at dominikbrodowski.de
Wed Nov 3 10:14:30 EST 2004
Remove the internal driver use_count in ds.c, as the reference counting
is done in the module core anyways, and that reference count is available
for cardmgr's usage by a call to module_refcount. And if
!CONFIG_MODULE_UNLOAD, rmmod is useless anyways, so avoid that call by
cardmgr at all.
drivers/pcmcia/ds.c | 13 ++++++++-----
include/pcmcia/ds.h | 1 -
2 files changed, 8 insertions(+), 6 deletions(-)
diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c 2004-05-16 17:45:55.353700504 +0200
+++ linux/drivers/pcmcia/ds.c 2004-05-16 17:45:58.541215928 +0200
@@ -283,7 +283,6 @@
if (!driver)
return -EINVAL;
- driver->use_count = 0;
driver->drv.bus = &pcmcia_bus_type;
return driver_register(&driver->drv);
@@ -305,10 +304,16 @@
static int proc_read_drivers_callback(struct device_driver *driver, void *d)
{
char **p = d;
- struct pcmcia_driver *p_dev = container_of(driver,
+ struct pcmcia_driver *p_drv = container_of(driver,
struct pcmcia_driver, drv);
- *p += sprintf(*p, "%-24.24s 1 %d\n", driver->name, p_dev->use_count);
+ *p += sprintf(*p, "%-24.24s 1 %d\n", p_drv->drv.name,
+#ifdef CONFIG_MODULE_UNLOAD
+ (p_drv->owner) ? module_refcount(p_drv->owner) : 1
+#else
+ 1
+#endif
+ );
d = (void *) p;
return 0;
@@ -587,7 +592,6 @@
/* finally here the parent client is registered */
s->parent->clients = client;
- p_drv->use_count++;
if (p_drv->attach) {
p_dev->instance = p_drv->attach();
if (!p_dev->instance) {
@@ -727,7 +731,6 @@
p_drv = to_pcmcia_drv(p_dev->dev.driver);
if (p_drv) {
module_put(p_drv->owner);
- p_drv->use_count--;
if ((p_drv->detach) && (p_dev->instance))
p_drv->detach(p_dev->instance);
}
diff -ruN linux-original/include/pcmcia/ds.h linux/include/pcmcia/ds.h
--- linux-original/include/pcmcia/ds.h 2004-05-16 17:45:55.367698376 +0200
+++ linux/include/pcmcia/ds.h 2004-05-16 17:45:58.542215776 +0200
@@ -132,7 +132,6 @@
extern struct bus_type pcmcia_bus_type;
struct pcmcia_driver {
- int use_count;
dev_link_t *(*attach)(void);
void (*detach)(dev_link_t *);
struct module *owner;
More information about the linux-pcmcia
mailing list