Space.c 3.6 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0-or-later
L
Linus Torvalds 已提交
2 3 4 5 6 7 8 9 10
/*
 * INET		An implementation of the TCP/IP protocol suite for the LINUX
 *		operating system.  INET is implemented using the  BSD Socket
 *		interface as the means of communication with the user level.
 *
 *		Holds initial configuration information for devices.
 *
 * Version:	@(#)Space.c	1.0.7	08/12/93
 *
11
 * Authors:	Ross Biro
L
Linus Torvalds 已提交
12 13 14 15 16 17 18 19 20 21
 *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 *		Donald J. Becker, <becker@scyld.com>
 *
 * Changelog:
 *		Stephen Hemminger (09/2003)
 *		- get rid of pre-linked dev list, dynamic device allocation
 *		Paul Gortmaker (03/2002)
 *		- struct init cleanup, enable multiple ISA autoprobes.
 *		Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 09/1999
 *		- fix sbni: s/device/net_device/
22
 *		Paul Gortmaker (06/98):
L
Linus Torvalds 已提交
23 24 25 26 27 28 29 30
 *		 - sort probes in a sane way, make sure all (safe) probes
 *		   get run once & failed autoprobes don't autoprobe again.
 */
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/netlink.h>
31
#include <net/Space.h>
L
Linus Torvalds 已提交
32 33

/* A unified ethernet device probe.  This is the easiest way to have every
34 35
 * ethernet adaptor have the name "eth[0123...]".
 */
L
Linus Torvalds 已提交
36 37 38 39 40 41 42 43 44

struct devprobe2 {
	struct net_device *(*probe)(int unit);
	int status;	/* non-zero if autoprobe has failed */
};

static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
{
	struct net_device *dev;
45

L
Linus Torvalds 已提交
46 47 48 49 50 51 52 53 54 55 56 57
	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;
}

58
/* ISA probes that touch addresses < 0x400 (including those that also
59
 * look for EISA/PCI cards in addition to ISA cards).
L
Linus Torvalds 已提交
60 61 62 63 64
 */
static struct devprobe2 isa_probes[] __initdata = {
#ifdef CONFIG_3C515
	{tc515_probe, 0},
#endif
65
#ifdef CONFIG_ULTRA
L
Linus Torvalds 已提交
66 67
	{ultra_probe, 0},
#endif
68
#ifdef CONFIG_WD80x3
L
Linus Torvalds 已提交
69 70
	{wd_probe, 0},
#endif
71
#if defined(CONFIG_NE2000) /* ISA (use ne2k-pci for PCI cards) */
L
Linus Torvalds 已提交
72 73 74 75 76 77 78 79 80
	{ne_probe, 0},
#endif
#ifdef CONFIG_LANCE		/* ISA/VLB (use pcnet32 for PCI cards) */
	{lance_probe, 0},
#endif
#ifdef CONFIG_SMC9194
	{smc_init, 0},
#endif
#ifdef CONFIG_CS89x0
81
#ifndef CONFIG_CS89x0_PLATFORM
82
	{cs89x0_probe, 0},
L
Linus Torvalds 已提交
83
#endif
84
#endif
85 86
#if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET)	/* Intel */
	{i82596_probe, 0},					/* I82596 */
L
Linus Torvalds 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
#endif
#ifdef CONFIG_NI65
	{ni65_probe, 0},
#endif
	{NULL, 0},
};

static struct devprobe2 m68k_probes[] __initdata = {
#ifdef CONFIG_ATARILANCE	/* Lance-based Atari ethernet boards */
	{atarilance_probe, 0},
#endif
#ifdef CONFIG_SUN3LANCE         /* sun3 onboard Lance chip */
	{sun3lance_probe, 0},
#endif
#ifdef CONFIG_SUN3_82586        /* sun3 onboard Intel 82586 chip */
	{sun3_82586_probe, 0},
#endif
#ifdef CONFIG_APNE		/* A1200 PCMCIA NE2000 */
	{apne_probe, 0},
#endif
#ifdef CONFIG_MVME147_NET	/* MVME147 internal Ethernet */
	{mvme147lance_probe, 0},
#endif
	{NULL, 0},
};

113
/* Unified ethernet device probe, segmented per architecture and
L
Linus Torvalds 已提交
114 115
 * per bus interface. This drives the legacy devices only for now.
 */
116

L
Linus Torvalds 已提交
117 118 119 120 121 122 123
static void __init ethif_probe2(int unit)
{
	unsigned long base_addr = netdev_boot_base("eth", unit);

	if (base_addr == 1)
		return;

124
	(void)(probe_list2(unit, m68k_probes, base_addr == 0) &&
125
		probe_list2(unit, isa_probes, base_addr == 0));
L
Linus Torvalds 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
}

/*  Statically configured drivers -- order matters here. */
static int __init net_olddevs_init(void)
{
	int num;

#ifdef CONFIG_SBNI
	for (num = 0; num < 8; ++num)
		sbni_probe(num);
#endif
	for (num = 0; num < 8; ++num)
		ethif_probe2(num);

#ifdef CONFIG_COPS
	cops_probe(0);
	cops_probe(1);
	cops_probe(2);
#endif

	return 0;
}

device_initcall(net_olddevs_init);