diff options
author | marius <marius@FreeBSD.org> | 2006-11-07 19:44:41 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2006-11-07 19:44:41 +0000 |
commit | ad2fcce00ec5b81c277a2a28549fe3bc4f0a199f (patch) | |
tree | 403e9a99362d570392d8455f3cfcd4d2ef3e2435 /sys | |
parent | 1e65ce591f8a8716142afedc78ae40258a205529 (diff) | |
download | FreeBSD-src-ad2fcce00ec5b81c277a2a28549fe3bc4f0a199f.zip FreeBSD-src-ad2fcce00ec5b81c277a2a28549fe3bc4f0a199f.tar.gz |
- Don't bother to include IDs of PCnet chips which are not supported
by this driver and largely are not even PCI devices in pcn_chipid.
- Use device_printf(9)/if_printf(9) rather than implementing their
functionality with printf(9).
- Sprinkle some const.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/pci/if_pcn.c | 58 | ||||
-rw-r--r-- | sys/pci/if_pcnreg.h | 9 |
2 files changed, 27 insertions, 40 deletions
diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c index b35b32c..50a713c 100644 --- a/sys/pci/if_pcn.c +++ b/sys/pci/if_pcn.c @@ -97,22 +97,16 @@ MODULE_DEPEND(pcn, miibus, 1, 1, 1); /* * Various supported device vendors/types and their names. */ -static struct pcn_type pcn_devs[] = { +static const struct pcn_type pcn_devs[] = { { PCN_VENDORID, PCN_DEVICEID_PCNET, "AMD PCnet/PCI 10/100BaseTX" }, { PCN_VENDORID, PCN_DEVICEID_HOME, "AMD PCnet/Home HomePNA" }, { 0, 0, NULL } }; -static struct pcn_chipid { +static const struct pcn_chipid { u_int32_t id; - char * name; + const char *name; } pcn_chipid[] = { - { Am79C960, "Am79C960" }, - { Am79C961, "Am79C961" }, - { Am79C961A, "Am79C961A" }, - { Am79C965, "Am79C965" }, - { Am79C970, "Am79C970" }, - { Am79C970A, "Am79C970A" }, { Am79C971, "Am79C971" }, { Am79C972, "Am79C972" }, { Am79C973, "Am79C973" }, @@ -122,8 +116,9 @@ static struct pcn_chipid { { 0, NULL }, }; -static char * pcn_chipid_name(u_int32_t); +static const char *pcn_chipid_name(u_int32_t); static u_int32_t pcn_chip_id(device_t); +static const struct pcn_type *pcn_match(u_int16_t, u_int16_t); static u_int32_t pcn_csr_read(struct pcn_softc *, int); static u_int16_t pcn_csr_read16(struct pcn_softc *, int); @@ -397,11 +392,12 @@ pcn_reset(sc) return; } -static char * -pcn_chipid_name (u_int32_t id) +static const char * +pcn_chipid_name(u_int32_t id) { - struct pcn_chipid *p = pcn_chipid; + const struct pcn_chipid *p; + p = pcn_chipid; while (p->name) { if (id == p->id) return (p->name); @@ -411,7 +407,7 @@ pcn_chipid_name (u_int32_t id) } static u_int32_t -pcn_chip_id (device_t dev) +pcn_chip_id(device_t dev) { struct pcn_softc *sc; u_int32_t chip_id; @@ -463,13 +459,13 @@ pcn_chip_id (device_t dev) return (chip_id); } -static struct pcn_type * -pcn_match (u_int16_t vid, u_int16_t did) +static const struct pcn_type * +pcn_match(u_int16_t vid, u_int16_t did) { - struct pcn_type *t; - t = pcn_devs; + const struct pcn_type *t; - while(t->pcn_name != NULL) { + t = pcn_devs; + while (t->pcn_name != NULL) { if ((vid == t->pcn_vid) && (did == t->pcn_did)) return (t); t++; @@ -485,7 +481,7 @@ static int pcn_probe(dev) device_t dev; { - struct pcn_type *t; + const struct pcn_type *t; struct pcn_softc *sc; int rid; u_int32_t chip_id; @@ -537,10 +533,9 @@ pcn_attach(dev) u_int32_t eaddr[2]; struct pcn_softc *sc; struct ifnet *ifp; - int unit, error = 0, rid; + int error = 0, rid; sc = device_get_softc(dev); - unit = device_get_unit(dev); /* Initialize our mutex. */ mtx_init(&sc->pcn_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, @@ -559,7 +554,7 @@ pcn_attach(dev) sc->pcn_res = bus_alloc_resource_any(dev, PCN_RES, &rid, RF_ACTIVE); if (sc->pcn_res == NULL) { - printf("pcn%d: couldn't map ports/memory\n", unit); + device_printf(dev, "couldn't map ports/memory\n"); error = ENXIO; goto fail; } @@ -573,7 +568,7 @@ pcn_attach(dev) RF_SHAREABLE | RF_ACTIVE); if (sc->pcn_irq == NULL) { - printf("pcn%d: couldn't map interrupt\n", unit); + device_printf(dev, "couldn't map interrupt\n"); error = ENXIO; goto fail; } @@ -587,14 +582,13 @@ pcn_attach(dev) eaddr[0] = CSR_READ_4(sc, PCN_IO32_APROM00); eaddr[1] = CSR_READ_4(sc, PCN_IO32_APROM01); - sc->pcn_unit = unit; callout_init_mtx(&sc->pcn_stat_callout, &sc->pcn_mtx, 0); sc->pcn_ldata = contigmalloc(sizeof(struct pcn_list_data), M_DEVBUF, M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0); if (sc->pcn_ldata == NULL) { - printf("pcn%d: no memory for list buffers!\n", unit); + device_printf(dev, "no memory for list buffers!\n"); error = ENXIO; goto fail; } @@ -602,7 +596,7 @@ pcn_attach(dev) ifp = sc->pcn_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - printf("pcn%d: can not if_alloc()\n", unit); + device_printf(dev, "can not if_alloc()\n"); error = ENOSPC; goto fail; } @@ -621,7 +615,7 @@ pcn_attach(dev) */ if (mii_phy_probe(dev, &sc->pcn_miibus, pcn_ifmedia_upd, pcn_ifmedia_sts)) { - printf("pcn%d: MII without any PHY!\n", sc->pcn_unit); + device_printf(dev, "MII without any PHY!\n"); error = ENXIO; goto fail; } @@ -636,7 +630,7 @@ pcn_attach(dev) pcn_intr, sc, &sc->pcn_intrhand); if (error) { - printf("pcn%d: couldn't set up irq\n", unit); + device_printf(dev, "couldn't set up irq\n"); ether_ifdetach(ifp); goto fail; } @@ -1178,8 +1172,8 @@ pcn_init_locked(sc) /* Init circular RX list. */ if (pcn_list_rx_init(sc) == ENOBUFS) { - printf("pcn%d: initialization failed: no " - "memory for rx buffers\n", sc->pcn_unit); + if_printf(ifp, "initialization failed: no " + "memory for rx buffers\n"); pcn_stop(sc); return; } @@ -1381,7 +1375,7 @@ pcn_watchdog(ifp) PCN_LOCK(sc); ifp->if_oerrors++; - printf("pcn%d: watchdog timeout\n", sc->pcn_unit); + if_printf(ifp, "watchdog timeout\n"); pcn_stop(sc); pcn_reset(sc); diff --git a/sys/pci/if_pcnreg.h b/sys/pci/if_pcnreg.h index 0b27b18..da7e567 100644 --- a/sys/pci/if_pcnreg.h +++ b/sys/pci/if_pcnreg.h @@ -218,12 +218,6 @@ /* CSR88-89: Chip ID masks */ #define AMD_MASK 0x003 #define PART_MASK 0xffff -#define Am79C960 0x0003 -#define Am79C961 0x2260 -#define Am79C961A 0x2261 -#define Am79C965 0x2430 -#define Am79C970 0x0242 -#define Am79C970A 0x2621 #define Am79C971 0x2623 #define Am79C972 0x2624 #define Am79C973 0x2625 @@ -447,7 +441,7 @@ struct pcn_ring_data { struct pcn_type { u_int16_t pcn_vid; u_int16_t pcn_did; - char *pcn_name; + const char *pcn_name; }; struct pcn_softc { @@ -458,7 +452,6 @@ struct pcn_softc { struct resource *pcn_irq; void *pcn_intrhand; device_t pcn_miibus; - u_int8_t pcn_unit; u_int8_t pcn_link; u_int8_t pcn_phyaddr; int pcn_if_flags; |