* [PATCH] (0/7) device_probe enhancement
@ 2003-09-23 21:47 Stephen Hemminger
2003-09-23 23:39 ` David S. Miller
2003-09-24 0:40 ` Jeff Garzik
0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2003-09-23 21:47 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
This comes from Al Viro's net device patchset and is updated for 2.6.0-test5 latest.
It adds a second probe list for network devices that are compiled into the kernel,
but allocate their own network device rather than being handed a device.
It is part of the incremental changes to have all network devices using dynamic
allocation.
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
--- a/drivers/net/Space.c Tue Sep 23 12:56:25 2003
+++ b/drivers/net/Space.c Tue Sep 23 12:56:25 2003
@@ -111,6 +111,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
@@ -136,6 +141,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
@@ -376,6 +396,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 */
@@ -445,9 +475,12 @@
if (trif_probe(num))
break;
#endif
- for (num = 0; num < 8; ++num)
+ for (num = 0; num < 8; ++num) {
if (ethif_probe(num))
break;
+ ethif_probe2(num);
+ }
+
#ifdef CONFIG_COPS
cops_probe(0);
cops_probe(1);
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
--- a/include/linux/netdevice.h Tue Sep 23 12:56:25 2003
+++ b/include/linux/netdevice.h Tue Sep 23 12:56:25 2003
@@ -498,6 +498,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);
diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c Tue Sep 23 12:56:25 2003
+++ b/net/core/dev.c Tue Sep 23 12:56:25 2003
@@ -375,6 +375,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.
*/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] (0/7) device_probe enhancement 2003-09-23 21:47 [PATCH] (0/7) device_probe enhancement Stephen Hemminger @ 2003-09-23 23:39 ` David S. Miller 2003-09-24 0:25 ` Jeff Garzik 2003-09-24 0:40 ` Jeff Garzik 1 sibling, 1 reply; 5+ messages in thread From: David S. Miller @ 2003-09-23 23:39 UTC (permalink / raw) To: Stephen Hemminger; +Cc: jgarzik, netdev On Tue, 23 Sep 2003 14:47:21 -0700 Stephen Hemminger <shemminger@osdl.org> wrote: > This comes from Al Viro's net device patchset and is updated for > 2.6.0-test5 latest. It adds a second probe list for network devices > that are compiled into the kernel, but allocate their own network > device rather than being handed a device. It is part of the > incremental changes to have all network devices using dynamic > allocation. This all looks fine to me. Jeff, what do you think? Are you gonna merge it if it's ok to you? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] (0/7) device_probe enhancement 2003-09-23 23:39 ` David S. Miller @ 2003-09-24 0:25 ` Jeff Garzik 0 siblings, 0 replies; 5+ messages in thread From: Jeff Garzik @ 2003-09-24 0:25 UTC (permalink / raw) To: David S. Miller; +Cc: Stephen Hemminger, netdev David S. Miller wrote: > On Tue, 23 Sep 2003 14:47:21 -0700 > Stephen Hemminger <shemminger@osdl.org> wrote: > > >>This comes from Al Viro's net device patchset and is updated for >>2.6.0-test5 latest. It adds a second probe list for network devices >>that are compiled into the kernel, but allocate their own network >>device rather than being handed a device. It is part of the >>incremental changes to have all network devices using dynamic >>allocation. > > > This all looks fine to me. Jeff, what do you think? Are you gonna > merge it if it's ok to you? Merging right now. I have some minor nits to pick, but they can be cleaned up later. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] (0/7) device_probe enhancement 2003-09-23 21:47 [PATCH] (0/7) device_probe enhancement Stephen Hemminger 2003-09-23 23:39 ` David S. Miller @ 2003-09-24 0:40 ` Jeff Garzik 2003-09-24 17:03 ` [PATCH] (1/7) de620 -- dynamic allocation (resend) Stephen Hemminger 1 sibling, 1 reply; 5+ messages in thread From: Jeff Garzik @ 2003-09-24 0:40 UTC (permalink / raw) To: Stephen Hemminger; +Cc: netdev hum. your first patch applied OK (0/7), but your succeeding patches did not. All of them failed on Space.c. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] (1/7) de620 -- dynamic allocation (resend) 2003-09-24 0:40 ` Jeff Garzik @ 2003-09-24 17:03 ` Stephen Hemminger 0 siblings, 0 replies; 5+ messages in thread From: Stephen Hemminger @ 2003-09-24 17:03 UTC (permalink / raw) To: Jeff Garzik; +Cc: netdev [-- Attachment #1: Type: text/plain, Size: 1360 bytes --] Convert de620 (original from Al Viro) * switched de620 to dynamic allocation * de620: embedded ->priv * de620: fixed IO before request_region() + fetch and don't clobber command line baseaddr This applies against 2.6.0-test5 bk latest with the probe2 (0/7) applied. Revision history of Space.c were: ======== Space.c 1.1..1.40 ======== D 1.40 03/09/23 05:56:25-07:00 shemminger@osdl.org[shemminger] 42 41 34/1/481 P drivers/net/Space.c C Import patch 0-probe2 ------------------------------------------------ D 1.39 03/09/23 12:09:54-07:00 shemminger@osdl.org 41 40 8/6/474 P drivers/net/Space.c C [NET]: Fix boot param string setup in Space.c ------------------------------------------------ D 1.38 03/09/23 12:08:59-07:00 shemminger@osdl.org 40 39 3/6/477 P drivers/net/Space.c C [NET]: Fix inaccurate comments in Space.c ------------------------------------------------ D 1.37 03/09/23 12:08:25-07:00 shemminger@osdl.org 39 38 3/11/480 P drivers/net/Space.c C [NET]: No need for alloc_divert_blk in Space.c ------------------------------------------------ D 1.36 03/09/12 13:40:26-04:00 mzyngier@freesurf.fr[jgarzik] 38 37 0/4/491 P drivers/net/Space.c C depca update ------------------------------------------------ D 1.35 03/09/08 10:01:25-04:00 shemminger@osdl.org[jgarzik] 37 36 0/5/495 P drivers/net/Space.c C (1/4) sdla - move out of Space.c [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 1-de620.patch --] [-- Type: text/x-diff; name="1-de620.patch", Size: 4399 bytes --] diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c --- a/drivers/net/Space.c Wed Sep 24 09:54:28 2003 +++ b/drivers/net/Space.c Wed Sep 24 09:54:28 2003 @@ -97,7 +97,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); @@ -296,7 +296,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 @@ -387,8 +387,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) @@ -404,7 +403,7 @@ if (base_addr == 1) return; - return; /* nothing yet */ + probe_list2(unit, parport_probes, base_addr == 0); } #ifdef CONFIG_TR diff -Nru a/drivers/net/de620.c b/drivers/net/de620.c --- a/drivers/net/de620.c Wed Sep 24 09:54:28 2003 +++ b/drivers/net/de620.c Wed Sep 24 09:54:28 2003 @@ -226,7 +226,6 @@ /* Initialization */ static int adapter_init(struct net_device *); -int de620_probe(struct net_device *); static int read_eeprom(struct net_device *); @@ -814,11 +813,16 @@ * * Check if there is a DE-620 connected */ -int __init de620_probe(struct net_device *dev) +struct net_device * __init de620_probe(int unit) { - static struct net_device_stats de620_netstats; - int i; byte checkbyte = 0xa5; + struct net_device *dev; + int err = -ENOMEM; + int i; + + dev = alloc_etherdev(sizeof(struct net_device_stats)); + if (!dev) + goto out; SET_MODULE_OWNER(dev); @@ -831,11 +835,23 @@ dev->base_addr = io; dev->irq = irq; + /* allow overriding parameters on command line */ + if (unit >= 0) { + sprintf(dev->name, "eth%d", unit); + netdev_boot_setup_check(dev); + } + if (de620_debug) printk(version); printk(KERN_INFO "D-Link DE-620 pocket adapter"); + if (!request_region(dev->base_addr, 3, "de620")) { + printk(" io 0x%3lX, which is busy.\n", dev->base_addr); + err = -EBUSY; + goto out1; + } + /* Initially, configure basic nibble mode, so we can read the EEPROM */ NIC_Cmd = DEF_NIC_CMD; de620_set_register(dev, W_EIP, EIPRegister); @@ -846,12 +862,8 @@ if ((checkbyte != 0xa5) || (read_eeprom(dev) != 0)) { printk(" not identified in the printer port\n"); - return -ENODEV; - } - - if (!request_region(dev->base_addr, 3, "de620")) { - printk(KERN_ERR "io 0x%3lX, which is busy.\n", dev->base_addr); - return -EBUSY; + err = -ENODEV; + goto out2; } /* else, got it! */ @@ -870,10 +882,6 @@ else printk(" UTP)\n"); - /* Initialize the device structure. */ - dev->priv = &de620_netstats; - - memset(dev->priv, 0, sizeof(struct net_device_stats)); dev->get_stats = get_stats; dev->open = de620_open; dev->stop = de620_close; @@ -884,8 +892,6 @@ /* base_addr and irq are already set, see above! */ - ether_setup(dev); - /* dump eeprom */ if (de620_debug) { printk("\nEEPROM contents:\n"); @@ -899,7 +905,17 @@ printk("SCR = 0x%02x\n", nic_data.SCR); } - return 0; + err = register_netdev(dev); + if (err) + goto out2; + return dev; + +out2: + release_region(dev->base_addr, 3); +out1: + free_netdev(dev); +out: + return ERR_PTR(err); } \f /********************************** @@ -994,20 +1010,21 @@ * */ #ifdef MODULE -static struct net_device de620_dev; +static struct net_device *de620_dev; int init_module(void) { - de620_dev.init = de620_probe; - if (register_netdev(&de620_dev) != 0) - return -EIO; + de620_dev = de620_probe(-1); + if (IS_ERR(de620_dev)) + return PTR_ERR(de620_dev); return 0; } void cleanup_module(void) { - unregister_netdev(&de620_dev); - release_region(de620_dev.base_addr, 3); + unregister_netdev(de620_dev); + release_region(de620_dev->base_addr, 3); + free_netdev(de620_dev); } #endif /* MODULE */ MODULE_LICENSE("GPL"); ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-09-24 17:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-09-23 21:47 [PATCH] (0/7) device_probe enhancement Stephen Hemminger 2003-09-23 23:39 ` David S. Miller 2003-09-24 0:25 ` Jeff Garzik 2003-09-24 0:40 ` Jeff Garzik 2003-09-24 17:03 ` [PATCH] (1/7) de620 -- dynamic allocation (resend) Stephen Hemminger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).