Skip to contentSkip to conversation

staging: vt6655: remove multiple instances of driver loading.

PATCH New Malcolm Priestley 1 participant 3 messages Aug 21, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 staging: vt6655: remove multiple instances of driver loading.

The driver can only load once from the instance provided by pci_dev.

struct vnt_private next, prev and pDevice_Infos are removed.

---
 drivers/staging/vt6655/device.h      |  3 ---
 drivers/staging/vt6655/device_main.c | 31 +++----------------------------
 2 files changed, 3 insertions(+), 31 deletions(-)
drivers/staging/vt6655/device.h +0 -3
index 2434a37..bc16ece 100644
@@ -331,9 +331,6 @@ typedef struct __device_opt {
 } OPTIONS, *POPTIONS;
 
 struct vnt_private {
-	struct vnt_private *next;
-	struct vnt_private *prev;
-
 	struct pci_dev *pcid;
 
 #ifdef CONFIG_PM
drivers/staging/vt6655/device_main.c +3 -28
index 1a94d4f..a441a5c 100644
@@ -247,7 +247,6 @@ DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode");
 //
 
 static int          device_nics             = 0;
-static struct vnt_private *pDevice_Infos = NULL;
 static struct net_device *root_device_dev = NULL;
 
 static CHIP_INFO chip_info_table[] = {
@@ -979,19 +978,8 @@ static void vt6655_init_info(struct pci_dev *pcid,
 			     struct vnt_private **ppDevice,
 			     PCHIP_INFO pChip_info)
 {
-	struct vnt_private *p;
-
 	memset(*ppDevice, 0, sizeof(**ppDevice));
 
-	if (pDevice_Infos == NULL) {
-		pDevice_Infos = *ppDevice;
-	} else {
-		for (p = pDevice_Infos; p->next != NULL; p = p->next)
-			do {} while (0);
-		p->next = *ppDevice;
-		(*ppDevice)->prev = p;
-	}
-
 	(*ppDevice)->pcid = pcid;
 	(*ppDevice)->chip_id = pChip_info->chip_id;
 	(*ppDevice)->io_size = pChip_info->io_size;
@@ -1030,9 +1018,11 @@ static bool device_get_pci_info(struct vnt_private *pDevice,
 
 static void device_free_info(struct vnt_private *pDevice)
 {
-	struct vnt_private *ptr;
 	struct net_device *dev = pDevice->dev;
 
+	if (!pDevice)
+		return;
+
 	ASSERT(pDevice);
 //2008-0714-01<Add>by chester
 	device_release_WPADEV(pDevice);
@@ -1042,21 +1032,6 @@ static void device_free_info(struct vnt_private *pDevice)
 	if (wpa_set_wpadev(pDevice, 0) != 0)
 		pr_err("unregister wpadev fail?\n");
 
-	if (pDevice_Infos == NULL)
-		return;
-
-	for (ptr = pDevice_Infos; ptr && (ptr != pDevice); ptr = ptr->next)
-		do {} while (0);
-
-	if (ptr == pDevice) {
-		if (ptr == pDevice_Infos)
-			pDevice_Infos = ptr->next;
-		else
-			ptr->prev->next = ptr->next;
-	} else {
-		pr_err("info struct not found\n");
-		return;
-	}
 #ifdef HOSTAP
 	if (dev)
 		vt6655_hostap_set_hostapd(pDevice, 0, 0);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 staging: vt6655: remove multiple instances of netdevice.

netdevice can only be created once.

---
 drivers/staging/vt6655/device.h      | 1 -
 drivers/staging/vt6655/device_main.c | 3 ---
 2 files changed, 4 deletions(-)
drivers/staging/vt6655/device.h +0 -1
index bc16ece..8ac7901 100644
@@ -339,7 +339,6 @@ struct vnt_private {
 
 // netdev
 	struct net_device *dev;
-	struct net_device *next_module;
 	struct net_device_stats     stats;
 
 //dma addr, rx/tx pool
drivers/staging/vt6655/device_main.c +0 -3
index a441a5c..ffbe64f 100644
@@ -247,7 +247,6 @@ DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode");
 //
 
 static int          device_nics             = 0;
-static struct net_device *root_device_dev = NULL;
 
 static CHIP_INFO chip_info_table[] = {
 	{ VT3253,       "VIA Networking Solomon-A/B/G Wireless LAN Adapter ",
@@ -851,8 +850,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 
 	vt6655_init_info(pcid, &pDevice, pChip_info);
 	pDevice->dev = dev;
-	pDevice->next_module = root_device_dev;
-	root_device_dev = dev;
 
 	if (pci_enable_device(pcid)) {
 		device_free_info(pDevice);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 staging: vt6655: dead code remove device_nics variable

In reply to Malcolm Priestley

The module can not load more than once.

Remove device_nics, MAX_UINTS and OPTION_DEFAULT

Remove dead index variable from device_get_options

---
 drivers/staging/vt6655/device_cfg.h  |  3 ---
 drivers/staging/vt6655/device_main.c | 12 ++----------
 2 files changed, 2 insertions(+), 13 deletions(-)
drivers/staging/vt6655/device_cfg.h +0 -3
index 8e50e53..7221824 100644
@@ -67,9 +67,6 @@ struct _version {
 
 #define PKT_BUF_SZ          2390
 
-#define MAX_UINTS           8
-#define OPTION_DEFAULT      { [0 ... MAX_UINTS-1] = -1}
-
 typedef enum  _chip_type {
 	VT3253 = 1
 } CHIP_TYPE, *PCHIP_TYPE;
drivers/staging/vt6655/device_main.c +2 -10
index ffbe64f..34a70b0 100644
@@ -245,9 +245,6 @@ DEVICE_PARAM(bDiversityANTEnable, "ANT diversity mode");
 //
 // Static vars definitions
 //
-
-static int          device_nics             = 0;
-
 static CHIP_INFO chip_info_table[] = {
 	{ VT3253,       "VIA Networking Solomon-A/B/G Wireless LAN Adapter ",
 	  256, 1,     DEVICE_FLAGS_IP_ALIGN|DEVICE_FLAGS_TX_ALIGN },
@@ -336,7 +333,7 @@ static void vt6655_remove(struct pci_dev *pcid)
 }
 
 static void device_get_options(struct vnt_private *pDevice,
-			       int index, char *devname)
+			       char *devname)
 {
 	POPTIONS pOpts = &(pDevice->sOpts);
 
@@ -825,11 +822,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 	struct vnt_private *pDevice;
 	int         rc;
 
-	if (device_nics++ >= MAX_UINTS) {
-		pr_notice(DEVICE_NAME ": already found %d NICs\n", device_nics);
-		return -ENODEV;
-	}
-
 	dev = alloc_etherdev(sizeof(*pDevice));
 
 	pDevice = netdev_priv(dev);
@@ -934,7 +926,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
 	MACvInitialize(pDevice->PortOffset);
 	MACvReadEtherAddress(pDevice->PortOffset, dev->dev_addr);
 
-	device_get_options(pDevice, device_nics-1, dev->name);
+	device_get_options(pDevice, dev->name);
 	device_set_options(pDevice);
 	//Mask out the options cannot be set to the chip
 	pDevice->sOpts.flags &= pChip_info->flags;
Signature · 1 line
1.9.1