Skip to contentSkip to conversation

device probing changes

PATCH In review Stephen Hemminger 2 participants 2 messages Sep 29, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device probing changes

This a resend of the earlier patches, but these are against 2.6.0-test6 latest; the arlan patch assumes the fix that occurred after 2.6.0-test6 went out.

	00 - adds list of devices that allocate own netdev

	01 - de620
	02 - ni65
	03 - ni52
	04 - ni5010
	05 - sk16
	06 - 3c505
	07 - 3c507
	08 - arlan
	09 - wavelan
	10 - 3c501
	11 - 82596

Each patch starts with a description.

Add second probe list used for devices which allocate their own network device.

Restore earlier behaviour where we probe for up to eight network devices, even if some don't exist. This is for the case where boot parameters set values for second or third device.

drivers/net/Space.c +37 -7
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -110,6 +110,11 @@
 	int status;	/* non-zero if autoprobe has failed */
 };
 
+struct devprobe2 {
+	struct net_device *(*probe)(int unit);
+	int status;	/* non-zero if autoprobe has failed */
+};
+
 /*
  * probe_list walks a list of probe functions and calls each so long
  * as a non-zero ioaddr is given, or as long as it hasn't already failed 
@@ -135,6 +140,21 @@
 	return -ENODEV;
 }
 
+static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
+{
+	struct net_device *dev;
+	for (; p->probe; p++) {
+		if (autoprobe && p->status)
+			continue;
+		dev = p->probe(unit);
+		if (!IS_ERR(dev))
+			return 0;
+		if (autoprobe)
+			p->status = PTR_ERR(dev);
+	}
+	return -ENODEV;
+}
+
 /*
  * This is a bit of an artificial separation as there are PCI drivers
  * that also probe for EISA cards (in the PCI group) and there are ISA
@@ -372,6 +392,16 @@
 	return err;
 
 }
+ 
+static void __init ethif_probe2(int unit)
+{
+	unsigned long base_addr = netdev_boot_base("eth", unit);
+
+	if (base_addr == 1)
+		return;
+
+	return;	/* nothing yet */
+}
 
 #ifdef CONFIG_TR
 /* Token-ring device probe */
@@ -433,17 +463,17 @@
 	
 #ifdef CONFIG_SBNI
 	for (num = 0; num < 8; ++num)
-		if (sbni_probe(num))
-			break;
+		sbni_probe(num);
 #endif
 #ifdef CONFIG_TR
 	for (num = 0; num < 8; ++num)
-		if (trif_probe(num))
-			break;
+		trif_probe(num);
 #endif
-	for (num = 0; num < 8; ++num)
-		if (ethif_probe(num))
-			break;
+	for (num = 0; num < 8; ++num) {
+		if (!ethif_probe(num))
+			ethif_probe2(num);
+	}
+
 #ifdef CONFIG_COPS
 	cops_probe(0);
 	cops_probe(1);
include/linux/netdevice.h +1 -0
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
@@ -499,6 +499,7 @@
 extern void		probe_old_netdevs(void);
 extern int			netdev_boot_setup_add(char *name, struct ifmap *map);
 extern int 			netdev_boot_setup_check(struct net_device *dev);
+extern unsigned long		netdev_boot_base(const char *prefix, int unit);
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern void		dev_add_pack(struct packet_type *pt);
 extern void		dev_remove_pack(struct packet_type *pt);
net/core/dev.c +24 -0
diff -Nru a/net/core/dev.c b/net/core/dev.c
@@ -372,6 +372,30 @@
 	return 0;
 }
 
+
+/**
+ *	netdev_boot_base	- get address from boot time settings
+ *	@prefix: prefix for network device
+ *	@unit: id for network device
+ *
+ * 	Check boot time settings for the base address of device.
+ *	The found settings are set for the device to be used
+ *	later in the device probing.
+ *	Returns 0 if no settings found.
+ */
+unsigned long netdev_boot_base(const char *prefix, int unit)
+{
+	const struct netdev_boot_setup *s = dev_boot_setup;
+	char name[IFNAMSIZ];
+	int i;
+
+	sprintf(name, "%s%d", prefix, unit);
+	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
+		if (!strcmp(name, s[i].name))
+			return s[i].map.base_addr;
+	return 0;
+}
+
 /*
  * Saves at boot time configured settings for any netdevice.
  */

Part of viro NE13-de620:
* switched de620 to dynamic allocation
* de620: embedded ->priv
* de620: fixed IO before request_region()
Additional:
* use free_netdev

drivers/net/Space.c +4 -5
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -96,7 +96,7 @@
 extern struct net_device *ltpc_probe(void);
   
 /* Detachable devices ("pocket adaptors") */
-extern int de620_probe(struct net_device *);
+extern struct net_device *de620_probe(int unit);
 
 /* Fibre Channel adapters */
 extern int iph5526_probe(struct net_device *dev);
@@ -292,7 +292,7 @@
 	{NULL, 0},
 };
 
-static struct devprobe parport_probes[] __initdata = {
+static struct devprobe2 parport_probes[] __initdata = {
 #ifdef CONFIG_DE620		/* D-Link DE-620 adapter */
 	{de620_probe, 0},
 #endif
@@ -383,8 +383,7 @@
 	    probe_list(dev, mips_probes) == 0 ||
 	    probe_list(dev, eisa_probes) == 0 ||
 	    probe_list(dev, mca_probes) == 0 ||
-	    probe_list(dev, isa_probes) == 0 ||
-	    probe_list(dev, parport_probes) == 0) 
+	    probe_list(dev, isa_probes) == 0)
 		err = register_netdev(dev);
 
 	if (err)
@@ -400,7 +399,7 @@
 	if (base_addr == 1)
 		return;
 
-	return;	/* nothing yet */
+	probe_list2(unit, parport_probes, base_addr == 0);
 }
 
 #ifdef CONFIG_TR
drivers/net/de620.c +40 -23

126 lines not on this page · raw message

Quoted 1 line

From viro NE14-ni65

* switched ni65 to dynamic allocation
* ni65: fixed ->irq and ->dma clobbering on autoprobe
Additional:
* added free_netdev

drivers/net/Space.c +6 -1
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -70,7 +70,7 @@
 extern int e2100_probe(struct net_device *);
 extern int ni5010_probe(struct net_device *);
 extern int ni52_probe(struct net_device *);
-extern int ni65_probe(struct net_device *);
+extern struct net_device *ni65_probe(int unit);
 extern int sonic_probe(struct net_device *);
 extern int SK_init(struct net_device *);
 extern int seeq8005_probe(struct net_device *);
@@ -286,6 +286,10 @@
 #ifdef CONFIG_NI52
 	{ni52_probe, 0},
 #endif
+	{NULL, 0},
+};
+
+static struct devprobe2 isa_probes2[] __initdata = {
 #ifdef CONFIG_NI65
 	{ni65_probe, 0},
 #endif
@@ -399,6 +403,7 @@
 	if (base_addr == 1)
 		return;
 
+	probe_list2(unit, isa_probes2, base_addr == 0) &&
 	probe_list2(unit, parport_probes, base_addr == 0);
 }
 
drivers/net/ni65.c +60 -41

142 lines not on this page · raw message

Quoted 1 line

From viro NE15-ni52

* switched ni52 to dynamic allocation
* ni52: embedded ->priv
* ni52: fixed clobbering of everything on autoprobe
Additional:
* add free_netdev

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -69,7 +69,7 @@
 extern int lne390_probe(struct net_device *);
 extern int e2100_probe(struct net_device *);
 extern int ni5010_probe(struct net_device *);
-extern int ni52_probe(struct net_device *);
+extern struct net_device *ni52_probe(int unit);
 extern struct net_device *ni65_probe(int unit);
 extern int sonic_probe(struct net_device *);
 extern int SK_init(struct net_device *);
@@ -283,13 +283,13 @@
 #ifdef CONFIG_NI5010
 	{ni5010_probe, 0},
 #endif
-#ifdef CONFIG_NI52
-	{ni52_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_NI52
+	{ni52_probe, 0},
+#endif
 #ifdef CONFIG_NI65
 	{ni65_probe, 0},
 #endif
drivers/net/ni52.c +61 -57

182 lines not on this page · raw message

from viro NE16-ni5010
* switched ni5010 to dynamic allocation
* ni5010: embedded ->priv
* ni5010: fixed clobbering ->irq
* ni5010: fixed IO before request_region()
Additional:
* add free_netdev

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -68,7 +68,7 @@
 extern int es_probe(struct net_device *);
 extern int lne390_probe(struct net_device *);
 extern int e2100_probe(struct net_device *);
-extern int ni5010_probe(struct net_device *);
+extern struct net_device *ni5010_probe(int unit);
 extern struct net_device *ni52_probe(int unit);
 extern struct net_device *ni65_probe(int unit);
 extern int sonic_probe(struct net_device *);
@@ -280,13 +280,13 @@
 #ifdef CONFIG_SK_G16
 	{SK_init, 0},
 #endif
-#ifdef CONFIG_NI5010
-	{ni5010_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_NI5010
+	{ni5010_probe, 0},
+#endif
 #ifdef CONFIG_NI52
 	{ni52_probe, 0},
 #endif
drivers/net/ni5010.c +94 -90

344 lines not on this page · raw message

from viro NE17-sk16
* switched sk_g16 to dynamic allocation
* sk_g16: embedded ->priv
* sk_g16: fixed buggy check for signature (|| instead of &&, somebody forgot to replace it when inverting the test).
* sk_g16: fixed use after kfree()
* sk_g16: fixed init_etherdev() race
Additional:
* add free_netdev

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -72,7 +72,7 @@
 extern struct net_device *ni52_probe(int unit);
 extern struct net_device *ni65_probe(int unit);
 extern int sonic_probe(struct net_device *);
-extern int SK_init(struct net_device *);
+extern struct net_device *SK_init(int unit);
 extern int seeq8005_probe(struct net_device *);
 extern int smc_init( struct net_device * );
 extern int atarilance_probe(struct net_device *);
@@ -277,13 +277,13 @@
 #ifdef CONFIG_ELPLUS		/* 3c505 */
 	{elplus_probe, 0},
 #endif
-#ifdef CONFIG_SK_G16
-	{SK_init, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_SK_G16
+	{SK_init, 0},
+#endif
 #ifdef CONFIG_NI5010
 	{ni5010_probe, 0},
 #endif
drivers/net/sk_g16.c +60 -119

261 lines not on this page · raw message

from viro NE18-3c505
* switched 3c505 to dynamic allocation
* 3c505: embedded ->priv
* 3c505: fixed use of uninitialized variable
* 3c505: fixed resource leaks on failure exits
Additional:
* add free_netdev

drivers/net/3c505.c +61 -67

208 lines not on this page · raw message

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -63,7 +63,7 @@
 extern int el16_probe(struct net_device *);
 extern int elmc_probe(struct net_device *);
 extern int skmca_probe(struct net_device *);
-extern int elplus_probe(struct net_device *);
+extern struct net_device *elplus_probe(int unit);
 extern int ac3200_probe(struct net_device *);
 extern int es_probe(struct net_device *);
 extern int lne390_probe(struct net_device *);
@@ -274,13 +274,13 @@
 #ifdef CONFIG_EL16		/* 3c507 */
 	{el16_probe, 0},
 #endif
-#ifdef CONFIG_ELPLUS		/* 3c505 */
-	{elplus_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_ELPLUS		/* 3c505 */
+	{elplus_probe, 0},
+#endif
 #ifdef CONFIG_SK_G16
 	{SK_init, 0},
 #endif

from viro NE19-3c507
* switched 3c507 to dynamic allocation
* 3c507: embedded ->priv
* 3c507: fixed clobbering on autoprobe
* NB: 3c507.c buggers port 0x100 without claiming it. Most likely it should be doing request_region() there.
Additional:
* fix port probing loop and correct error return on no device
* add free_netdev

drivers/net/3c507.c +56 -51

172 lines not on this page · raw message

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -60,7 +60,7 @@
 extern int el1_probe(struct net_device *);
 extern int wavelan_probe(struct net_device *);
 extern int arlan_probe(struct net_device *);
-extern int el16_probe(struct net_device *);
+extern struct net_device *el16_probe(int unit);
 extern int elmc_probe(struct net_device *);
 extern int skmca_probe(struct net_device *);
 extern struct net_device *elplus_probe(int unit);
@@ -271,13 +271,13 @@
 #ifdef CONFIG_ARLAN		/* Aironet */
 	{arlan_probe, 0},
 #endif
-#ifdef CONFIG_EL16		/* 3c507 */
-	{el16_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_EL16		/* 3c507 */
+	{el16_probe, 0},
+#endif
 #ifdef CONFIG_ELPLUS		/* 3c505 */
 	{elplus_probe, 0},
 #endif

Completed work started by NE20-arlan-TODO
* allocate network device
* probe only once and do it right
* handle probes > MAX_ARLAN
* use request_mem_region
* proper error unwinds.

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -59,7 +59,7 @@
 extern int ewrk3_probe(struct net_device *);
 extern int el1_probe(struct net_device *);
 extern int wavelan_probe(struct net_device *);
-extern int arlan_probe(struct net_device *);
+extern struct net_device *arlan_probe(int unit);
 extern struct net_device *el16_probe(int unit);
 extern int elmc_probe(struct net_device *);
 extern int skmca_probe(struct net_device *);
@@ -268,13 +268,13 @@
 #ifdef CONFIG_WAVELAN		/* WaveLAN */
 	{wavelan_probe, 0},
 #endif
-#ifdef CONFIG_ARLAN		/* Aironet */
-	{arlan_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_ARLAN		/* Aironet */
+	{arlan_probe, 0},
+#endif
 #ifdef CONFIG_EL16		/* 3c507 */
 	{el16_probe, 0},
 #endif
drivers/net/wireless/arlan-main.c +91 -169

404 lines not on this page · raw message

Quoted 1 line

From viro NE21-wavelan

* switched wavelan to dynamic allocation
* wavelan: embedded ->priv
* wavelan: fixed clobbering on autoprobe
* wavelan: fixed IO before request_region()
* wavelan: fixed resource leaks on failure exits
* wavelan: fixed order of freeing bugs
Additional:
* use free_netdev

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -58,7 +58,7 @@
 extern int i82596_probe(struct net_device *);
 extern int ewrk3_probe(struct net_device *);
 extern int el1_probe(struct net_device *);
-extern int wavelan_probe(struct net_device *);
+extern struct net_device *wavelan_probe(int unit);
 extern struct net_device *arlan_probe(int unit);
 extern struct net_device *el16_probe(int unit);
 extern int elmc_probe(struct net_device *);
@@ -265,13 +265,13 @@
 #ifdef CONFIG_EL1		/* 3c501 */
 	{el1_probe, 0},
 #endif
-#ifdef CONFIG_WAVELAN		/* WaveLAN */
-	{wavelan_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_WAVELAN		/* WaveLAN */
+	{wavelan_probe, 0},
+#endif
 #ifdef CONFIG_ARLAN		/* Aironet */
 	{arlan_probe, 0},
 #endif
drivers/net/wireless/arlan.h +2 -4
diff -Nru a/drivers/net/wireless/arlan.h b/drivers/net/wireless/arlan.h
@@ -57,12 +57,8 @@
  
 #define SIDUNKNOWN -1
 #define radioNodeIdUNKNOWN -1
-#define encryptionKeyUNKNOWN '\0';
 #define irqUNKNOWN 0
-#define memUNKNOWN 0
 #define debugUNKNOWN 0
-#define probeUNKNOWN 1
-#define numDevicesUNKNOWN 1
 #define testMemoryUNKNOWN 1
 #define spreadingCodeUNKNOWN 0
 #define channelNumberUNKNOWN 0
@@ -81,6 +77,8 @@
 #else
 	#define ARLAN_DEBUG(a,b) 
 #endif
+
+#define ARLAN_SHMEM_SIZE	0x2000
 
 struct arlan_shmem
 {
drivers/net/wireless/wavelan.c +76 -95

279 lines not on this page · raw message

drivers/net/wireless/wavelan.p.h +2 -3
diff -Nru a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
@@ -656,9 +656,8 @@
 static int
 	wavelan_open(device *),		/* Open the device. */
 	wavelan_close(device *),	/* Close the device. */
-	wavelan_config(device *);	/* Configure one device. */
-extern int
-	wavelan_probe(device *);	/* See Space.c. */
+	wavelan_config(device *, unsigned short);/* Configure one device. */
+extern struct net_device *wavelan_probe(int unit);	/* See Space.c. */
 
 /**************************** VARIABLES ****************************/
 
Quoted 1 line

From viro NE22-3c501

* switched 3c501 to dynamic allocation
* 3c501: embedded ->priv
* 3c501: fixed clobbering on autoprobe
* 3c501: fixed resource leaks on failure exits
Additional:
* probe correctly when no device present
* fix loop forever bug in probing
* free_netdev

drivers/net/3c501.c +53 -63

180 lines not on this page · raw message

drivers/net/3c501.h +0 -1
diff -Nru a/drivers/net/3c501.h b/drivers/net/3c501.h
@@ -3,7 +3,6 @@
  *	Index to functions.
  */
 
-int el1_probe(struct net_device *dev);
 static int  el1_probe1(struct net_device *dev, int ioaddr);
 static int  el_open(struct net_device *dev);
 static void el_timeout(struct net_device *dev);
drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -57,7 +57,7 @@
 extern int eth16i_probe(struct net_device *);
 extern int i82596_probe(struct net_device *);
 extern int ewrk3_probe(struct net_device *);
-extern int el1_probe(struct net_device *);
+extern struct net_device *el1_probe(int unit);
 extern struct net_device *wavelan_probe(int unit);
 extern struct net_device *arlan_probe(int unit);
 extern struct net_device *el16_probe(int unit);
@@ -262,13 +262,13 @@
 #if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)	/* Intel I82596 */
 	{i82596_probe, 0},
 #endif
-#ifdef CONFIG_EL1		/* 3c501 */
-	{el1_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#ifdef CONFIG_EL1		/* 3c501 */
+	{el1_probe, 0},
+#endif
 #ifdef CONFIG_WAVELAN		/* WaveLAN */
 	{wavelan_probe, 0},
 #endif
Quoted 1 line

From viro NE23-82596

* switched 82596 to dynamic allocation
* 82596: fixed resource leaks on failure exits
Additional:
* free_netdev

drivers/net/82596.c +57 -26

158 lines not on this page · raw message

drivers/net/Space.c +4 -4
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
@@ -55,7 +55,7 @@
 extern int at1700_probe(struct net_device *);
 extern int fmv18x_probe(struct net_device *);
 extern int eth16i_probe(struct net_device *);
-extern int i82596_probe(struct net_device *);
+extern struct net_device *i82596_probe(int unit);
 extern int ewrk3_probe(struct net_device *);
 extern struct net_device *el1_probe(int unit);
 extern struct net_device *wavelan_probe(int unit);
@@ -259,13 +259,13 @@
 #ifdef CONFIG_EWRK3             /* DEC EtherWORKS 3 */
     	{ewrk3_probe, 0},
 #endif
-#if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)	/* Intel I82596 */
-	{i82596_probe, 0},
-#endif
 	{NULL, 0},
 };
 
 static struct devprobe2 isa_probes2[] __initdata = {
+#if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)	/* Intel I82596 */
+	{i82596_probe, 0},
+#endif
 #ifdef CONFIG_EL1		/* 3c501 */
 	{el1_probe, 0},
 #endif
#1 lore raw

dropped -- please re-spam me with one patch per email