Module Name: src
Committed By: cegger
Date: Fri Apr 17 10:20:33 UTC 2009
Modified Files:
src/sys/dev/cardbus: if_tlp_cardbus.c
src/sys/dev/eisa: if_tlp_eisa.c
src/sys/dev/ic: tulip.c tulipvar.h
src/sys/dev/pci: if_tlp_pci.c
Log Message:
device_t/softc split. Tested with tlp at pci
To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/cardbus/if_tlp_cardbus.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/eisa/if_tlp_eisa.c
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ic/tulip.c
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/ic/tulipvar.h
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/pci/if_tlp_pci.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/cardbus/if_tlp_cardbus.c
diff -u src/sys/dev/cardbus/if_tlp_cardbus.c:1.60 src/sys/dev/cardbus/if_tlp_cardbus.c:1.61
--- src/sys/dev/cardbus/if_tlp_cardbus.c:1.60 Sat Mar 14 15:36:16 2009
+++ src/sys/dev/cardbus/if_tlp_cardbus.c Fri Apr 17 10:20:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tlp_cardbus.c,v 1.60 2009/03/14 15:36:16 dsl Exp $ */
+/* $NetBSD: if_tlp_cardbus.c,v 1.61 2009/04/17 10:20:32 cegger Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.60 2009/03/14 15:36:16 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.61 2009/04/17 10:20:32 cegger Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -112,11 +112,11 @@
cardbus_intr_line_t sc_intrline; /* interrupt line */
};
-int tlp_cardbus_match(struct device *, struct cfdata *, void *);
-void tlp_cardbus_attach(struct device *, struct device *, void *);
-int tlp_cardbus_detach(struct device *, int);
+int tlp_cardbus_match(device_t, cfdata_t, void *);
+void tlp_cardbus_attach(device_t, device_t, void *);
+int tlp_cardbus_detach(device_t, int);
-CFATTACH_DECL(tlp_cardbus, sizeof(struct tulip_cardbus_softc),
+CFATTACH_DECL_NEW(tlp_cardbus, sizeof(struct tulip_cardbus_softc),
tlp_cardbus_match, tlp_cardbus_attach, tlp_cardbus_detach, tlp_activate);
const struct tulip_cardbus_product {
@@ -218,7 +218,7 @@
}
int
-tlp_cardbus_match(struct device *parent, struct cfdata *match,
+tlp_cardbus_match(device_t parent, cfdata_t match,
void *aux)
{
struct cardbus_attach_args *ca = aux;
@@ -230,7 +230,7 @@
}
void
-tlp_cardbus_attach(struct device *parent, struct device *self,
+tlp_cardbus_attach(device_t parent, device_t self,
void *aux)
{
struct tulip_cardbus_softc *csc = device_private(self);
@@ -242,6 +242,7 @@
bus_addr_t adr;
pcireg_t reg;
+ sc->sc_dev = self;
sc->sc_devno = 0;
sc->sc_dmat = ca->ca_dmat;
csc->sc_ct = ct;
@@ -333,7 +334,7 @@
csc->sc_bar_reg = TULIP_PCI_IOBA;
csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_IO;
} else {
- aprint_error_dev(&sc->sc_dev, "unable to map device registers\n");
+ aprint_error_dev(self, "unable to map device registers\n");
return;
}
@@ -399,7 +400,7 @@
*/
if (sc->sc_mediasw == NULL) {
printf("%s: defaulting to MII-over-SIO; no bets...\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
sc->sc_mediasw = &tlp_sio_mii_mediasw;
}
break;
@@ -441,7 +442,7 @@
default:
cant_cope:
printf("%s: sorry, unable to handle your board\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
@@ -460,7 +461,7 @@
}
int
-tlp_cardbus_detach(struct device *self, int flags)
+tlp_cardbus_detach(device_t self, int flags)
{
struct tulip_cardbus_softc *csc = device_private(self);
struct tulip_softc *sc = &csc->sc_tulip;
@@ -469,7 +470,7 @@
#if defined(DIAGNOSTIC)
if (ct == NULL)
- panic("%s: data structure lacks", device_xname(&sc->sc_dev));
+ panic("%s: data structure lacks", device_xname(self));
#endif
rv = tlp_detach(sc);
@@ -516,7 +517,7 @@
csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline, IPL_NET,
tlp_intr, sc);
if (csc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev,
+ aprint_error_dev(sc->sc_dev,
"unable to establish interrupt\n");
Cardbus_function_disable(csc->sc_ct);
return (1);
Index: src/sys/dev/eisa/if_tlp_eisa.c
diff -u src/sys/dev/eisa/if_tlp_eisa.c:1.21 src/sys/dev/eisa/if_tlp_eisa.c:1.22
--- src/sys/dev/eisa/if_tlp_eisa.c:1.21 Mon Apr 28 20:23:48 2008
+++ src/sys/dev/eisa/if_tlp_eisa.c Fri Apr 17 10:20:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tlp_eisa.c,v 1.21 2008/04/28 20:23:48 martin Exp $ */
+/* $NetBSD: if_tlp_eisa.c,v 1.22 2009/04/17 10:20:32 cegger Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_eisa.c,v 1.21 2008/04/28 20:23:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_eisa.c,v 1.22 2009/04/17 10:20:32 cegger Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@@ -106,10 +106,10 @@
void *sc_ih; /* interrupt handle */
};
-static int tlp_eisa_match(struct device *, struct cfdata *, void *);
-static void tlp_eisa_attach(struct device *, struct device *, void *);
+static int tlp_eisa_match(device_t, cfdata_t, void *);
+static void tlp_eisa_attach(device_t, device_t, void *);
-CFATTACH_DECL(tlp_eisa, sizeof(struct tulip_eisa_softc),
+CFATTACH_DECL_NEW(tlp_eisa, sizeof(struct tulip_eisa_softc),
tlp_eisa_match, tlp_eisa_attach, NULL, NULL);
static const int tlp_eisa_irqs[] = { 5, 9, 10, 11 };
@@ -139,7 +139,7 @@
}
static int
-tlp_eisa_match(struct device *parent, struct cfdata *match,
+tlp_eisa_match(device_t parent, cfdata_t match,
void *aux)
{
struct eisa_attach_args *ea = aux;
@@ -151,7 +151,7 @@
}
static void
-tlp_eisa_attach(struct device *parent, struct device *self, void *aux)
+tlp_eisa_attach(device_t parent, device_t self, void *aux)
{
static const u_int8_t testpat[] =
{ 0xff, 0, 0x55, 0xaa, 0xff, 0, 0x55, 0xaa };
@@ -177,6 +177,7 @@
return;
}
+ sc->sc_dev = self;
sc->sc_st = iot;
sc->sc_sh = ioh;
@@ -244,7 +245,7 @@
* None of the DE425 boards have the new-style SROMs.
*/
if (tlp_parse_old_srom(sc, enaddr) == 0) {
- aprint_error_dev(&sc->sc_dev, "unable to decode old-style SROM\n");
+ aprint_error_dev(self, "unable to decode old-style SROM\n");
return;
}
@@ -264,7 +265,7 @@
* Map and establish our interrupt.
*/
if (eisa_intr_map(ec, irq, &ih)) {
- aprint_error_dev(&sc->sc_dev, "unable to map interrupt (%u)\n",
+ aprint_error_dev(self, "unable to map interrupt (%u)\n",
irq);
return;
}
@@ -272,14 +273,14 @@
esc->sc_ih = eisa_intr_establish(ec, ih,
(val & 0x01) ? IST_EDGE : IST_LEVEL, IPL_NET, tlp_intr, sc);
if (esc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev, "unable to establish interrupt");
+ aprint_error_dev(self, "unable to establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
if (intrstr != NULL)
- printf("%s: interrupting at %s\n", device_xname(&sc->sc_dev),
+ printf("%s: interrupting at %s\n", device_xname(self),
intrstr);
/*
Index: src/sys/dev/ic/tulip.c
diff -u src/sys/dev/ic/tulip.c:1.166 src/sys/dev/ic/tulip.c:1.167
--- src/sys/dev/ic/tulip.c:1.166 Fri Apr 17 08:19:09 2009
+++ src/sys/dev/ic/tulip.c Fri Apr 17 10:20:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.166 2009/04/17 08:19:09 cegger Exp $ */
+/* $NetBSD: tulip.c,v 1.167 2009/04/17 10:20:33 cegger Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.166 2009/04/17 08:19:09 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.167 2009/04/17 10:20:33 cegger Exp $");
#include "bpfilter.h"
@@ -190,7 +190,7 @@
tlp_attach(struct tulip_softc *sc, const uint8_t *enaddr)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- device_t self = &sc->sc_dev;
+ device_t self = sc->sc_dev;
int i, error;
callout_init(&sc->sc_nway_callout, 0);
@@ -399,7 +399,7 @@
if ((error = bus_dmamem_alloc(sc->sc_dmat,
sizeof(struct tulip_control_data), PAGE_SIZE, 0, &sc->sc_cdseg,
1, &sc->sc_cdnseg, 0)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to allocate control data, error = %d\n",
+ aprint_error_dev(self, "unable to allocate control data, error = %d\n",
error);
goto fail_0;
}
@@ -407,7 +407,7 @@
if ((error = bus_dmamem_map(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg,
sizeof(struct tulip_control_data), (void **)&sc->sc_control_data,
BUS_DMA_COHERENT)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to map control data, error = %d\n",
+ aprint_error_dev(self, "unable to map control data, error = %d\n",
error);
goto fail_1;
}
@@ -415,7 +415,7 @@
if ((error = bus_dmamap_create(sc->sc_dmat,
sizeof(struct tulip_control_data), 1,
sizeof(struct tulip_control_data), 0, 0, &sc->sc_cddmamap)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to create control data DMA map, "
+ aprint_error_dev(self, "unable to create control data DMA map, "
"error = %d\n", error);
goto fail_2;
}
@@ -423,7 +423,7 @@
if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cddmamap,
sc->sc_control_data, sizeof(struct tulip_control_data), NULL,
0)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to load control data DMA map, error = %d\n",
+ aprint_error_dev(self, "unable to load control data DMA map, error = %d\n",
error);
goto fail_3;
}
@@ -455,7 +455,7 @@
if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
sc->sc_ntxsegs, MCLBYTES, 0, 0,
&sc->sc_txsoft[i].txs_dmamap)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to create tx DMA map %d, "
+ aprint_error_dev(self, "unable to create tx DMA map %d, "
"error = %d\n", i, error);
goto fail_4;
}
@@ -467,7 +467,7 @@
for (i = 0; i < TULIP_NRXDESC; i++) {
if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
MCLBYTES, 0, 0, &sc->sc_rxsoft[i].rxs_dmamap)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to create rx DMA map %d, "
+ aprint_error_dev(self, "unable to create rx DMA map %d, "
"error = %d\n", i, error);
goto fail_5;
}
@@ -487,7 +487,7 @@
tlp_reset(sc);
/* Announce ourselves. */
- printf("%s: %s%sEthernet address %s\n", device_xname(&sc->sc_dev),
+ printf("%s: %s%sEthernet address %s\n", device_xname(self),
sc->sc_name[0] != '\0' ? sc->sc_name : "",
sc->sc_name[0] != '\0' ? ", " : "",
ether_sprintf(enaddr));
@@ -505,7 +505,7 @@
*/
(*sc->sc_mediasw->tmsw_init)(sc);
- strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
+ strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
sc->sc_if_flags = ifp->if_flags;
@@ -528,7 +528,7 @@
ether_ifattach(ifp, enaddr);
ether_set_ifflags_cb(&sc->sc_ethercom, tlp_ifflags_cb);
#if NRND > 0
- rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dev),
+ rnd_attach_source(&sc->sc_rnd_source, device_xname(self),
RND_TYPE_NET, 0);
#endif
@@ -607,7 +607,7 @@
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
struct tulip_rxsoft *rxs;
struct tulip_txsoft *txs;
- device_t self = &sc->sc_dev;
+ device_t self = sc->sc_dev;
int i;
/*
@@ -681,7 +681,7 @@
int error, firsttx, nexttx, lasttx = 1, ofree, seg;
DPRINTF(sc, ("%s: tlp_start: sc_flags 0x%08x, if_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags, ifp->if_flags));
+ device_xname(sc->sc_dev), sc->sc_flags, ifp->if_flags));
/*
* If we want a filter setup, it means no more descriptors were
@@ -706,7 +706,7 @@
firsttx = sc->sc_txnext;
DPRINTF(sc, ("%s: tlp_start: txfree %d, txnext %d\n",
- device_xname(&sc->sc_dev), ofree, firsttx));
+ device_xname(sc->sc_dev), ofree, firsttx));
/*
* Loop through the send queue, setting up transmit descriptors
@@ -742,7 +742,7 @@
BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) {
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
- aprint_error_dev(&sc->sc_dev, "unable to allocate Tx mbuf\n");
+ aprint_error_dev(sc->sc_dev, "unable to allocate Tx mbuf\n");
break;
}
MCLAIM(m, &sc->sc_ethercom.ec_tx_mowner);
@@ -750,7 +750,7 @@
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
printf("%s: unable to allocate Tx "
- "cluster\n", device_xname(&sc->sc_dev));
+ "cluster\n", device_xname(sc->sc_dev));
m_freem(m);
break;
}
@@ -761,7 +761,7 @@
m, BUS_DMA_WRITE|BUS_DMA_NOWAIT);
if (error) {
printf("%s: unable to load Tx buffer, "
- "error = %d\n", device_xname(&sc->sc_dev), error);
+ "error = %d\n", device_xname(sc->sc_dev), error);
break;
}
}
@@ -890,7 +890,7 @@
if (sc->sc_txfree != ofree) {
DPRINTF(sc, ("%s: packets enqueued, IC on %d, OWN on %d\n",
- device_xname(&sc->sc_dev), lasttx, firsttx));
+ device_xname(sc->sc_dev), lasttx, firsttx));
/*
* Cause a transmit interrupt to happen on the
* last packet we enqueued.
@@ -944,15 +944,15 @@
doing_transmit = (! SIMPLEQ_EMPTY(&sc->sc_txdirtyq));
if (doing_setup && doing_transmit) {
- printf("%s: filter setup and transmit timeout\n", device_xname(&sc->sc_dev));
+ printf("%s: filter setup and transmit timeout\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
} else if (doing_transmit) {
- printf("%s: transmit timeout\n", device_xname(&sc->sc_dev));
+ printf("%s: transmit timeout\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
} else if (doing_setup)
- printf("%s: filter setup timeout\n", device_xname(&sc->sc_dev));
+ printf("%s: filter setup timeout\n", device_xname(sc->sc_dev));
else
- printf("%s: spurious watchdog timeout\n", device_xname(&sc->sc_dev));
+ printf("%s: spurious watchdog timeout\n", device_xname(sc->sc_dev));
(void) tlp_init(ifp);
@@ -1034,11 +1034,11 @@
uint32_t status, rxstatus, txstatus;
int handled = 0, txthresh;
- DPRINTF(sc, ("%s: tlp_intr\n", device_xname(&sc->sc_dev)));
+ DPRINTF(sc, ("%s: tlp_intr\n", device_xname(sc->sc_dev)));
#ifdef DEBUG
if (TULIP_IS_ENABLED(sc) == 0)
- panic("%s: tlp_intr: not enabled", device_xname(&sc->sc_dev));
+ panic("%s: tlp_intr: not enabled", device_xname(sc->sc_dev));
#endif
/*
@@ -1046,7 +1046,7 @@
* possibly have come from us.
*/
if ((ifp->if_flags & IFF_RUNNING) == 0 ||
- !device_is_active(&sc->sc_dev))
+ !device_is_active(sc->sc_dev))
return (0);
/* Disable interrupts on the DM9102 (interrupt edge bug). */
@@ -1080,11 +1080,11 @@
if (rxstatus & STATUS_RWT)
printf("%s: receive watchdog timeout\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
if (rxstatus & STATUS_RU) {
printf("%s: receive ring overrun\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
/* Get the receive process going again. */
if (sc->sc_tdctl_er != TDCTL_ER) {
tlp_idle(sc, OPMODE_SR);
@@ -1104,7 +1104,7 @@
if (txstatus & STATUS_TJT)
printf("%s: transmit jabber timeout\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
if (txstatus & STATUS_UNF) {
/*
@@ -1122,7 +1122,7 @@
sc->sc_txth[txthresh].txth_opmode;
printf("%s: transmit underrun; new "
"threshold: %s\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
sc->sc_txth[txthresh].txth_name);
/*
@@ -1142,10 +1142,10 @@
if (status & (STATUS_TPS|STATUS_RPS)) {
if (status & STATUS_TPS)
printf("%s: transmit process stopped\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
if (status & STATUS_RPS)
printf("%s: receive process stopped\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
(void) tlp_init(ifp);
break;
}
@@ -1169,7 +1169,7 @@
str = "unknown error";
break;
}
- aprint_error_dev(&sc->sc_dev, "fatal system error: %s\n",
+ aprint_error_dev(sc->sc_dev, "fatal system error: %s\n",
str);
(void) tlp_init(ifp);
break;
@@ -1252,7 +1252,7 @@
if ((rxstat & (TDSTAT_Rx_FS|TDSTAT_Rx_LS)) !=
(TDSTAT_Rx_FS|TDSTAT_Rx_LS)) {
printf("%s: incoming packet spilled, resetting\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
(void) tlp_init(ifp);
return;
}
@@ -1287,7 +1287,7 @@
rxstat &= errors;
#define PRINTERR(bit, str) \
if (rxstat & (bit)) \
- aprint_error_dev(&sc->sc_dev, "receive error: %s\n", \
+ aprint_error_dev(sc->sc_dev, "receive error: %s\n", \
str)
ifp->if_ierrors++;
PRINTERR(TDSTAT_Rx_DE, "descriptor error");
@@ -1432,7 +1432,7 @@
uint32_t txstat;
DPRINTF(sc, ("%s: tlp_txintr: sc_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags));
+ device_xname(sc->sc_dev), sc->sc_flags));
ifp->if_flags &= ~IFF_OACTIVE;
@@ -1544,7 +1544,7 @@
{
printf("%s: tx_uf %lu, tx_to %lu, tx_ec %lu, tx_lc %lu\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
sc->sc_stats.ts_tx_uf, sc->sc_stats.ts_tx_to,
sc->sc_stats.ts_tx_ec, sc->sc_stats.ts_tx_lc);
}
@@ -1594,7 +1594,7 @@
}
if (TULIP_ISSET(sc, CSR_BUSMODE, BUSMODE_SWR))
- aprint_error_dev(&sc->sc_dev, "reset failed to complete\n");
+ aprint_error_dev(sc->sc_dev, "reset failed to complete\n");
delay(1000);
@@ -1826,7 +1826,7 @@
rxs = &sc->sc_rxsoft[i];
if (rxs->rxs_mbuf == NULL) {
if ((error = tlp_add_rxbuf(sc, i)) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to allocate or map rx "
+ aprint_error_dev(sc->sc_dev, "unable to allocate or map rx "
"buffer %d, error = %d\n",
i, error);
/*
@@ -1971,7 +1971,7 @@
if (error) {
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
ifp->if_timer = 0;
- printf("%s: interface not running\n", device_xname(&sc->sc_dev));
+ printf("%s: interface not running\n", device_xname(sc->sc_dev));
}
return (error);
}
@@ -1987,7 +1987,7 @@
if (TULIP_IS_ENABLED(sc) == 0 && sc->sc_enable != NULL) {
if ((*sc->sc_enable)(sc) != 0) {
- aprint_error_dev(&sc->sc_dev, "device enable failed\n");
+ aprint_error_dev(sc->sc_dev, "device enable failed\n");
return (EIO);
}
sc->sc_flags |= TULIPF_ENABLED;
@@ -2187,13 +2187,13 @@
SROM_EMIT(sc, 0);
if (x < 4 || x > 12) {
- aprint_debug_dev(&sc->sc_dev, "broken MicroWire interface detected; "
+ aprint_debug_dev(sc->sc_dev, "broken MicroWire interface detected; "
"setting SROM size to 1Kb\n");
return (6);
} else {
if (tlp_srom_debug)
printf("%s: SROM size is 2^%d*16 bits (%d bytes)\n",
- device_xname(&sc->sc_dev), x, (1 << (x + 4)) >> 3);
+ device_xname(sc->sc_dev), x, (1 << (x + 4)) >> 3);
return (x);
}
}
@@ -2323,7 +2323,7 @@
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",
+ aprint_error_dev(sc->sc_dev, "can't load rx DMA map %d, error = %d\n",
idx, error);
panic("tlp_add_rxbuf"); /* XXX */
}
@@ -2581,7 +2581,7 @@
int cnt, nexttx;
DPRINTF(sc, ("%s: tlp_filter_setup: sc_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags));
+ device_xname(sc->sc_dev), sc->sc_flags));
memcpy(enaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
@@ -2593,7 +2593,7 @@
(sc->sc_flags & TULIPF_DOING_SETUP) != 0) {
sc->sc_flags |= TULIPF_WANT_SETUP;
DPRINTF(sc, ("%s: tlp_filter_setup: deferring\n",
- device_xname(&sc->sc_dev)));
+ device_xname(sc->sc_dev)));
return;
}
sc->sc_flags &= ~TULIPF_WANT_SETUP;
@@ -2827,7 +2827,7 @@
/* Set up a watchdog timer in case the chip flakes out. */
ifp->if_timer = 5;
- DPRINTF(sc, ("%s: tlp_filter_setup: returning\n", device_xname(&sc->sc_dev)));
+ DPRINTF(sc, ("%s: tlp_filter_setup: returning\n", device_xname(sc->sc_dev)));
}
/*
@@ -2845,7 +2845,7 @@
uint32_t hash, mchash[2];
DPRINTF(sc, ("%s: tlp_winb_filter_setup: sc_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags));
+ device_xname(sc->sc_dev), sc->sc_flags));
sc->sc_opmode &= ~(OPMODE_WINB_APP|OPMODE_WINB_AMP|OPMODE_WINB_ABP);
@@ -2898,7 +2898,7 @@
TULIP_WRITE(sc, CSR_WINB_CMA1, mchash[1]);
TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
DPRINTF(sc, ("%s: tlp_winb_filter_setup: returning\n",
- device_xname(&sc->sc_dev)));
+ device_xname(sc->sc_dev)));
}
/*
@@ -2927,7 +2927,7 @@
}
DPRINTF(sc, ("%s: tlp_al981_filter_setup: sc_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags));
+ device_xname(sc->sc_dev), sc->sc_flags));
sc->sc_opmode &= ~(OPMODE_PR|OPMODE_PM);
@@ -2968,7 +2968,7 @@
bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_MAR1, mchash[1]);
TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
DPRINTF(sc, ("%s: tlp_al981_filter_setup: returning\n",
- device_xname(&sc->sc_dev)));
+ device_xname(sc->sc_dev)));
}
/*
@@ -2986,7 +2986,7 @@
uint32_t hash, mchash[2];
DPRINTF(sc, ("%s: tlp_asix_filter_setup: sc_flags 0x%08x\n",
- device_xname(&sc->sc_dev), sc->sc_flags));
+ device_xname(sc->sc_dev), sc->sc_flags));
sc->sc_opmode &= ~(OPMODE_PM|OPMODE_AX_RB|OPMODE_PR);
@@ -3038,7 +3038,7 @@
TULIP_WRITE(sc, CSR_AX_FILTDATA, mchash[1]);
TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
DPRINTF(sc, ("%s: tlp_asix_filter_setup: returning\n",
- device_xname(&sc->sc_dev)));
+ device_xname(sc->sc_dev)));
}
@@ -3135,7 +3135,7 @@
break;
default:
printf("%s: transmit process failed to idle: "
- "state %s\n", device_xname(&sc->sc_dev),
+ "state %s\n", device_xname(sc->sc_dev),
tx_state_names[(csr & STATUS_TS) >> 20]);
}
}
@@ -3152,7 +3152,7 @@
break;
default:
printf("%s: receive process failed to idle: "
- "state %s\n", device_xname(&sc->sc_dev),
+ "state %s\n", device_xname(sc->sc_dev),
rx_state_names[(csr & STATUS_RS) >> 17]);
}
}
@@ -3213,7 +3213,7 @@
struct tulip_softc *sc = arg;
int s;
- if (!device_is_active(&sc->sc_dev))
+ if (!device_is_active(sc->sc_dev))
return;
s = splnet();
@@ -3433,7 +3433,7 @@
return (val & PNIC_MII_DATA);
}
}
- printf("%s: MII read timed out\n", device_xname(&sc->sc_dev));
+ printf("%s: MII read timed out\n", device_xname(sc->sc_dev));
return (0);
}
@@ -3458,7 +3458,7 @@
if (TULIP_ISSET(sc, CSR_PNIC_MII, PNIC_MII_BUSY) == 0)
return;
}
- printf("%s: MII write timed out\n", device_xname(&sc->sc_dev));
+ printf("%s: MII write timed out\n", device_xname(sc->sc_dev));
}
static const bus_addr_t tlp_al981_phy_regmap[] = {
@@ -4029,7 +4029,7 @@
#define PRINT(str) printf("%s%s", sep, str); sep = ", "
- printf("%s: ", device_xname(&sc->sc_dev));
+ printf("%s: ", device_xname(sc->sc_dev));
for (ife = TAILQ_FIRST(&sc->sc_mii.mii_media.ifm_list);
ife != NULL; ife = TAILQ_NEXT(ife, ifm_list)) {
tm = ife->ifm_aux;
@@ -4534,7 +4534,7 @@
default:
printf("%s: unknown media code 0x%02x\n",
- device_xname(&sc->sc_dev),
+ device_xname(sc->sc_dev),
mb & TULIP_ROM_MB_MEDIA_CODE);
free(tm, M_DEVBUF);
}
@@ -4645,7 +4645,7 @@
}
if (i == devcnt) {
- aprint_error_dev(&sc->sc_dev, "unable to locate info leaf in SROM\n");
+ aprint_error_dev(sc->sc_dev, "unable to locate info leaf in SROM\n");
return;
}
@@ -4821,7 +4821,7 @@
* particularly care; the MII code just likes to
* search the whole thing anyhow.
*/
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
MII_PHY_ANY, tm->tm_phyno, 0);
/*
@@ -4836,7 +4836,7 @@
if (phy->mii_offset == tm->tm_phyno)
break;
if (phy == NULL) {
- aprint_error_dev(&sc->sc_dev, "unable to configure MII\n");
+ aprint_error_dev(sc->sc_dev, "unable to configure MII\n");
break;
}
@@ -4978,7 +4978,7 @@
* particularly care; the MII code just likes to
* search the whole thing anyhow.
*/
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
MII_PHY_ANY, tm->tm_phyno, 0);
/*
@@ -4993,7 +4993,7 @@
if (phy->mii_offset == tm->tm_phyno)
break;
if (phy == NULL) {
- aprint_error_dev(&sc->sc_dev, "unable to configure MII\n");
+ aprint_error_dev(sc->sc_dev, "unable to configure MII\n");
break;
}
@@ -5069,12 +5069,12 @@
break;
case TULIP_ROM_MB_21143_RESET:
- printf("%s: 21143 reset block\n", device_xname(&sc->sc_dev));
+ printf("%s: 21143 reset block\n", device_xname(sc->sc_dev));
break;
default:
printf("%s: unknown ISV media block type 0x%02x\n",
- device_xname(&sc->sc_dev), type);
+ device_xname(sc->sc_dev), type);
}
}
@@ -5082,7 +5082,7 @@
* Deal with the case where no media is configured.
*/
if (TAILQ_FIRST(&sc->sc_mii.mii_media.ifm_list) == NULL) {
- printf("%s: no media found!\n", device_xname(&sc->sc_dev));
+ printf("%s: no media found!\n", device_xname(sc->sc_dev));
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
return;
@@ -5190,7 +5190,7 @@
struct mii_data *mii = &sc->sc_mii;
int s, ticks;
- if (!device_is_active(&sc->sc_dev))
+ if (!device_is_active(sc->sc_dev))
return;
s = splnet();
@@ -5283,7 +5283,7 @@
*/
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO &&
ife->ifm_data != mii->mii_media_active) {
- (*sc->sc_statchg)(&sc->sc_dev);
+ (*sc->sc_statchg)(sc->sc_dev);
ife->ifm_data = mii->mii_media_active;
}
return (0);
@@ -5453,7 +5453,7 @@
sc->sc_mii.mii_statchg = sc->sc_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
@@ -5500,11 +5500,11 @@
sc->sc_mii.mii_statchg = sc->sc_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
/* XXX What about AUI/BNC support? */
- printf("%s: ", device_xname(&sc->sc_dev));
+ printf("%s: ", device_xname(sc->sc_dev));
tlp_pnic_nway_reset(sc);
@@ -5625,7 +5625,7 @@
struct tulip_softc *sc = arg;
int s;
- if (!device_is_active(&sc->sc_dev))
+ if (!device_is_active(sc->sc_dev))
return;
s = splnet();
@@ -5706,7 +5706,7 @@
if ((sc->sc_nway_active == NULL ||
sc->sc_nway_active->ifm_media != mii->mii_media_active) ||
cmd == MII_MEDIACHG) {
- (*sc->sc_statchg)(&sc->sc_dev);
+ (*sc->sc_statchg)(sc->sc_dev);
tlp_nway_activate(sc, mii->mii_media_active);
}
return (0);
@@ -5744,7 +5744,7 @@
}
#if 0
if ((reg & PNIC_NWAY_LPAR_MASK) == 0)
- aprint_error_dev(&sc->sc_dev, "autonegotiation failed to complete\n");
+ aprint_error_dev(sc->sc_dev, "autonegotiation failed to complete\n");
#endif
/*
@@ -5780,7 +5780,7 @@
reg = TULIP_READ(sc, CSR_PNIC_NWAY);
#if 0
if ((reg & PNIC_NWAY_LPAR_MASK) == 0)
- aprint_error_dev(&sc->sc_dev, "autonegotiation failed to complete\n");
+ aprint_error_dev(sc->sc_dev, "autonegotiation failed to complete\n");
#endif
tlp_pnic_nway_acomp(sc);
@@ -5896,7 +5896,7 @@
tlp_mediastatus);
if (sc->sc_chip == TULIP_CHIP_MX98713 ||
sc->sc_chip == TULIP_CHIP_MX98713A) {
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
MII_PHY_ANY, MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) {
sc->sc_flags |= TULIPF_HAS_MII;
@@ -5969,7 +5969,7 @@
sc->sc_mii.mii_statchg = sc->sc_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
@@ -6004,7 +6004,7 @@
sc->sc_mii.mii_statchg = sc->sc_statchg;
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
@@ -6064,7 +6064,7 @@
TULIP_WRITE(sc, CSR_OPMODE, opmode);
/* Now, probe the internal MII for the internal PHY. */
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
/*
@@ -6141,7 +6141,7 @@
TULIP_WRITE(sc, CSR_OPMODE, opmode);
/* Now, probe the internal MII for the internal PHY. */
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
/* XXX Figure how to handle the PHY. */
@@ -6208,7 +6208,7 @@
* The RS7112 reports a PHY at 0 (possibly HomePNA?)
* and 1 (ethernet). We attach ethernet only.
*/
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
Index: src/sys/dev/ic/tulipvar.h
diff -u src/sys/dev/ic/tulipvar.h:1.62 src/sys/dev/ic/tulipvar.h:1.63
--- src/sys/dev/ic/tulipvar.h:1.62 Fri Apr 17 08:30:55 2009
+++ src/sys/dev/ic/tulipvar.h Fri Apr 17 10:20:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tulipvar.h,v 1.62 2009/04/17 08:30:55 cegger Exp $ */
+/* $NetBSD: tulipvar.h,v 1.63 2009/04/17 10:20:33 cegger Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -330,7 +330,7 @@
* Software state per device.
*/
struct tulip_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 */
Index: src/sys/dev/pci/if_tlp_pci.c
diff -u src/sys/dev/pci/if_tlp_pci.c:1.106 src/sys/dev/pci/if_tlp_pci.c:1.107
--- src/sys/dev/pci/if_tlp_pci.c:1.106 Sun Jun 8 18:18:34 2008
+++ src/sys/dev/pci/if_tlp_pci.c Fri Apr 17 10:20:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tlp_pci.c,v 1.106 2008/06/08 18:18:34 tsutsui Exp $ */
+/* $NetBSD: if_tlp_pci.c,v 1.107 2009/04/17 10:20:32 cegger Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.106 2008/06/08 18:18:34 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tlp_pci.c,v 1.107 2009/04/17 10:20:32 cegger Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -108,7 +108,7 @@
static int tlp_pci_match(device_t, struct cfdata *, void *);
static void tlp_pci_attach(device_t, device_t, void *);
-CFATTACH_DECL(tlp_pci, sizeof(struct tulip_pci_softc),
+CFATTACH_DECL_NEW(tlp_pci, sizeof(struct tulip_pci_softc),
tlp_pci_match, tlp_pci_attach, NULL, NULL);
static const struct tulip_pci_product {
@@ -310,8 +310,8 @@
for (i = 0; i < tlp_cd.cd_ndevs; i++) {
if ((cur = device_lookup_private(&tlp_cd, i)) == NULL)
continue;
- if (device_parent(&cur->sc_tulip.sc_dev) !=
- device_parent(&sc->sc_dev))
+ if (device_parent(cur->sc_tulip.sc_dev) !=
+ device_parent(sc->sc_dev))
continue;
if ((cur->sc_flags & shared) == 0)
continue;
@@ -329,7 +329,7 @@
}
static int
-tlp_pci_match(device_t parent, struct cfdata *match, void *aux)
+tlp_pci_match(device_t parent, cfdata_t match, void *aux)
{
struct pci_attach_args *pa = aux;
@@ -358,6 +358,7 @@
pcireg_t reg;
int error;
+ sc->sc_dev = self;
sc->sc_devno = pa->pa_device;
psc->sc_pc = pa->pa_pc;
psc->sc_pcitag = pa->pa_tag;
@@ -466,7 +467,7 @@
case TULIP_CHIP_21040:
if (sc->sc_rev < 0x20) {
printf("%s: 21040 must be at least pass 2.0\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
break;
@@ -474,7 +475,7 @@
case TULIP_CHIP_21140:
if (sc->sc_rev < 0x11) {
printf("%s: 21140 must be at least pass 1.1\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
break;
@@ -520,7 +521,7 @@
/* power up chip */
if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self,
NULL)) && error != EOPNOTSUPP) {
- aprint_error_dev(&sc->sc_dev, "cannot activate %d\n",
+ aprint_error_dev(self, "cannot activate %d\n",
error);
return;
}
@@ -542,7 +543,7 @@
sc->sc_st = iot;
sc->sc_sh = ioh;
} else {
- aprint_error_dev(&sc->sc_dev, "unable to map device registers\n");
+ aprint_error_dev(self, "unable to map device registers\n");
return;
}
@@ -611,7 +612,7 @@
}
if (val & PNIC_MIIROM_BUSY) {
printf("%s: EEPROM timed out\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
val &= PNIC_MIIROM_DATA;
@@ -630,7 +631,7 @@
* XXX logic, and for now we can at least remove a machine-
* XXX dependent wart from the PCI front-end.
*/
- ea = prop_dictionary_get(device_properties(&sc->sc_dev),
+ ea = prop_dictionary_get(device_properties(self),
"mac-addr");
if (ea != NULL) {
extern int tlp_srom_debug;
@@ -967,7 +968,7 @@
default:
cant_cope:
printf("%s: sorry, unable to handle your board\n",
- device_xname(&sc->sc_dev));
+ device_xname(self));
return;
}
@@ -989,14 +990,14 @@
if (psc->sc_flags & TULIP_PCI_SLAVEINTR) {
printf("%s: sharing interrupt with %s\n",
- device_xname(&sc->sc_dev),
- device_xname(&psc->sc_master->sc_tulip.sc_dev));
+ device_xname(self),
+ device_xname(psc->sc_master->sc_tulip.sc_dev));
} else {
/*
* Map and establish our interrupt.
*/
if (pci_intr_map(pa, &ih)) {
- aprint_error_dev(&sc->sc_dev, "unable to map interrupt\n");
+ aprint_error_dev(self, "unable to map interrupt\n");
return;
}
intrstr = pci_intr_string(pc, ih);
@@ -1004,13 +1005,13 @@
(psc->sc_flags & TULIP_PCI_SHAREDINTR) ?
tlp_pci_shared_intr : tlp_intr, sc);
if (psc->sc_ih == NULL) {
- aprint_error_dev(&sc->sc_dev, "unable to establish interrupt");
+ aprint_error_dev(self, "unable to establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
- printf("%s: interrupting at %s\n", device_xname(&sc->sc_dev),
+ printf("%s: interrupting at %s\n", device_xname(self),
intrstr);
}
@@ -1156,7 +1157,7 @@
case 0x2b: /* ZX244 */
case 0x2c: /* ZX424 */
case 0x2e: /* ZX422 */
- printf("%s: QS6611 PHY\n", device_xname(&sc->sc_dev));
+ printf("%s: QS6611 PHY\n", device_xname(sc->sc_dev));
sc->sc_reset = tlp_pci_znyx_21142_qs6611_reset;
break;
}
@@ -1350,7 +1351,7 @@
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- printf("%s: ", device_xname(&sc->sc_dev));
+ printf("%s: ", device_xname(sc->sc_dev));
#define ADD(m, c) \
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); \
@@ -1510,7 +1511,7 @@
default:
printf("%s: unknown Cogent board ID 0x%02x\n",
- device_xname(&sc->sc_dev), id0);
+ device_xname(sc->sc_dev), id0);
}
return;
}
@@ -1543,7 +1544,7 @@
default:
unknown:
printf("%s: unknown Adaptec/Cogent board ID 0x%04x/0x%04x\n",
- device_xname(&sc->sc_dev), id1, id2);
+ device_xname(sc->sc_dev), id1, id2);
}
}
@@ -1559,7 +1560,7 @@
ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
tlp_mediastatus);
- printf("%s: ", device_xname(&sc->sc_dev));
+ printf("%s: ", device_xname(sc->sc_dev));
#define ADD(m, c) \
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO); \