From b463581154f3f3eecda27cae60df813fefcd84d3 Mon Sep 17 00:00:00 2001
From: Dominik Brodowski <linux@dominikbrodowski.net>
Date: Mon, 14 Nov 2005 21:25:35 +0100
Subject: [PATCH] pcmcia: remove dev_list from drivers

The linked list of devices managed by each PCMCIA driver is, in very most
cases, unused. Therefore, remove it from many drivers.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 drivers/scsi/pcmcia/fdomain_stub.c | 30 ++++++++----------------------
 drivers/scsi/pcmcia/nsp_cs.c       | 19 +------------------
 drivers/scsi/pcmcia/qlogic_stub.c  | 16 +---------------
 drivers/scsi/pcmcia/sym53c500_cs.c | 14 +-------------
 4 files changed, 11 insertions(+), 68 deletions(-)

(limited to 'drivers/scsi')

diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 5842c938fff5..538fedb97924 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -87,8 +87,6 @@ static dev_link_t *fdomain_attach(void);
 static void fdomain_detach(struct pcmcia_device *p_dev);
 
 
-static dev_link_t *dev_list = NULL;
-
 static dev_info_t dev_info = "fdomain_cs";
 
 static dev_link_t *fdomain_attach(void)
@@ -116,8 +114,7 @@ static dev_link_t *fdomain_attach(void)
     link->conf.Present = PRESENT_OPTION;
 
     /* Register with Card Services */
-    link->next = dev_list;
-    dev_list = link;
+    link->next = NULL;
     client_reg.dev_info = &dev_info;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
@@ -135,24 +132,14 @@ static dev_link_t *fdomain_attach(void)
 
 static void fdomain_detach(struct pcmcia_device *p_dev)
 {
-    dev_link_t *link = dev_to_instance(p_dev);
-    dev_link_t **linkp;
+	dev_link_t *link = dev_to_instance(p_dev);
 
-    DEBUG(0, "fdomain_detach(0x%p)\n", link);
-    
-    /* Locate device structure */
-    for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
-	if (*linkp == link) break;
-    if (*linkp == NULL)
-	return;
-
-    if (link->state & DEV_CONFIG)
-	fdomain_release(link);
-
-    /* Unlink device structure, free bits */
-    *linkp = link->next;
-    kfree(link->priv);
-    
+	DEBUG(0, "fdomain_detach(0x%p)\n", link);
+
+	if (link->state & DEV_CONFIG)
+		fdomain_release(link);
+
+	kfree(link->priv);
 } /* fdomain_detach */
 
 /*====================================================================*/
@@ -324,7 +311,6 @@ static int __init init_fdomain_cs(void)
 static void __exit exit_fdomain_cs(void)
 {
 	pcmcia_unregister_driver(&fdomain_cs_driver);
-	BUG_ON(dev_list != NULL);
 }
 
 module_init(init_fdomain_cs);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index e40a8c22aa9d..e48e9fb3c58c 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -104,7 +104,6 @@ static struct scsi_host_template nsp_driver_template = {
 #endif
 };
 
-static dev_link_t *dev_list = NULL;
 static dev_info_t dev_info  = {"nsp_cs"};
 
 static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
@@ -1638,8 +1637,7 @@ static dev_link_t *nsp_cs_attach(void)
 
 
 	/* Register with Card Services */
-	link->next               = dev_list;
-	dev_list                 = link;
+	link->next               = NULL;
 	client_reg.dev_info	 = &dev_info;
 	client_reg.Version	 = 0x0210;
 	client_reg.event_callback_args.client_data = link;
@@ -1665,30 +1663,16 @@ static dev_link_t *nsp_cs_attach(void)
 static void nsp_cs_detach(struct pcmcia_device *p_dev)
 {
 	dev_link_t *link = dev_to_instance(p_dev);
-	dev_link_t **linkp;
 
 	nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link);
 
-	/* Locate device structure */
-	for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) {
-		if (*linkp == link) {
-			break;
-		}
-	}
-	if (*linkp == NULL) {
-		return;
-	}
-
 	if (link->state & DEV_CONFIG) {
 		((scsi_info_t *)link->priv)->stop = 1;
 		nsp_cs_release(link);
 	}
 
-	/* Unlink device structure, free bits */
-	*linkp = link->next;
 	kfree(link->priv);
 	link->priv = NULL;
-
 } /* nsp_cs_detach */
 
 
@@ -2168,7 +2152,6 @@ static void __exit nsp_cs_exit(void)
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68))
 	pcmcia_unregister_driver(&nsp_driver);
-	BUG_ON(dev_list != NULL);
 #else
 	unregister_pcmcia_driver(&dev_info);
 	/* XXX: this really needs to move into generic code.. */
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 8351dc234ffb..e10281a6e5f9 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -104,8 +104,6 @@ static dev_link_t *qlogic_attach(void);
 static void qlogic_detach(struct pcmcia_device *p_dev);
 
 
-static dev_link_t *dev_list = NULL;
-
 static dev_info_t dev_info = "qlogic_cs";
 
 static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
@@ -190,8 +188,7 @@ static dev_link_t *qlogic_attach(void)
 	link->conf.Present = PRESENT_OPTION;
 
 	/* Register with Card Services */
-	link->next = dev_list;
-	dev_list = link;
+	link->next = NULL;
 	client_reg.dev_info = &dev_info;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
@@ -210,22 +207,12 @@ static dev_link_t *qlogic_attach(void)
 static void qlogic_detach(struct pcmcia_device *p_dev)
 {
 	dev_link_t *link = dev_to_instance(p_dev);
-	dev_link_t **linkp;
 
 	DEBUG(0, "qlogic_detach(0x%p)\n", link);
 
-	/* Locate device structure */
-	for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
-		if (*linkp == link)
-			break;
-	if (*linkp == NULL)
-		return;
-
 	if (link->state & DEV_CONFIG)
 		qlogic_release(link);
 
-	/* Unlink device structure, free bits */
-	*linkp = link->next;
 	kfree(link->priv);
 
 }				/* qlogic_detach */
@@ -439,7 +426,6 @@ static int __init init_qlogic_cs(void)
 static void __exit exit_qlogic_cs(void)
 {
 	pcmcia_unregister_driver(&qlogic_cs_driver);
-	BUG_ON(dev_list != NULL);
 }
 
 MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index a0f8e2691f9c..87d50b33475e 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -232,7 +232,6 @@ enum Phase {
 *  Global (within this module) variables other than
 *  sym53c500_driver_template (the scsi_host_template).
 */
-static dev_link_t *dev_list;
 static dev_info_t dev_info = "sym53c500_cs";
 
 /* ================================================================== */
@@ -930,22 +929,12 @@ static void
 SYM53C500_detach(struct pcmcia_device *p_dev)
 {
 	dev_link_t *link = dev_to_instance(p_dev);
-	dev_link_t **linkp;
 
 	DEBUG(0, "SYM53C500_detach(0x%p)\n", link);
 
-	/* Locate device structure */
-	for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
-		if (*linkp == link)
-			break;
-	if (*linkp == NULL)
-		return;
-
 	if (link->state & DEV_CONFIG)
 		SYM53C500_release(link);
 
-	/* Unlink device structure, free bits. */
-	*linkp = link->next;
 	kfree(link->priv);
 	link->priv = NULL;
 } /* SYM53C500_detach */
@@ -978,8 +967,7 @@ SYM53C500_attach(void)
 	link->conf.Present = PRESENT_OPTION;
 
 	/* Register with Card Services */
-	link->next = dev_list;
-	dev_list = link;
+	link->next = NULL;
 	client_reg.dev_info = &dev_info;
 	client_reg.Version = 0x0210;
 	client_reg.event_callback_args.client_data = link;
-- 
cgit v1.2.2