Split softc/device_t and misc cleanup for sn(4).

This commit is contained in:
tsutsui 2008-04-23 13:29:44 +00:00
parent c8ff5c0c50
commit 3b31064c9a
5 changed files with 114 additions and 100 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_jazzio.c,v 1.9 2007/10/17 19:53:29 garbled Exp $ */
/* $NetBSD: if_sn_jazzio.c,v 1.10 2008/04/23 13:29:45 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.9 2007/10/17 19:53:29 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.10 2008/04/23 13:29:45 tsutsui Exp $");
#include "bpfilter.h"
@ -71,14 +71,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.9 2007/10/17 19:53:29 garbled Exp
#include <arc/arc/arcbios.h>
#include <arc/jazz/jazziovar.h>
int sonic_jazzio_match(struct device *, struct cfdata *, void *);
void sonic_jazzio_attach(struct device *, struct device *, void *);
int sonic_jazzio_match(device_t, cfdata_t, void *);
void sonic_jazzio_attach(device_t, device_t, void *);
CFATTACH_DECL(sn_jazzio, sizeof(struct sonic_softc),
CFATTACH_DECL_NEW(sn_jazzio, sizeof(struct sonic_softc),
sonic_jazzio_match, sonic_jazzio_attach, NULL, NULL);
int
sonic_jazzio_match(struct device *parent, struct cfdata *match, void *aux)
sonic_jazzio_match(device_t parent, cfdata_t cf, void *aux)
{
struct jazzio_attach_args *ja = aux;
@ -89,23 +89,23 @@ sonic_jazzio_match(struct device *parent, struct cfdata *match, void *aux)
}
void
sonic_jazzio_attach(struct device *parent, struct device *self, void *aux)
sonic_jazzio_attach(device_t parent, device_t self, void *aux)
{
struct sonic_softc *sc = (void *) self;
struct sonic_softc *sc = device_private(self);
struct jazzio_attach_args *ja = aux;
int i;
uint8_t enaddr[ETHER_ADDR_LEN];
sc->sc_dev = self;
sc->sc_st = ja->ja_bust;
sc->sc_dmat = ja->ja_dmat;
printf(": SONIC Ethernet\n");
aprint_normal(": SONIC Ethernet\n");
/* Map the device. */
if (bus_space_map(sc->sc_st, ja->ja_addr, SONIC_NREGS * 4,
0, &sc->sc_sh) != 0) {
printf("%s: unable to map SONIC registers\n",
sc->sc_dev.dv_xname);
aprint_error_dev(sc->sc_dev, "unable to map SONIC registers\n");
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_nubus.c,v 1.28 2007/10/17 19:55:15 garbled Exp $ */
/* $NetBSD: if_sn_nubus.c,v 1.29 2008/04/23 13:29:45 tsutsui Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_sn_nubus.c,v 1.28 2007/10/17 19:55:15 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_sn_nubus.c,v 1.29 2008/04/23 13:29:45 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -50,25 +50,25 @@ __KERNEL_RCSID(0, "$NetBSD: if_sn_nubus.c,v 1.28 2007/10/17 19:55:15 garbled Exp
#include <mac68k/nubus/nubus.h>
#include <mac68k/dev/if_snvar.h>
static int sn_nubus_match(struct device *, struct cfdata *, void *);
static void sn_nubus_attach(struct device *, struct device *, void *);
static int sn_nubus_match(device_t, cfdata_t, void *);
static void sn_nubus_attach(device_t, device_t, void *);
static int sn_nb_card_vendor(bus_space_tag_t, bus_space_handle_t,
struct nubus_attach_args *);
CFATTACH_DECL(sn_nubus, sizeof(struct sonic_softc),
CFATTACH_DECL_NEW(sn_nubus, sizeof(struct sonic_softc),
sn_nubus_match, sn_nubus_attach, NULL, NULL);
static int
sn_nubus_match(struct device *parent, struct cfdata *cf, void *aux)
sn_nubus_match(device_t parent, cfdata_t cf, void *aux)
{
struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
struct nubus_attach_args *na = aux;
bus_space_handle_t bsh;
int rv;
if (bus_space_map(na->na_tag,
NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh))
return (0);
return 0;
rv = 0;
@ -96,9 +96,9 @@ sn_nubus_match(struct device *parent, struct cfdata *cf, void *aux)
* Install interface into kernel networking data structures
*/
static void
sn_nubus_attach(struct device *parent, struct device *self, void *aux)
sn_nubus_attach(device_t parent, device_t self, void *aux)
{
struct sonic_softc *sc = (void *)self;
struct sonic_softc *sc = device_private(self);
struct nubus_attach_args *na = aux;
int i, success, offset;
bus_space_tag_t bst;
@ -108,10 +108,11 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
bst = na->na_tag;
if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) {
printf(": failed to map memory space.\n");
aprint_error(": failed to map memory space.\n");
return;
}
sc->sc_dev = self;
sc->sc_st = bst;
sc->sc_dmat = na->na_dmat;
@ -128,13 +129,13 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_subregion(bst, bsh,
0x00180000, SONIC_NREGS * 4, &sc->sc_sh)) {
printf(": failed to map register space.\n");
aprint_error(": failed to map register space.\n");
break;
}
if (bus_space_subregion(bst, bsh,
0x00ffe004, ETHER_ADDR_LEN, &tmp_bsh)) {
printf(": failed to map ROM space.\n");
aprint_error(": failed to map ROM space.\n");
break;
}
@ -151,13 +152,13 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_subregion(bst, bsh,
0x0, SONIC_NREGS * 4, &sc->sc_sh)) {
printf(": failed to map register space.\n");
aprint_error(": failed to map register space.\n");
break;
}
if (bus_space_subregion(bst, bsh,
0x40000, ETHER_ADDR_LEN, &tmp_bsh)) {
printf(": failed to map ROM space.\n");
aprint_error(": failed to map ROM space.\n");
break;
}
@ -175,13 +176,13 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_subregion(bst, bsh,
0x0, SONIC_NREGS * 4, &sc->sc_sh)) {
printf(": failed to map register space.\n");
aprint_error(": failed to map register space.\n");
break;
}
if (bus_space_subregion(bst, bsh,
0x40000, ETHER_ADDR_LEN, &tmp_bsh)) {
printf(": failed to map ROM space.\n");
aprint_error(": failed to map ROM space.\n");
break;
}
@ -198,13 +199,13 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_subregion(bst, bsh,
0x0, SONIC_NREGS * 4, &sc->sc_sh)) {
printf(": failed to map register space.\n");
aprint_error(": failed to map register space.\n");
break;
}
if (bus_space_subregion(bst, bsh,
0x400000, ETHER_ADDR_LEN, &tmp_bsh)) {
printf(": failed to map ROM space.\n");
aprint_error(": failed to map ROM space.\n");
break;
}
@ -225,7 +226,7 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dcr2 = 0;
sc->sc_32bit = 1;
success = 0;
printf(": unknown card: attachment incomplete.\n");
aprint_error(": unknown card: attachment incomplete.\n");
}
if (!success) {
@ -240,7 +241,7 @@ sn_nubus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_bigendian = 1;
printf(": %s\n", cardtype);
aprint_error(": %s\n", cardtype);
add_nubus_intr(na->slot, (void (*)(void *))sonic_intr, (void *)sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_sn_obio.c,v 1.27 2007/10/17 19:55:16 garbled Exp $ */
/* $NetBSD: if_sn_obio.c,v 1.28 2008/04/23 13:29:45 tsutsui Exp $ */
/*
* Copyright (C) 1997 Allen Briggs
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_sn_obio.c,v 1.27 2007/10/17 19:55:16 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_sn_obio.c,v 1.28 2008/04/23 13:29:45 tsutsui Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -55,18 +55,18 @@ __KERNEL_RCSID(0, "$NetBSD: if_sn_obio.c,v 1.27 2007/10/17 19:55:16 garbled Exp
#define SONIC_PROM_BASE 0x50F08000
#define SONIC_SLOTNO 9
static int sn_obio_match(struct device *, struct cfdata *, void *);
static void sn_obio_attach(struct device *, struct device *, void *);
static int sn_obio_match(device_t, cfdata_t, void *);
static void sn_obio_attach(device_t, device_t, void *);
static int sn_obio_getaddr(struct sonic_softc *, uint8_t *);
static int sn_obio_getaddr_kludge(struct sonic_softc *, uint8_t *);
CFATTACH_DECL(sn_obio, sizeof(struct sonic_softc),
CFATTACH_DECL_NEW(sn_obio, sizeof(struct sonic_softc),
sn_obio_match, sn_obio_attach, NULL, NULL);
static int
sn_obio_match(struct device *parent, struct cfdata *cf, void *aux)
sn_obio_match(device_t parent, cfdata_t cf, void *aux)
{
struct obio_attach_args *oa = (struct obio_attach_args *)aux;
struct obio_attach_args *oa = aux;
bus_space_handle_t bsh;
int found = 0;
@ -89,19 +89,20 @@ sn_obio_match(struct device *parent, struct cfdata *cf, void *aux)
* Install interface into kernel networking data structures
*/
static void
sn_obio_attach(struct device *parent, struct device *self, void *aux)
sn_obio_attach(device_t parent, device_t self, void *aux)
{
struct obio_attach_args *oa = (struct obio_attach_args *)aux;
struct sonic_softc *sc = (void *)self;
struct sonic_softc *sc = device_private(self);
struct obio_attach_args *oa = aux;
uint8_t myaddr[ETHER_ADDR_LEN];
int i;
sc->sc_dev = self;
sc->sc_st = oa->oa_tag;
sc->sc_dmat = oa->oa_dmat;
if (bus_space_map(sc->sc_st,
SONIC_REG_BASE, SONIC_NREGS * 4, 0, &sc->sc_sh)) {
printf(": failed to map space for SONIC regs.\n");
aprint_error(": failed to map space for SONIC regs.\n");
return;
}
@ -142,18 +143,18 @@ sn_obio_attach(struct device *parent, struct device *self, void *aux)
break;
default:
printf(": unsupported machine type\n");
aprint_error(": unsupported machine type\n");
return;
}
if (sn_obio_getaddr(sc, myaddr) &&
sn_obio_getaddr_kludge(sc, myaddr)) { /* XXX kludge for PB */
printf(": failed to get MAC address.\n");
aprint_error(": failed to get MAC address.\n");
bus_space_unmap(sc->sc_st, sc->sc_sh, SONIC_NREGS * 4);
return;
}
printf(": integrated SONIC Ethernet adapter\n");
aprint_normal(": integrated SONIC Ethernet adapter\n");
if (mac68k_machine.aux_interrupts) {
intr_establish(sonic_intr, (void *)sc, 3);
@ -171,14 +172,14 @@ sn_obio_getaddr(struct sonic_softc *sc, uint8_t *lladdr)
bus_space_handle_t bsh;
if (bus_space_map(sc->sc_st, SONIC_PROM_BASE, PAGE_SIZE, 0, &bsh)) {
printf(": failed to map space to read SONIC address.\n%s",
sc->sc_dev.dv_xname);
return (-1);
aprint_error(": failed to map space to read SONIC address.\n");
aprint_normal("%s:", device_xname(sc->sc_dev));
return -1;
}
if (!mac68k_bus_space_probe(sc->sc_st, bsh, 0, 1)) {
bus_space_unmap(sc->sc_st, bsh, PAGE_SIZE);
return (-1);
return -1;
}
sn_get_enaddr(sc->sc_st, bsh, 0, lladdr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp83932.c,v 1.24 2008/04/19 06:59:08 tsutsui Exp $ */
/* $NetBSD: dp83932.c,v 1.25 2008/04/23 13:29:44 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dp83932.c,v 1.24 2008/04/19 06:59:08 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: dp83932.c,v 1.25 2008/04/23 13:29:44 tsutsui Exp $");
#include "bpfilter.h"
@ -104,7 +104,7 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
int i, rseg, error;
bus_dma_segment_t seg;
size_t cdatasize;
char *nullbuf;
uint8_t *nullbuf;
/*
* Allocate the control data structures, and create and load the
@ -118,30 +118,34 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
if ((error = bus_dmamem_alloc(sc->sc_dmat, cdatasize + ETHER_PAD_LEN,
PAGE_SIZE, (64 * 1024), &seg, 1, &rseg,
BUS_DMA_NOWAIT)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to allocate control data, error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to allocate control data, error = %d\n", error);
goto fail_0;
}
if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg,
cdatasize + ETHER_PAD_LEN, (void **) &sc->sc_cdata16,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to map control data, error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to map control data, error = %d\n", error);
goto fail_1;
}
nullbuf = (char *)sc->sc_cdata16 + cdatasize;
nullbuf = (uint8_t *)sc->sc_cdata16 + cdatasize;
memset(nullbuf, 0, ETHER_PAD_LEN);
if ((error = bus_dmamap_create(sc->sc_dmat,
cdatasize, 1, cdatasize, 0, BUS_DMA_NOWAIT,
&sc->sc_cddmamap)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to create control data DMA map, "
"error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to create control data DMA map, error = %d\n",
error);
goto fail_2;
}
if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cddmamap,
sc->sc_cdata16, cdatasize, NULL, BUS_DMA_NOWAIT)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to load control data DMA map, error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to load control data DMA map, error = %d\n", error);
goto fail_3;
}
@ -152,8 +156,9 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
SONIC_NTXFRAGS, MCLBYTES, 0, BUS_DMA_NOWAIT,
&sc->sc_txsoft[i].ds_dmamap)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to create tx DMA map %d, "
"error = %d\n", i, error);
aprint_error_dev(sc->sc_dev,
"unable to create tx DMA map %d, error = %d\n",
i, error);
goto fail_4;
}
}
@ -165,8 +170,9 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
MCLBYTES, 0, BUS_DMA_NOWAIT,
&sc->sc_rxsoft[i].ds_dmamap)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to create rx DMA map %d, "
"error = %d\n", i, error);
aprint_error_dev(sc->sc_dev,
"unable to create rx DMA map %d, error = %d\n",
i, error);
goto fail_5;
}
sc->sc_rxsoft[i].ds_mbuf = NULL;
@ -177,15 +183,15 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
*/
if ((error = bus_dmamap_create(sc->sc_dmat, ETHER_PAD_LEN, 1,
ETHER_PAD_LEN, 0, BUS_DMA_NOWAIT, &sc->sc_nulldmamap)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to create pad buffer DMA map, "
"error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to create pad buffer DMA map, error = %d\n", error);
goto fail_5;
}
if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_nulldmamap,
nullbuf, ETHER_PAD_LEN, NULL, BUS_DMA_NOWAIT)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to load pad buffer DMA map, "
"error = %d\n", error);
aprint_error_dev(sc->sc_dev,
"unable to load pad buffer DMA map, error = %d\n", error);
goto fail_6;
}
bus_dmamap_sync(sc->sc_dmat, sc->sc_nulldmamap, 0, ETHER_PAD_LEN,
@ -196,10 +202,10 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
*/
sonic_reset(sc);
printf("%s: Ethernet address %s\n", device_xname(&sc->sc_dev),
aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n",
ether_sprintf(enaddr));
strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sonic_ioctl;
@ -225,7 +231,8 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
*/
sc->sc_sdhook = shutdownhook_establish(sonic_shutdown, sc);
if (sc->sc_sdhook == NULL)
aprint_error_dev(&sc->sc_dev, "WARNING: unable to establish shutdown hook\n");
aprint_error_dev(sc->sc_dev,
"WARNING: unable to establish shutdown hook\n");
return;
/*
@ -250,7 +257,7 @@ sonic_attach(struct sonic_softc *sc, const uint8_t *enaddr)
fail_3:
bus_dmamap_destroy(sc->sc_dmat, sc->sc_cddmamap);
fail_2:
bus_dmamem_unmap(sc->sc_dmat, (void *) sc->sc_cdata16, cdatasize);
bus_dmamem_unmap(sc->sc_dmat, (void *)sc->sc_cdata16, cdatasize);
fail_1:
bus_dmamem_free(sc->sc_dmat, &seg, rseg);
fail_0:
@ -332,14 +339,16 @@ sonic_start(struct ifnet *ifp)
bus_dmamap_unload(sc->sc_dmat, dmamap);
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
aprint_error_dev(&sc->sc_dev, "unable to allocate Tx mbuf\n");
printf("%s: unable to allocate Tx mbuf\n",
device_xname(sc->sc_dev));
break;
}
if (m0->m_pkthdr.len > MHLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
aprint_error_dev(&sc->sc_dev, "unable to allocate Tx "
"cluster\n");
printf("%s: unable to allocate Tx "
"cluster\n",
device_xname(sc->sc_dev));
m_freem(m);
break;
}
@ -349,8 +358,9 @@ sonic_start(struct ifnet *ifp)
error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
m, BUS_DMA_WRITE|BUS_DMA_NOWAIT);
if (error) {
aprint_error_dev(&sc->sc_dev, "unable to load Tx buffer, "
"error = %d\n", error);
printf("%s: unable to load Tx buffer, "
"error = %d\n", device_xname(sc->sc_dev),
error);
m_freem(m);
break;
}
@ -533,10 +543,10 @@ sonic_watchdog(struct ifnet *ifp)
{
struct sonic_softc *sc = ifp->if_softc;
printf("%s: device timeout\n", device_xname(&sc->sc_dev));
printf("%s: device timeout\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
(void) sonic_init(ifp);
(void)sonic_init(ifp);
}
/*
@ -558,12 +568,12 @@ sonic_ioctl(struct ifnet *ifp, u_long cmd, void *data)
* filter accordingly.
*/
if (ifp->if_flags & IFF_RUNNING)
(void) sonic_init(ifp);
(void)sonic_init(ifp);
error = 0;
}
splx(s);
return (error);
return error;
}
/*
@ -593,7 +603,7 @@ sonic_intr(void *arg)
if (isr & (IMR_PTX|IMR_TXER)) {
if (sonic_txintr(sc) & TCR_FU) {
printf("%s: transmit FIFO underrun\n",
device_xname(&sc->sc_dev));
device_xname(sc->sc_dev));
wantinit = 1;
}
}
@ -601,7 +611,7 @@ sonic_intr(void *arg)
if (isr & (IMR_RFO|IMR_RBA|IMR_RBE|IMR_RDE)) {
#define PRINTERR(bit, str) \
if (isr & (bit)) \
printf("%s: %s\n", device_xname(&sc->sc_dev), str)
printf("%s: %s\n",device_xname(sc->sc_dev), str)
PRINTERR(IMR_RFO, "receive FIFO overrun");
PRINTERR(IMR_RBA, "receive buffer exceeded");
PRINTERR(IMR_RBE, "receive buffers exhausted");
@ -612,11 +622,11 @@ sonic_intr(void *arg)
if (handled) {
if (wantinit)
(void) sonic_init(ifp);
(void)sonic_init(ifp);
sonic_start(ifp);
}
return (handled);
return handled;
}
/*
@ -685,7 +695,7 @@ sonic_txintr(struct sonic_softc *sc)
if (sc->sc_txpending == 0)
ifp->if_timer = 0;
return (totstat);
return totstat;
}
/*
@ -750,9 +760,11 @@ sonic_rxintr(struct sonic_softc *sc)
*/
if ((status & RCR_PRX) == 0) {
if (status & RCR_FAER)
aprint_error_dev(&sc->sc_dev, "Rx frame alignment error\n");
printf("%s: Rx frame alignment error\n",
device_xname(sc->sc_dev));
else if (status & RCR_CRCR)
aprint_error_dev(&sc->sc_dev, "Rx CRC error\n");
printf("%s: Rx CRC error\n",
device_xname(sc->sc_dev));
ifp->if_ierrors++;
SONIC_INIT_RXDESC(sc, i);
continue;
@ -941,9 +953,9 @@ sonic_init(struct ifnet *ifp)
ds = &sc->sc_rxsoft[i];
if (ds->ds_mbuf == NULL) {
if ((error = sonic_add_rxbuf(sc, i)) != 0) {
aprint_error_dev(&sc->sc_dev, "unable to allocate or map Rx "
printf("%s: unable to allocate or map Rx "
"buffer %d, error = %d\n",
i, error);
device_xname(sc->sc_dev), i, error);
/*
* XXX Should attempt to run with fewer receive
* XXX buffers instead of just failing.
@ -1022,8 +1034,8 @@ sonic_init(struct ifnet *ifp)
out:
if (error)
printf("%s: interface not running\n", device_xname(&sc->sc_dev));
return (error);
printf("%s: interface not running\n", device_xname(sc->sc_dev));
return error;
}
/*
@ -1074,7 +1086,7 @@ sonic_stop(struct ifnet *ifp, int disable)
delay(2);
}
if ((CSR_READ(sc, SONIC_CR) & (CR_TXP|CR_RXEN|CR_ST)) != 0)
aprint_error_dev(&sc->sc_dev, "SONIC failed to stop\n");
printf("%s: SONIC failed to stop\n", device_xname(sc->sc_dev));
/*
* Release any queued transmit buffers.
@ -1112,12 +1124,12 @@ sonic_add_rxbuf(struct sonic_softc *sc, int idx)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
return ENOBUFS;
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
return (ENOBUFS);
return ENOBUFS;
}
if (ds->ds_mbuf != NULL)
@ -1129,8 +1141,8 @@ sonic_add_rxbuf(struct sonic_softc *sc, int idx)
m->m_ext.ext_buf, m->m_ext.ext_size, NULL,
BUS_DMA_READ|BUS_DMA_NOWAIT);
if (error) {
aprint_error_dev(&sc->sc_dev, "can't load rx DMA map %d, error = %d\n",
idx, error);
printf("%s: can't load rx DMA map %d, error = %d\n",
device_xname(sc->sc_dev), idx, error);
panic("sonic_add_rxbuf"); /* XXX */
}
@ -1139,7 +1151,7 @@ sonic_add_rxbuf(struct sonic_softc *sc, int idx)
SONIC_INIT_RXDESC(sc, idx);
return (0);
return 0;
}
static void
@ -1255,7 +1267,7 @@ sonic_set_filter(struct sonic_softc *sc)
delay(2);
}
if (CSR_READ(sc, SONIC_CR) & CR_LCAM)
aprint_error_dev(&sc->sc_dev, "CAM load failed\n");
printf("%s: CAM load failed\n", device_xname(sc->sc_dev));
SONIC_CDCAMSYNC(sc, BUS_DMASYNC_POSTWRITE);
/* Set the receive control register. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp83932var.h,v 1.9 2008/04/19 06:59:08 tsutsui Exp $ */
/* $NetBSD: dp83932var.h,v 1.10 2008/04/23 13:29:45 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -153,7 +153,7 @@ struct sonic_descsoft {
* Software state per device.
*/
struct sonic_softc {
struct device sc_dev; /* generic device information */
device_t sc_dev; /* generic device information */
bus_space_tag_t sc_st; /* bus space tag */
bus_space_handle_t sc_sh; /* bus space handle */
bus_dma_tag_t sc_dmat; /* bus DMA tag */