diff options
| author | tsutsui <tsutsui@NetBSD.org> | 2011-06-03 16:28:40 +0000 |
|---|---|---|
| committer | tsutsui <tsutsui@NetBSD.org> | 2011-06-03 16:28:40 +0000 |
| commit | 83fe5ffe4f3b358f5eb7219148fc87d068e38973 (patch) | |
| tree | 303042e888f9f8a39ee27fec887dc2e0427398f4 /sys/dev | |
| parent | 4ad790a8901af2e2cd573be40926cfc2daf6c8a6 (diff) | |
Split device_t/softc of i82586. No crash on TME emulating sun2.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/i82586.c | 92 | ||||
| -rw-r--r-- | sys/dev/ic/i82586var.h | 4 | ||||
| -rw-r--r-- | sys/dev/isa/if_ai.c | 18 | ||||
| -rw-r--r-- | sys/dev/isa/if_ef.c | 21 | ||||
| -rw-r--r-- | sys/dev/isa/if_ix.c | 21 | ||||
| -rw-r--r-- | sys/dev/mca/if_elmc_mca.c | 23 | ||||
| -rw-r--r-- | sys/dev/podulebus/if_ei.c | 20 | ||||
| -rw-r--r-- | sys/dev/vme/if_ie_vme.c | 11 |
8 files changed, 109 insertions, 101 deletions
diff --git a/sys/dev/ic/i82586.c b/sys/dev/ic/i82586.c index 0bbb1adaaff..6a5df278c50 100644 --- a/sys/dev/ic/i82586.c +++ b/sys/dev/ic/i82586.c @@ -1,4 +1,4 @@ -/* $NetBSD: i82586.c,v 1.68 2010/04/05 07:19:34 joerg Exp $ */ +/* $NetBSD: i82586.c,v 1.69 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -137,7 +137,7 @@ Mode of operation: */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.68 2010/04/05 07:19:34 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.69 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> @@ -236,7 +236,7 @@ i82586_attach(struct ie_softc *sc, const char *name, u_int8_t *etheraddr, int *m int i; struct ifnet *ifp = &sc->sc_ethercom.ec_if; - 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_start = i82586_start; ifp->if_ioctl = i82586_ioctl; @@ -262,7 +262,7 @@ i82586_attach(struct ie_softc *sc, const char *name, u_int8_t *etheraddr, int *m padbuf = malloc(ETHER_MIN_LEN - ETHER_CRC_LEN, M_DEVBUF, M_ZERO | M_NOWAIT); if (padbuf == NULL) { - aprint_error_dev(&sc->sc_dev, "can't allocate pad buffer\n"); + aprint_error_dev(sc->sc_dev, "can't allocate pad buffer\n"); return; } } @@ -285,7 +285,7 @@ i82586_watchdog(struct ifnet *ifp) { struct ie_softc *sc = ifp->if_softc; - log(LOG_ERR, "%s: device timeout\n", device_xname(&sc->sc_dev)); + log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev)); ++ifp->if_oerrors; i82586_reset(sc, 1); @@ -424,7 +424,7 @@ i82586_rx_errors(struct ie_softc *sc, int fn, int status) char bits[128]; snprintb(bits, sizeof(bits), IE_FD_STATUSBITS, status); log(LOG_ERR, "%s: rx error (frame# %d): %s\n", - device_xname(&sc->sc_dev), fn, bits); + device_xname(sc->sc_dev), fn, bits); } @@ -472,7 +472,7 @@ loop: #if I82586_DEBUG if ((status & IE_ST_CNA) && (sc->sc_debug & IED_CNA)) - printf("%s: cna; status=0x%x\n", device_xname(&sc->sc_dev), status); + printf("%s: cna; status=0x%x\n", device_xname(sc->sc_dev), status); #endif if (sc->intrhook) (sc->intrhook)(sc, INTR_LOOP); @@ -516,7 +516,7 @@ static int timesthru = 1024; #if I82586_DEBUG if (sc->sc_debug & IED_RINT) printf("%s: rint: status 0x%x\n", - device_xname(&sc->sc_dev), scbstatus); + device_xname(sc->sc_dev), scbstatus); #endif for (;;) { @@ -530,12 +530,12 @@ static int timesthru = 1024; #if I82586_DEBUG if (sc->sc_debug & IED_RINT) printf("%s: rint: frame(%d) status 0x%x\n", - device_xname(&sc->sc_dev), i, status); + device_xname(sc->sc_dev), i, status); #endif if ((status & IE_FD_COMPLETE) == 0) { if ((status & IE_FD_OK) != 0) { printf("%s: rint: weird: ", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); i82586_rx_errors(sc, i, status); break; } @@ -558,7 +558,7 @@ static int timesthru = 1024; #if I82586_DEBUG if ((status & IE_FD_BUSY) != 0) printf("%s: rint: frame(%d) busy; status=0x%x\n", - device_xname(&sc->sc_dev), i, status); + device_xname(sc->sc_dev), i, status); #endif @@ -616,7 +616,7 @@ static int timesthru = 1024; scbstatus); if (i82586_start_cmd(sc, IE_RUC_RESUME, 0, 0, 0) == 0) return (0); - aprint_error_dev(&sc->sc_dev, "RU RESUME command timed out\n"); + aprint_error_dev(sc->sc_dev, "RU RESUME command timed out\n"); return (1); /* Ask for a reset */ } @@ -645,7 +645,7 @@ static int timesthru = 1024; return (0); } else printf("%s: receiver not ready; scbstatus=0x%x\n", - device_xname(&sc->sc_dev), scbstatus); + device_xname(sc->sc_dev), scbstatus); sc->sc_ethercom.ec_if.if_ierrors++; return (1); /* Ask for a reset */ @@ -682,7 +682,7 @@ i82586_tint(struct ie_softc *sc, int scbstatus) #if I82586_DEBUG if (sc->sc_debug & IED_TINT) printf("%s: tint: SCB status 0x%x; xmit status 0x%x\n", - device_xname(&sc->sc_dev), scbstatus, status); + device_xname(sc->sc_dev), scbstatus, status); #endif if ((status & IE_STAT_COMPL) == 0 || (status & IE_STAT_BUSY)) { @@ -701,15 +701,15 @@ i82586_tint(struct ie_softc *sc, int scbstatus) * What if more than one bit is set? */ if (status & IE_STAT_ABORT) - aprint_error_dev(&sc->sc_dev, "send aborted\n"); + aprint_error_dev(sc->sc_dev, "send aborted\n"); else if (status & IE_XS_NOCARRIER) - aprint_error_dev(&sc->sc_dev, "no carrier\n"); + aprint_error_dev(sc->sc_dev, "no carrier\n"); else if (status & IE_XS_LOSTCTS) - aprint_error_dev(&sc->sc_dev, "lost CTS\n"); + aprint_error_dev(sc->sc_dev, "lost CTS\n"); else if (status & IE_XS_UNDERRUN) - aprint_error_dev(&sc->sc_dev, "DMA underrun\n"); + aprint_error_dev(sc->sc_dev, "DMA underrun\n"); else if (status & IE_XS_EXCMAX) { - aprint_error_dev(&sc->sc_dev, "too many collisions\n"); + aprint_error_dev(sc->sc_dev, "too many collisions\n"); sc->sc_ethercom.ec_if.if_collisions += 16; } } @@ -763,7 +763,7 @@ i82586_get_rbd_list(struct ie_softc *sc, u_int16_t *start, u_int16_t *end, int * #endif log(LOG_ERR, "%s: receive descriptors out of sync at %d\n", - device_xname(&sc->sc_dev), rbindex); + device_xname(sc->sc_dev), rbindex); return (0); } plen += (rbdstatus & IE_RBD_CNTMASK); @@ -850,7 +850,7 @@ i82586_chk_rx_ring(struct ie_softc *sc) /* `rbtail' and EOL flag out of sync */ log(LOG_ERR, "%s: rx buffer descriptors out of sync at %d\n", - device_xname(&sc->sc_dev), n); + device_xname(sc->sc_dev), n); return (1); } @@ -864,7 +864,7 @@ i82586_chk_rx_ring(struct ie_softc *sc) /* `rftail' and EOL flag out of sync */ log(LOG_ERR, "%s: rx frame list out of sync at %d\n", - device_xname(&sc->sc_dev), n); + device_xname(sc->sc_dev), n); return (1); } } @@ -1026,7 +1026,7 @@ ie_readframe( struct ether_header *eh = mtod(m, struct ether_header *); printf("%s: frame from ether %s type 0x%x len %d\n", - device_xname(&sc->sc_dev), + device_xname(sc->sc_dev), ether_sprintf(eh->ether_shost), (u_int)ntohs(eh->ether_type), pktlen); @@ -1059,7 +1059,7 @@ iexmit(struct ie_softc *sc) #if I82586_DEBUG if (sc->sc_debug & IED_XMIT) - printf("%s: xmit buffer %d\n", device_xname(&sc->sc_dev), cur); + printf("%s: xmit buffer %d\n", device_xname(sc->sc_dev), cur); #endif /* @@ -1112,7 +1112,7 @@ iexmit(struct ie_softc *sc) IE_BUS_BARRIER(sc, off, 2, BUS_SPACE_BARRIER_READ); if (i82586_start_cmd(sc, IE_CUC_START, 0, 0, 1)) - aprint_error_dev(&sc->sc_dev, "iexmit: start xmit command timed out\n"); + aprint_error_dev(sc->sc_dev, "iexmit: start xmit command timed out\n"); } sc->sc_ethercom.ec_if.if_timer = 5; @@ -1156,12 +1156,12 @@ i82586_start(struct ifnet *ifp) #if I82586_DEBUG if (sc->sc_debug & IED_ENQ) - printf("%s: fill buffer %d\n", device_xname(&sc->sc_dev), + printf("%s: fill buffer %d\n", device_xname(sc->sc_dev), sc->xchead); #endif if (m0->m_pkthdr.len > IE_TBUF_SIZE) - printf("%s: tbuf overflow\n", device_xname(&sc->sc_dev)); + printf("%s: tbuf overflow\n", device_xname(sc->sc_dev)); buffer = IE_XBUF_ADDR(sc, head); for (m = m0; m != 0; m = m->m_next) { @@ -1244,7 +1244,7 @@ i82586_reset(struct ie_softc *sc, int hard) int s = splnet(); if (hard) - printf("%s: reset\n", device_xname(&sc->sc_dev)); + printf("%s: reset\n", device_xname(sc->sc_dev)); /* Clear OACTIVE in case we're called from watchdog (frozen xmit). */ sc->sc_ethercom.ec_if.if_timer = 0; @@ -1254,7 +1254,7 @@ i82586_reset(struct ie_softc *sc, int hard) * Stop i82586 dead in its tracks. */ if (i82586_start_cmd(sc, IE_RUC_ABORT | IE_CUC_ABORT, 0, 0, 0)) - aprint_error_dev(&sc->sc_dev, "abort commands timed out\n"); + aprint_error_dev(sc->sc_dev, "abort commands timed out\n"); /* * This can really slow down the i82586_reset() on some cards, but it's @@ -1314,17 +1314,17 @@ ie_run_tdr(struct ie_softc *sc, int cmd) return; if (result & 0x10000) - aprint_error_dev(&sc->sc_dev, "TDR command failed\n"); + aprint_error_dev(sc->sc_dev, "TDR command failed\n"); else if (result & IE_TDR_XCVR) - aprint_error_dev(&sc->sc_dev, "transceiver problem\n"); + aprint_error_dev(sc->sc_dev, "transceiver problem\n"); else if (result & IE_TDR_OPEN) - aprint_error_dev(&sc->sc_dev, "TDR detected incorrect termination %d clocks away\n", + aprint_error_dev(sc->sc_dev, "TDR detected incorrect termination %d clocks away\n", result & IE_TDR_TIME); else if (result & IE_TDR_SHORT) - aprint_error_dev(&sc->sc_dev, "TDR detected a short circuit %d clocks away\n", + aprint_error_dev(sc->sc_dev, "TDR detected a short circuit %d clocks away\n", result & IE_TDR_TIME); else - aprint_error_dev(&sc->sc_dev, "TDR returned unknown status 0x%x\n", + aprint_error_dev(sc->sc_dev, "TDR returned unknown status 0x%x\n", result); } @@ -1401,7 +1401,7 @@ i82586_setup_bufs(struct ie_softc *sc) ptr += sc->nrxbuf * IE_RBUF_SIZE; #if I82586_DEBUG - printf("%s: %d frames %d bufs\n", device_xname(&sc->sc_dev), sc->nframes, + printf("%s: %d frames %d bufs\n", device_xname(sc->sc_dev), sc->nframes, sc->nrxbuf); #endif @@ -1489,7 +1489,7 @@ i82586_setup_bufs(struct ie_softc *sc) /* link in recv frames * and buffer into the scb. */ #if I82586_DEBUG printf("%s: reserved %d bytes\n", - device_xname(&sc->sc_dev), ptr - sc->buf_area); + device_xname(sc->sc_dev), ptr - sc->buf_area); #endif } @@ -1518,11 +1518,11 @@ ie_cfg_setup(struct ie_softc *sc, int cmd, int promiscuous, int manchester) cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmd, IE_STAT_COMPL, 0); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmd)); if (cmdresult != 0) { - aprint_error_dev(&sc->sc_dev, "configure command timed out; status %x\n", status); + aprint_error_dev(sc->sc_dev, "configure command timed out; status %x\n", status); return (0); } if ((status & IE_STAT_OK) == 0) { - aprint_error_dev(&sc->sc_dev, "configure command failed; status %x\n", status); + aprint_error_dev(sc->sc_dev, "configure command failed; status %x\n", status); return (0); } @@ -1545,11 +1545,11 @@ ie_ia_setup(struct ie_softc *sc, int cmdbuf) cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf)); if (cmdresult != 0) { - aprint_error_dev(&sc->sc_dev, "individual address command timed out; status %x\n", status); + aprint_error_dev(sc->sc_dev, "individual address command timed out; status %x\n", status); return (0); } if ((status & IE_STAT_OK) == 0) { - aprint_error_dev(&sc->sc_dev, "individual address command failed; status %x\n", status); + aprint_error_dev(sc->sc_dev, "individual address command failed; status %x\n", status); return (0); } @@ -1583,11 +1583,11 @@ ie_mc_setup(struct ie_softc *sc, int cmdbuf) cmdresult = i82586_start_cmd(sc, IE_CUC_START, cmdbuf, IE_STAT_COMPL, 0); status = sc->ie_bus_read16(sc, IE_CMD_COMMON_STATUS(cmdbuf)); if (cmdresult != 0) { - aprint_error_dev(&sc->sc_dev, "multicast setup command timed out; status %x\n", status); + aprint_error_dev(sc->sc_dev, "multicast setup command timed out; status %x\n", status); return (0); } if ((status & IE_STAT_OK) == 0) { - aprint_error_dev(&sc->sc_dev, "multicast setup command failed; status %x\n", + aprint_error_dev(sc->sc_dev, "multicast setup command failed; status %x\n", status); return (0); } @@ -1680,7 +1680,7 @@ i82586_start_transceiver(struct ie_softc *sc) if (sc->do_xmitnopchain) { /* Stop transmit command chain */ if (i82586_start_cmd(sc, IE_CUC_SUSPEND|IE_RUC_SUSPEND, 0, 0, 0)) - aprint_error_dev(&sc->sc_dev, "CU/RU stop command timed out\n"); + aprint_error_dev(sc->sc_dev, "CU/RU stop command timed out\n"); /* Start the receiver & transmitter chain */ /* sc->scb->ie_command_list = @@ -1691,10 +1691,10 @@ i82586_start_transceiver(struct ie_softc *sc) (sc->xctail + NTXBUF - 1) % NTXBUF)); if (i82586_start_cmd(sc, IE_CUC_START|IE_RUC_START, 0, 0, 0)) - aprint_error_dev(&sc->sc_dev, "CU/RU command timed out\n"); + aprint_error_dev(sc->sc_dev, "CU/RU command timed out\n"); } else { if (i82586_start_cmd(sc, IE_RUC_START, 0, 0, 0)) - aprint_error_dev(&sc->sc_dev, "RU command timed out\n"); + aprint_error_dev(sc->sc_dev, "RU command timed out\n"); } } @@ -1706,7 +1706,7 @@ i82586_stop( struct ie_softc *sc = ifp->if_softc; if (i82586_start_cmd(sc, IE_RUC_SUSPEND | IE_CUC_SUSPEND, 0, 0, 0)) - aprint_error_dev(&sc->sc_dev, "iestop: disable commands timed out\n"); + aprint_error_dev(sc->sc_dev, "iestop: disable commands timed out\n"); } int diff --git a/sys/dev/ic/i82586var.h b/sys/dev/ic/i82586var.h index 3f9cbd4fe2e..ffb43c7b0b4 100644 --- a/sys/dev/ic/i82586var.h +++ b/sys/dev/ic/i82586var.h @@ -1,4 +1,4 @@ -/* $NetBSD: i82586var.h,v 1.22 2008/04/28 20:23:50 martin Exp $ */ +/* $NetBSD: i82586var.h,v 1.23 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -166,7 +166,7 @@ */ struct ie_softc { - struct device sc_dev; /* device structure */ + device_t sc_dev; /* device structure */ bus_space_tag_t bt; /* bus-space tag of card memory */ bus_space_handle_t bh; /* bus-space handle of card memory */ diff --git a/sys/dev/isa/if_ai.c b/sys/dev/isa/if_ai.c index daea63e358e..f812687c44d 100644 --- a/sys/dev/isa/if_ai.c +++ b/sys/dev/isa/if_ai.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ai.c,v 1.32 2009/05/12 09:10:15 cegger Exp $ */ +/* $NetBSD: if_ai.c,v 1.33 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.32 2009/05/12 09:10:15 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ai.c,v 1.33 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -304,7 +304,7 @@ out: void ai_attach(device_t parent, device_t self, void *aux) { - struct ai_softc *asc = (void *)self; + struct ai_softc *asc = device_private(self); struct ie_softc *sc = &asc->sc_ie; struct isa_attach_args *ia = aux; @@ -313,10 +313,12 @@ ai_attach(device_t parent, device_t self, void *aux) u_int8_t ethaddr[ETHER_ADDR_LEN]; char name[80]; + sc->sc_dev = self; + if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size, 0, &ioh) != 0) { DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), + device_xname(self), ia->ia_io[0].ir_addr, ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1)); return; @@ -325,7 +327,7 @@ ai_attach(device_t parent, device_t self, void *aux) if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_size, 0, &memh) != 0) { DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), + device_xname(self), ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_addr + ia->ia_iomem[0].ir_size - 1)); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); @@ -386,7 +388,7 @@ ai_attach(device_t parent, device_t self, void *aux) BUS_SPACE_BARRIER_WRITE); if (!i82586_proberam(sc)) { DPRINTF(("\n%s: can't talk to i82586!\n", - device_xname(&sc->sc_dev))); + device_xname(self))); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size); return; @@ -404,7 +406,7 @@ ai_attach(device_t parent, device_t self, void *aux) IST_EDGE, IPL_NET, i82586_intr, sc); if (asc->sc_ih == NULL) { DPRINTF(("\n%s: can't establish interrupt\n", - device_xname(&sc->sc_dev))); + device_xname(self))); } } @@ -475,5 +477,5 @@ check_ie_present(struct ie_softc* sc, bus_space_tag_t memt, bus_space_handle_t m return (size); } -CFATTACH_DECL(ai, sizeof(struct ai_softc), +CFATTACH_DECL_NEW(ai, sizeof(struct ai_softc), ai_match, ai_attach, NULL, NULL); diff --git a/sys/dev/isa/if_ef.c b/sys/dev/isa/if_ef.c index 2f357b1d906..46449e31448 100644 --- a/sys/dev/isa/if_ef.c +++ b/sys/dev/isa/if_ef.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ef.c,v 1.30 2009/05/12 09:10:15 cegger Exp $ */ +/* $NetBSD: if_ef.c,v 1.31 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.30 2009/05/12 09:10:15 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.31 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -472,7 +472,7 @@ ef_match(device_t parent, cfdata_t cf, void *aux) void ef_attach(device_t parent, device_t self, void *aux) { - struct ef_softc *esc = (void *)self; + struct ef_softc *esc = device_private(self); struct ie_softc *sc = &esc->sc_ie; struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; @@ -484,6 +484,7 @@ ef_attach(device_t parent, device_t self, void *aux) bus_space_handle_t ioh, memh; u_int8_t ethaddr[ETHER_ADDR_LEN]; + sc->sc_dev = self; sc->hwinit = ef_hwinit; sc->hwreset = ef_reset; sc->chan_attn = ef_atten; @@ -518,14 +519,14 @@ ef_attach(device_t parent, device_t self, void *aux) } if (bus == NULL) - panic("%s: Can't find parent bus!", device_xname(&sc->sc_dev)); + panic("%s: Can't find parent bus!", device_xname(self)); /* If the bus hasn't been transitioned to the RUN state, do so now */ if (bus->bus_state == 1) { if (bus_space_map(iot, ELINK_ID_PORT, 1, 0, &ioh) != 0) { DPRINTF(("\n%s: Can't map Elink ID port!\n", - device_xname(&sc->sc_dev))); + device_xname(self))); return; } @@ -542,7 +543,7 @@ ef_attach(device_t parent, device_t self, void *aux) ia->ia_io[0].ir_size, 0, &ioh) != 0) { DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), ia->ia_io[0].ir_addr, + device_xname(self), ia->ia_io[0].ir_addr, ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1)); return; } @@ -554,7 +555,7 @@ ef_attach(device_t parent, device_t self, void *aux) ia->ia_iomem[0].ir_size, 0, &memh) != 0) { DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), ia->ia_maddr, + device_xname(self), ia->ia_maddr, ia->ia_maddr + ia->ia_msize - 1)); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); return; @@ -592,7 +593,7 @@ ef_attach(device_t parent, device_t self, void *aux) BUS_SPACE_BARRIER_WRITE); if (!i82586_proberam(sc)) { DPRINTF(("\n%s: can't talk to i82586!\n", - device_xname(&sc->sc_dev))); + device_xname(self))); bus_space_unmap(ia->ia_iot, ioh, ia->ia_io[0].ir_size); bus_space_unmap(ia->ia_memt, memh, ia->ia_iomem[0].ir_size); return; @@ -644,7 +645,7 @@ ef_attach(device_t parent, device_t self, void *aux) IST_EDGE, IPL_NET, i82586_intr, sc); if (esc->sc_ih == NULL) { DPRINTF(("\n%s: can't establish interrupt\n", - device_xname(&sc->sc_dev))); + device_xname(self))); } } @@ -669,6 +670,6 @@ ef_port_check(bus_space_tag_t iot, bus_space_handle_t ioh) return 1; } -CFATTACH_DECL(ef, sizeof(struct ef_softc), +CFATTACH_DECL_NEW(ef, sizeof(struct ef_softc), ef_match, ef_attach, NULL, NULL); diff --git a/sys/dev/isa/if_ix.c b/sys/dev/isa/if_ix.c index 8535e894ca7..b64368b9bc7 100644 --- a/sys/dev/isa/if_ix.c +++ b/sys/dev/isa/if_ix.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ix.c,v 1.33 2009/05/12 09:10:15 cegger Exp $ */ +/* $NetBSD: if_ix.c,v 1.34 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.33 2009/05/12 09:10:15 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.34 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -674,7 +674,7 @@ out: void ix_attach(device_t parent, device_t self, void *aux) { - struct ix_softc *isc = (void *)self; + struct ix_softc *isc = device_private(self); struct ie_softc *sc = &isc->sc_ie; struct isa_attach_args *ia = aux; @@ -688,6 +688,7 @@ ix_attach(device_t parent, device_t self, void *aux) u_short irq_encoded; u_int8_t ethaddr[ETHER_ADDR_LEN]; + sc->sc_dev = self; iot = ia->ia_iot; /* @@ -701,7 +702,7 @@ ix_attach(device_t parent, device_t self, void *aux) ia->ia_io[0].ir_size, 0, &ioh) != 0) { DPRINTF(("\n%s: can't map i/o space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), ia->ia_[0].ir_addr, + device_xname(self), ia->ia_[0].ir_addr, ia->ia_io[0].ir_addr + ia->ia_io[0].ir_size - 1)); return; } @@ -711,7 +712,7 @@ ix_attach(device_t parent, device_t self, void *aux) if (bus_space_map(ia->ia_memt, ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_size, 0, &memh) != 0) { DPRINTF(("\n%s: can't map iomem space 0x%x-0x%x\n", - device_xname(&sc->sc_dev), ia->ia_iomem[0].ir_addr, + device_xname(self), ia->ia_iomem[0].ir_addr, ia->ia_iomem[0].ir_addr + ia->ia_iomem[0].ir_size - 1)); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); return; @@ -849,7 +850,7 @@ ix_attach(device_t parent, device_t self, void *aux) /* Memory tests failed, punt... */ if (memsize == 0) { DPRINTF(("\n%s: can't determine size of on-card RAM\n", - device_xname(&sc->sc_dev))); + device_xname(self))); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); return; } @@ -913,7 +914,7 @@ ix_attach(device_t parent, device_t self, void *aux) if (!i82586_proberam(sc)) { DPRINTF(("\n%s: Can't talk to i82586!\n", - device_xname(&sc->sc_dev))); + device_xname(self))); bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size); if (ia->ia_iomem[0].ir_size) @@ -957,15 +958,15 @@ ix_attach(device_t parent, device_t self, void *aux) ix_media, NIX_MEDIA, media); if (isc->use_pio) - aprint_error_dev(&sc->sc_dev, "unsupported memory config, using PIO to access %d bytes of memory\n", sc->sc_msize); + aprint_error_dev(self, "unsupported memory config, using PIO to access %d bytes of memory\n", sc->sc_msize); isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_NET, i82586_intr, sc); if (isc->sc_ih == NULL) { DPRINTF(("\n%s: can't establish interrupt\n", - device_xname(&sc->sc_dev))); + device_xname(self))); } } -CFATTACH_DECL(ix, sizeof(struct ix_softc), +CFATTACH_DECL_NEW(ix, sizeof(struct ix_softc), ix_match, ix_attach, NULL, NULL); diff --git a/sys/dev/mca/if_elmc_mca.c b/sys/dev/mca/if_elmc_mca.c index b665b63598f..a842df6ff37 100644 --- a/sys/dev/mca/if_elmc_mca.c +++ b/sys/dev/mca/if_elmc_mca.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_elmc_mca.c,v 1.29 2009/05/12 14:31:00 cegger Exp $ */ +/* $NetBSD: if_elmc_mca.c,v 1.30 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_elmc_mca.c,v 1.29 2009/05/12 14:31:00 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_elmc_mca.c,v 1.30 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -144,6 +144,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) return; } + sc->sc_dev = self; pbram_addr = ELMC_MADDR_BASE + (((pos2 & 0x18) >> 3) * 0x8000); printf(" slot %d irq %d: 3Com EtherLink/MC Ethernet Adapter (3C523)\n", @@ -151,7 +152,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) /* map the pio registers */ if (bus_space_map(ma->ma_iot, iobase, ELMC_IOADDR_SIZE, 0, &ioh)) { - aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n"); + aprint_error_dev(self, "unable to map i/o space\n"); return; } @@ -161,9 +162,9 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) * about. Just use the first 16K. */ if (bus_space_map(ma->ma_memt, pbram_addr, ELMC_MADDR_SIZE, 0, &memh)) { - aprint_error_dev(&sc->sc_dev, "unable to map memory space\n"); + aprint_error_dev(self, "unable to map memory space\n"); if (pbram_addr == 0xc0000) { - aprint_error_dev(&sc->sc_dev, "memory space 0xc0000 may conflict with vga\n"); + aprint_error_dev(self, "memory space 0xc0000 may conflict with vga\n"); } bus_space_unmap(ma->ma_iot, ioh, ELMC_IOADDR_SIZE); @@ -234,7 +235,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) bus_space_barrier(sc->bt, sc->bh, 0, sc->sc_msize, BUS_SPACE_BARRIER_WRITE); if (!i82586_proberam(sc)) { - aprint_error_dev(&sc->sc_dev, "can't talk to i82586!\n"); + aprint_error_dev(self, "can't talk to i82586!\n"); bus_space_unmap(asc->sc_regt, asc->sc_regh, ELMC_IOADDR_SIZE); bus_space_unmap(sc->bt, sc->bh, ELMC_MADDR_SIZE); @@ -247,7 +248,7 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) /* dump known info */ printf("%s: rev %d, i/o %#04x-%#04x, mem %#06x-%#06x, %sternal xcvr\n", - device_xname(&sc->sc_dev), revision, + device_xname(self), revision, iobase, iobase + ELMC_IOADDR_SIZE - 1, pbram_addr, pbram_addr + ELMC_MADDR_SIZE - 1, (pos2 & 0x20) ? "ex" : "in"); @@ -259,14 +260,14 @@ elmc_mca_attach(device_t parent, device_t self, void *aux) for(i=0; i < MIN(6, ETHER_ADDR_LEN); i++) myaddr[i] = bus_space_read_1(asc->sc_regt, asc->sc_regh, i); - printf("%s:", device_xname(&sc->sc_dev)); - i82586_attach((void *)sc, "3C523", myaddr, NULL, 0, 0); + printf("%s:", device_xname(self)); + i82586_attach(sc, "3C523", myaddr, NULL, 0, 0); /* establish interrupt handler */ asc->sc_ih = mca_intr_establish(ma->ma_mc, irq, IPL_NET, i82586_intr, sc); if (asc->sc_ih == NULL) { - aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt handler\n"); + aprint_error_dev(self, "couldn't establish interrupt handler\n"); return; } } @@ -405,5 +406,5 @@ elmc_mca_intrhook(struct ie_softc *sc, int why) return (0); } -CFATTACH_DECL(elmc_mca, sizeof(struct elmc_mca_softc), +CFATTACH_DECL_NEW(elmc_mca, sizeof(struct elmc_mca_softc), elmc_mca_match, elmc_mca_attach, NULL, NULL); diff --git a/sys/dev/podulebus/if_ei.c b/sys/dev/podulebus/if_ei.c index 3e80aeffb0b..8d1392be752 100644 --- a/sys/dev/podulebus/if_ei.c +++ b/sys/dev/podulebus/if_ei.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ei.c,v 1.16 2009/05/12 14:42:58 cegger Exp $ */ +/* $NetBSD: if_ei.c,v 1.17 2011/06/03 16:28:40 tsutsui Exp $ */ /*- * Copyright (c) 2000, 2001 Ben Harris @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ei.c,v 1.16 2009/05/12 14:42:58 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ei.c,v 1.17 2011/06/03 16:28:40 tsutsui Exp $"); #include <sys/param.h> @@ -85,7 +85,7 @@ struct ei_softc { struct evcnt sc_intrcnt; }; -CFATTACH_DECL(ei, sizeof(struct ei_softc), +CFATTACH_DECL_NEW(ei, sizeof(struct ei_softc), ei_match, ei_attach, NULL, NULL); static inline void @@ -118,6 +118,8 @@ ei_attach(device_t parent, device_t self, void *aux) int i; char descr[16]; + sc->sc_ie.sc_dev = self; + /* Set up bus spaces */ sc->sc_ctl_t = sc->sc_mem_t = pa->pa_fast_t; bus_space_map(pa->pa_fast_t, pa->pa_fast_base, EI_MEMOFF, 0, @@ -252,7 +254,7 @@ ei_copyin(struct ie_softc *sc_ie, void *dest, int src, size_t size) #ifdef DIAGNOSTIC if (src % 2 != 0 || !ALIGNED_POINTER(dest, u_int16_t)) - panic("%s: unaligned copyin", device_xname(&sc_ie->sc_dev)); + panic("%s: unaligned copyin", device_xname(sc_ie->sc_dev)); #endif wptr = dest; extra_byte = size % 2; @@ -292,13 +294,13 @@ ei_copyout(struct ie_softc *sc_ie, const void *src, int dest, size_t size) #ifdef DIAGNOSTIC if (dest % 2 != 0) - panic("%s: unaligned copyout", device_xname(&sc_ie->sc_dev)); + panic("%s: unaligned copyout", device_xname(sc_ie->sc_dev)); #endif if (!ALIGNED_POINTER(src, u_int16_t)) { bounce = (u_int16_t *) malloc(size, M_DEVBUF, M_NOWAIT); if (bounce == NULL) panic("%s: no memory to align copyout", - device_xname(&sc_ie->sc_dev)); + device_xname(sc_ie->sc_dev)); memcpy(bounce, src, size); src = bounce; } @@ -331,7 +333,7 @@ ei_read16(struct ie_softc *sc_ie, int addr) #ifdef DIAGNOSTIC if (addr % 2 != 0) - panic("%s: unaligned read16", device_xname(&sc_ie->sc_dev)); + panic("%s: unaligned read16", device_xname(sc_ie->sc_dev)); #endif s = splnet(); ei_setpage(sc, ei_atop(addr)); @@ -349,7 +351,7 @@ ei_write16(struct ie_softc *sc_ie, int addr, u_int16_t value) #ifdef DIAGNOSTIC if (addr % 2 != 0) - panic("%s: unaligned write16", device_xname(&sc_ie->sc_dev)); + panic("%s: unaligned write16", device_xname(sc_ie->sc_dev)); #endif s = splnet(); ei_setpage(sc, ei_atop(addr)); @@ -365,7 +367,7 @@ ei_write24(struct ie_softc *sc_ie, int addr, int value) #ifdef DIAGNOSTIC if (addr % 2 != 0) - panic("%s: unaligned write24", device_xname(&sc_ie->sc_dev)); + panic("%s: unaligned write24", device_xname(sc_ie->sc_dev)); #endif s = splnet(); ei_write16(sc_ie, addr, value & 0xffff); diff --git a/sys/dev/vme/if_ie_vme.c b/sys/dev/vme/if_ie_vme.c index 70905ec1e2a..a4c81843cd6 100644 --- a/sys/dev/vme/if_ie_vme.c +++ b/sys/dev/vme/if_ie_vme.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie_vme.c,v 1.29 2011/02/01 19:36:24 chuck Exp $ */ +/* $NetBSD: if_ie_vme.c,v 1.30 2011/06/03 16:28:41 tsutsui Exp $ */ /* * Copyright (c) 1995 Charles D. Cranor @@ -140,7 +140,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.29 2011/02/01 19:36:24 chuck Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.30 2011/06/03 16:28:41 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -239,7 +239,7 @@ struct ie_vme_softc { bus_space_handle_t ievh; }; -CFATTACH_DECL(ie_vme, sizeof(struct ie_vme_softc), +CFATTACH_DECL_NEW(ie_vme, sizeof(struct ie_vme_softc), ie_vme_match, ie_vme_attach, NULL, NULL); #define read_iev(sc, reg) \ @@ -291,7 +291,7 @@ ie_vmeintr(struct ie_softc *sc, int where) * check for parity error */ if (read_iev(vsc, status) & IEVME_PERR) { - aprint_error_dev(&sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n", + aprint_error_dev(sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n", read_iev(vsc, pectrl), read_iev(vsc, pectrl) & IEVME_HADDR, read_iev(vsc, peaddr)); @@ -459,7 +459,7 @@ void ie_vme_attach(device_t parent, device_t self, void *aux) { u_int8_t myaddr[ETHER_ADDR_LEN]; - struct ie_vme_softc *vsc = (void *) self; + struct ie_vme_softc *vsc = device_private(self); struct vme_attach_args *va = aux; vme_chipset_tag_t ct = va->va_vct; struct ie_softc *sc; @@ -484,6 +484,7 @@ ie_vme_attach(device_t parent, device_t self, void *aux) panic("if_ie: vme alloc"); sc = &vsc->ie; + sc->sc_dev = self; sc->hwreset = ie_vmereset; sc->hwinit = ie_vmerun; |
