From: Dominik Brodowski <linux@dominikbrodowski.de>

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.

Signed-off-by: Dominik Brodowski <linux@brodo.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/pcmcia/ds.c |   13 ++++++++-----
 25-akpm/include/pcmcia/ds.h |    1 -
 2 files changed, 8 insertions(+), 6 deletions(-)

diff -puN drivers/pcmcia/ds.c~pcmcia-remove-internal-module-use-count-use-module_refcount-instead drivers/pcmcia/ds.c
--- 25/drivers/pcmcia/ds.c~pcmcia-remove-internal-module-use-count-use-module_refcount-instead	Mon Dec 13 14:38:40 2004
+++ 25-akpm/drivers/pcmcia/ds.c	Mon Dec 13 14:38:40 2004
@@ -285,7 +285,6 @@ int pcmcia_register_driver(struct pcmcia
 	if (!driver)
 		return -EINVAL;
 
- 	driver->use_count = 0;
 	driver->drv.bus = &pcmcia_bus_type;
 
 	return driver_register(&driver->drv);
@@ -307,10 +306,16 @@ static struct proc_dir_entry *proc_pccar
 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;
@@ -593,7 +598,6 @@ static int bind_request(struct pcmcia_bu
 	/* 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 @@ static int unbind_request(struct pcmcia_
 			/* detach the "instance" */
 			p_drv = to_pcmcia_drv(p_dev->dev.driver);
 			if (p_drv) {
-				p_drv->use_count--;
 				if ((p_drv->detach) && (p_dev->instance))
 					p_drv->detach(p_dev->instance);
 				module_put(p_drv->owner);
diff -puN include/pcmcia/ds.h~pcmcia-remove-internal-module-use-count-use-module_refcount-instead include/pcmcia/ds.h
--- 25/include/pcmcia/ds.h~pcmcia-remove-internal-module-use-count-use-module_refcount-instead	Mon Dec 13 14:38:40 2004
+++ 25-akpm/include/pcmcia/ds.h	Mon Dec 13 14:38:40 2004
@@ -132,7 +132,6 @@ struct pcmcia_socket;
 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;
_