Module Name: src Committed By: drochner Date: Sat Feb 18 13:38:36 UTC 2012
Modified Files: src/sys/dev/cardbus: if_ral_cardbus.c src/sys/dev/ic: rt2560.c rt2560var.h rt2661.c rt2661var.h src/sys/dev/pci: if_ral_pci.c Log Message: split device_t/softc To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/cardbus/if_ral_cardbus.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ic/rt2560.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/rt2560var.h cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/rt2661.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/rt2661var.h cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_ral_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_ral_cardbus.c diff -u src/sys/dev/cardbus/if_ral_cardbus.c:1.22 src/sys/dev/cardbus/if_ral_cardbus.c:1.23 --- src/sys/dev/cardbus/if_ral_cardbus.c:1.22 Mon Aug 1 11:20:27 2011 +++ src/sys/dev/cardbus/if_ral_cardbus.c Sat Feb 18 13:38:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ral_cardbus.c,v 1.22 2011/08/01 11:20:27 drochner Exp $ */ +/* $NetBSD: if_ral_cardbus.c,v 1.23 2012/02/18 13:38:35 drochner Exp $ */ /* $OpenBSD: if_ral_cardbus.c,v 1.6 2006/01/09 20:03:31 damien Exp $ */ /*- @@ -22,7 +22,7 @@ * CardBus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.22 2011/08/01 11:20:27 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.23 2012/02/18 13:38:35 drochner Exp $"); #include <sys/param.h> @@ -95,7 +95,7 @@ int ral_cardbus_match(device_t, cfdata_t void ral_cardbus_attach(device_t, device_t, void *); int ral_cardbus_detach(device_t, int); -CFATTACH_DECL(ral_cardbus, sizeof (struct ral_cardbus_softc), +CFATTACH_DECL_NEW(ral_cardbus, sizeof (struct ral_cardbus_softc), ral_cardbus_match, ral_cardbus_attach, ral_cardbus_detach, NULL); int ral_cardbus_enable(struct rt2560_softc *); @@ -128,7 +128,7 @@ void ral_cardbus_attach(device_t parent, device_t self, void *aux) { - struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self; + struct ral_cardbus_softc *csc = device_private(self); struct rt2560_softc *sc = &csc->sc_sc; struct cardbus_attach_args *ca = aux; cardbus_devfunc_t ct = ca->ca_ct; @@ -144,6 +144,7 @@ ral_cardbus_attach(device_t parent, devi (PCI_PRODUCT(ca->ca_id) == PCI_PRODUCT_RALINK_RT2560) ? &ral_rt2560_opns : &ral_rt2661_opns; + sc->sc_dev = self; sc->sc_dmat = ca->ca_dmat; csc->sc_ct = ct; csc->sc_tag = ca->ca_tag; @@ -174,7 +175,7 @@ ral_cardbus_attach(device_t parent, devi int ral_cardbus_detach(device_t self, int flags) { - struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self; + struct ral_cardbus_softc *csc = device_private(self); struct rt2560_softc *sc = &csc->sc_sc; cardbus_devfunc_t ct = csc->sc_ct; int error; @@ -212,7 +213,7 @@ ral_cardbus_enable(struct rt2560_softc * csc->sc_ih = Cardbus_intr_establish(ct, IPL_NET, csc->sc_opns->intr, sc); if (csc->sc_ih == NULL) { - aprint_error_dev(&sc->sc_dev, + aprint_error_dev(sc->sc_dev, "could not establish interrupt\n"); Cardbus_function_disable(ct); return 1; Index: src/sys/dev/ic/rt2560.c diff -u src/sys/dev/ic/rt2560.c:1.24 src/sys/dev/ic/rt2560.c:1.25 --- src/sys/dev/ic/rt2560.c:1.24 Sun Jun 13 03:08:15 2010 +++ src/sys/dev/ic/rt2560.c Sat Feb 18 13:38:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560.c,v 1.24 2010/06/13 03:08:15 tsutsui Exp $ */ +/* $NetBSD: rt2560.c,v 1.25 2012/02/18 13:38:35 drochner Exp $ */ /* $OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $ */ /* $FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/ @@ -24,7 +24,7 @@ * http://www.ralinktech.com/ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.24 2010/06/13 03:08:15 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.25 2012/02/18 13:38:35 drochner Exp $"); #include <sys/param.h> @@ -344,13 +344,13 @@ rt2560_attach(void *xsc, int id) /* retrieve MAC address */ rt2560_get_macaddr(sc, ic->ic_myaddr); - aprint_normal_dev(&sc->sc_dev, "802.11 address %s\n", + aprint_normal_dev(sc->sc_dev, "802.11 address %s\n", ether_sprintf(ic->ic_myaddr)); /* retrieve RF rev. no and various other things from EEPROM */ rt2560_read_eeprom(sc); - aprint_normal_dev(&sc->sc_dev, "MAC/BBP RT2560 (rev 0x%02x), RF %s\n", + aprint_normal_dev(sc->sc_dev, "MAC/BBP RT2560 (rev 0x%02x), RF %s\n", sc->asic_rev, rt2560_get_rf(sc->rf_rev)); /* @@ -358,31 +358,31 @@ rt2560_attach(void *xsc, int id) */ error = rt2560_alloc_tx_ring(sc, &sc->txq, RT2560_TX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Tx ring\n)"); + aprint_error_dev(sc->sc_dev, "could not allocate Tx ring\n)"); goto fail1; } error = rt2560_alloc_tx_ring(sc, &sc->atimq, RT2560_ATIM_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate ATIM ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate ATIM ring\n"); goto fail2; } error = rt2560_alloc_tx_ring(sc, &sc->prioq, RT2560_PRIO_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Prio ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Prio ring\n"); goto fail3; } error = rt2560_alloc_tx_ring(sc, &sc->bcnq, RT2560_BEACON_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Beacon ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Beacon ring\n"); goto fail4; } error = rt2560_alloc_rx_ring(sc, &sc->rxq, RT2560_RX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Rx ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Rx ring\n"); goto fail5; } @@ -394,7 +394,7 @@ rt2560_attach(void *xsc, int id) ifp->if_start = rt2560_start; ifp->if_watchdog = rt2560_watchdog; IFQ_SET_READY(&ifp->if_snd); - memcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); + memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); ic->ic_ifp = ifp; ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ @@ -473,10 +473,10 @@ rt2560_attach(void *xsc, int id) ieee80211_announce(ic); - if (pmf_device_register(&sc->sc_dev, NULL, NULL)) - pmf_class_network_register(&sc->sc_dev, ifp); + if (pmf_device_register(sc->sc_dev, NULL, NULL)) + pmf_class_network_register(sc->sc_dev, ifp); else - aprint_error_dev(&sc->sc_dev, + aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); return 0; @@ -499,7 +499,7 @@ rt2560_detach(void *xsc) callout_stop(&sc->scan_ch); callout_stop(&sc->rssadapt_ch); - pmf_device_deregister(&sc->sc_dev); + pmf_device_deregister(sc->sc_dev); rt2560_stop(ifp, 1); @@ -529,14 +529,14 @@ rt2560_alloc_tx_ring(struct rt2560_softc error = bus_dmamap_create(sc->sc_dmat, count * RT2560_TX_DESC_SIZE, 1, count * RT2560_TX_DESC_SIZE, 0, BUS_DMA_NOWAIT, &ring->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create desc DMA map\n"); goto fail; } error = bus_dmamem_alloc(sc->sc_dmat, count * RT2560_TX_DESC_SIZE, PAGE_SIZE, 0, &ring->seg, 1, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not allocate DMA memory\n"); goto fail; } @@ -544,14 +544,14 @@ rt2560_alloc_tx_ring(struct rt2560_softc count * RT2560_TX_DESC_SIZE, (void **)&ring->desc, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map desc DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not map desc DMA memory\n"); goto fail; } error = bus_dmamap_load(sc->sc_dmat, ring->map, ring->desc, count * RT2560_TX_DESC_SIZE, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not load desc DMA map\n"); goto fail; } @@ -561,7 +561,7 @@ rt2560_alloc_tx_ring(struct rt2560_softc ring->data = malloc(count * sizeof (struct rt2560_tx_data), M_DEVBUF, M_NOWAIT); if (ring->data == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate soft data\n"); + aprint_error_dev(sc->sc_dev, "could not allocate soft data\n"); error = ENOMEM; goto fail; } @@ -572,7 +572,7 @@ rt2560_alloc_tx_ring(struct rt2560_softc RT2560_MAX_SCATTER, MCLBYTES, 0, BUS_DMA_NOWAIT, &ring->data[i].map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create DMA map\n"); goto fail; } } @@ -671,14 +671,14 @@ rt2560_alloc_rx_ring(struct rt2560_softc error = bus_dmamap_create(sc->sc_dmat, count * RT2560_RX_DESC_SIZE, 1, count * RT2560_RX_DESC_SIZE, 0, BUS_DMA_NOWAIT, &ring->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create desc DMA map\n"); goto fail; } error = bus_dmamem_alloc(sc->sc_dmat, count * RT2560_RX_DESC_SIZE, PAGE_SIZE, 0, &ring->seg, 1, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not allocate DMA memory\n"); goto fail; } @@ -686,14 +686,14 @@ rt2560_alloc_rx_ring(struct rt2560_softc count * RT2560_RX_DESC_SIZE, (void **)&ring->desc, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map desc DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not map desc DMA memory\n"); goto fail; } error = bus_dmamap_load(sc->sc_dmat, ring->map, ring->desc, count * RT2560_RX_DESC_SIZE, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not load desc DMA map\n"); goto fail; } @@ -703,7 +703,7 @@ rt2560_alloc_rx_ring(struct rt2560_softc ring->data = malloc(count * sizeof (struct rt2560_rx_data), M_DEVBUF, M_NOWAIT); if (ring->data == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate soft data\n"); + aprint_error_dev(sc->sc_dev, "could not allocate soft data\n"); error = ENOMEM; goto fail; } @@ -719,20 +719,20 @@ rt2560_alloc_rx_ring(struct rt2560_softc error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, BUS_DMA_NOWAIT, &data->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create DMA map\n"); goto fail; } MGETHDR(data->m, M_DONTWAIT, MT_DATA); if (data->m == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf\n"); + aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf\n"); error = ENOMEM; goto fail; } MCLGET(data->m, M_DONTWAIT); if (!(data->m->m_flags & M_EXT)) { - aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf cluster\n"); + aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf cluster\n"); error = ENOMEM; goto fail; } @@ -740,7 +740,7 @@ rt2560_alloc_rx_ring(struct rt2560_softc error = bus_dmamap_load(sc->sc_dmat, data->map, mtod(data->m, void *), MCLBYTES, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load rx buf DMA map"); + aprint_error_dev(sc->sc_dev, "could not load rx buf DMA map"); goto fail; } @@ -928,7 +928,7 @@ rt2560_newstate(struct ieee80211com *ic, ic->ic_opmode == IEEE80211_M_IBSS) { m = ieee80211_beacon_alloc(ic, ni, &sc->sc_bo); if (m == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate beacon\n"); + aprint_error_dev(sc->sc_dev, "could not allocate beacon\n"); error = ENOBUFS; break; } @@ -1112,7 +1112,7 @@ rt2560_tx_intr(struct rt2560_softc *sc) case RT2560_TX_FAIL_INVALID: case RT2560_TX_FAIL_OTHER: default: - aprint_error_dev(&sc->sc_dev, "sending data frame failed 0x%08x\n", + aprint_error_dev(sc->sc_dev, "sending data frame failed 0x%08x\n", le32toh(desc->flags)); ifp->if_oerrors++; } @@ -1181,7 +1181,7 @@ rt2560_prio_intr(struct rt2560_softc *sc case RT2560_TX_FAIL_INVALID: case RT2560_TX_FAIL_OTHER: default: - aprint_error_dev(&sc->sc_dev, "sending mgt frame failed 0x%08x\n", + aprint_error_dev(sc->sc_dev, "sending mgt frame failed 0x%08x\n", le32toh(desc->flags)); } @@ -1291,7 +1291,7 @@ rt2560_decryption_intr(struct rt2560_sof if (error != 0) { /* very unlikely that it will fail... */ panic("%s: could not load old rx mbuf", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); } /* physical address may have changed */ desc->physaddr = htole32(data->map->dm_segs->ds_addr); @@ -1466,7 +1466,7 @@ rt2560_intr(void *arg) struct ifnet *ifp = &sc->sc_if; uint32_t r; - if (!device_is_active(&sc->sc_dev)) + if (!device_is_active(sc->sc_dev)) return 0; if ((r = RAL_READ(sc, RT2560_CSR7)) == 0) @@ -1696,7 +1696,7 @@ rt2560_tx_bcn(struct rt2560_softc *sc, s error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -1752,7 +1752,7 @@ rt2560_tx_mgt(struct rt2560_softc *sc, s error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -1822,7 +1822,7 @@ rt2560_get_rts(struct rt2560_softc *sc, MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { sc->sc_ic.ic_stats.is_tx_nobuf++; - aprint_error_dev(&sc->sc_dev, "could not allocate RTS frame\n"); + aprint_error_dev(sc->sc_dev, "could not allocate RTS frame\n"); return NULL; } @@ -1907,7 +1907,7 @@ rt2560_tx_data(struct rt2560_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m); m_freem(m0); @@ -1951,7 +1951,7 @@ rt2560_tx_data(struct rt2560_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0 && error != EFBIG) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -1983,7 +1983,7 @@ rt2560_tx_data(struct rt2560_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -2130,7 +2130,7 @@ rt2560_watchdog(struct ifnet *ifp) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { - aprint_error_dev(&sc->sc_dev, "device timeout\n"); + aprint_error_dev(sc->sc_dev, "device timeout\n"); rt2560_init(ifp); ifp->if_oerrors++; return; @@ -2233,7 +2233,7 @@ rt2560_bbp_write(struct rt2560_softc *sc DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "could not write to BBP\n"); + aprint_error_dev(sc->sc_dev, "could not write to BBP\n"); return; } @@ -2259,7 +2259,7 @@ rt2560_bbp_read(struct rt2560_softc *sc, DELAY(1); } - aprint_error_dev(&sc->sc_dev, "could not read from BBP\n"); + aprint_error_dev(sc->sc_dev, "could not read from BBP\n"); return 0; } @@ -2275,7 +2275,7 @@ rt2560_rf_write(struct rt2560_softc *sc, DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "could not write to RF\n"); + aprint_error_dev(sc->sc_dev, "could not write to RF\n"); return; } @@ -2701,7 +2701,7 @@ rt2560_bbp_init(struct rt2560_softc *sc) DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "timeout waiting for BBP\n"); + aprint_error_dev(sc->sc_dev, "timeout waiting for BBP\n"); return EIO; } @@ -2735,7 +2735,7 @@ rt2560_init(struct ifnet *ifp) /* for CardBus, power on the socket */ if (!(sc->sc_flags & RT2560_ENABLED)) { if (sc->sc_enable != NULL && (*sc->sc_enable)(sc) != 0) { - aprint_error_dev(&sc->sc_dev, "could not enable device\n"); + aprint_error_dev(sc->sc_dev, "could not enable device\n"); return EIO; } sc->sc_flags |= RT2560_ENABLED; Index: src/sys/dev/ic/rt2560var.h diff -u src/sys/dev/ic/rt2560var.h:1.8 src/sys/dev/ic/rt2560var.h:1.9 --- src/sys/dev/ic/rt2560var.h:1.8 Tue Jan 19 22:06:25 2010 +++ src/sys/dev/ic/rt2560var.h Sat Feb 18 13:38:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560var.h,v 1.8 2010/01/19 22:06:25 pooka Exp $ */ +/* $NetBSD: rt2560var.h,v 1.9 2012/02/18 13:38:36 drochner Exp $ */ /* $OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $ */ /*- @@ -97,7 +97,7 @@ struct rt2560_node { }; struct rt2560_softc { - struct device sc_dev; + device_t sc_dev; struct ieee80211com sc_ic; int (*sc_newstate)(struct ieee80211com *, Index: src/sys/dev/ic/rt2661.c diff -u src/sys/dev/ic/rt2661.c:1.28 src/sys/dev/ic/rt2661.c:1.29 --- src/sys/dev/ic/rt2661.c:1.28 Mon Apr 5 07:19:36 2010 +++ src/sys/dev/ic/rt2661.c Sat Feb 18 13:38:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661.c,v 1.28 2010/04/05 07:19:36 joerg Exp $ */ +/* $NetBSD: rt2661.c,v 1.29 2012/02/18 13:38:36 drochner Exp $ */ /* $OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $ */ /* $FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $ */ @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.28 2010/04/05 07:19:36 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.29 2012/02/18 13:38:36 drochner Exp $"); #include <sys/param.h> @@ -224,16 +224,16 @@ rt2661_attach(void *xsc, int id) DELAY(1000); } if (ntries == 1000) { - aprint_error_dev(&sc->sc_dev, "timeout waiting for NIC to initialize\n"); + aprint_error_dev(sc->sc_dev, "timeout waiting for NIC to initialize\n"); return EIO; } /* retrieve RF rev. no and various other things from EEPROM */ rt2661_read_eeprom(sc); - aprint_normal_dev(&sc->sc_dev, "802.11 address %s\n", + aprint_normal_dev(sc->sc_dev, "802.11 address %s\n", ether_sprintf(ic->ic_myaddr)); - aprint_normal_dev(&sc->sc_dev, "MAC/BBP RT%X, RF %s\n", val, + aprint_normal_dev(sc->sc_dev, "MAC/BBP RT%X, RF %s\n", val, rt2661_get_rf(sc->rf_rev)); /* @@ -241,37 +241,37 @@ rt2661_attach(void *xsc, int id) */ error = rt2661_alloc_tx_ring(sc, &sc->txq[0], RT2661_TX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Tx ring 0\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Tx ring 0\n"); goto fail1; } error = rt2661_alloc_tx_ring(sc, &sc->txq[1], RT2661_TX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Tx ring 1\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Tx ring 1\n"); goto fail2; } error = rt2661_alloc_tx_ring(sc, &sc->txq[2], RT2661_TX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Tx ring 2\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Tx ring 2\n"); goto fail3; } error = rt2661_alloc_tx_ring(sc, &sc->txq[3], RT2661_TX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Tx ring 3\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Tx ring 3\n"); goto fail4; } error = rt2661_alloc_tx_ring(sc, &sc->mgtq, RT2661_MGT_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Mgt ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Mgt ring\n"); goto fail5; } error = rt2661_alloc_rx_ring(sc, &sc->rxq, RT2661_RX_RING_COUNT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate Rx ring\n"); + aprint_error_dev(sc->sc_dev, "could not allocate Rx ring\n"); goto fail6; } @@ -283,7 +283,7 @@ rt2661_attach(void *xsc, int id) ifp->if_start = rt2661_start; ifp->if_watchdog = rt2661_watchdog; IFQ_SET_READY(&ifp->if_snd); - memcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ); + memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); ic->ic_ifp = ifp; ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ @@ -361,10 +361,10 @@ rt2661_attach(void *xsc, int id) ieee80211_announce(ic); - if (pmf_device_register(&sc->sc_dev, NULL, NULL)) - pmf_class_network_register(&sc->sc_dev, ifp); + if (pmf_device_register(sc->sc_dev, NULL, NULL)) + pmf_class_network_register(sc->sc_dev, ifp); else - aprint_error_dev(&sc->sc_dev, + aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); return 0; @@ -386,7 +386,7 @@ rt2661_detach(void *xsc) callout_stop(&sc->scan_ch); callout_stop(&sc->amrr_ch); - pmf_device_deregister(&sc->sc_dev); + pmf_device_deregister(sc->sc_dev); ieee80211_ifdetach(&sc->sc_ic); if_detach(ifp); @@ -414,14 +414,14 @@ rt2661_alloc_tx_ring(struct rt2661_softc error = bus_dmamap_create(sc->sc_dmat, count * RT2661_TX_DESC_SIZE, 1, count * RT2661_TX_DESC_SIZE, 0, BUS_DMA_NOWAIT, &ring->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create desc DMA map\n"); goto fail; } error = bus_dmamem_alloc(sc->sc_dmat, count * RT2661_TX_DESC_SIZE, PAGE_SIZE, 0, &ring->seg, 1, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not allocate DMA memory\n"); goto fail; } @@ -429,14 +429,14 @@ rt2661_alloc_tx_ring(struct rt2661_softc count * RT2661_TX_DESC_SIZE, (void **)&ring->desc, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map desc DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not map desc DMA memory\n"); goto fail; } error = bus_dmamap_load(sc->sc_dmat, ring->map, ring->desc, count * RT2661_TX_DESC_SIZE, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not load desc DMA map\n"); goto fail; } @@ -446,7 +446,7 @@ rt2661_alloc_tx_ring(struct rt2661_softc ring->data = malloc(count * sizeof (struct rt2661_tx_data), M_DEVBUF, M_NOWAIT); if (ring->data == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate soft data\n"); + aprint_error_dev(sc->sc_dev, "could not allocate soft data\n"); error = ENOMEM; goto fail; } @@ -457,7 +457,7 @@ rt2661_alloc_tx_ring(struct rt2661_softc RT2661_MAX_SCATTER, MCLBYTES, 0, BUS_DMA_NOWAIT, &ring->data[i].map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create DMA map\n"); goto fail; } } @@ -554,14 +554,14 @@ rt2661_alloc_rx_ring(struct rt2661_softc error = bus_dmamap_create(sc->sc_dmat, count * RT2661_RX_DESC_SIZE, 1, count * RT2661_RX_DESC_SIZE, 0, BUS_DMA_NOWAIT, &ring->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create desc DMA map\n"); goto fail; } error = bus_dmamem_alloc(sc->sc_dmat, count * RT2661_RX_DESC_SIZE, PAGE_SIZE, 0, &ring->seg, 1, &nsegs, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not allocate DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not allocate DMA memory\n"); goto fail; } @@ -569,14 +569,14 @@ rt2661_alloc_rx_ring(struct rt2661_softc count * RT2661_RX_DESC_SIZE, (void **)&ring->desc, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map desc DMA memory\n"); + aprint_error_dev(sc->sc_dev, "could not map desc DMA memory\n"); goto fail; } error = bus_dmamap_load(sc->sc_dmat, ring->map, ring->desc, count * RT2661_RX_DESC_SIZE, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load desc DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not load desc DMA map\n"); goto fail; } @@ -586,7 +586,7 @@ rt2661_alloc_rx_ring(struct rt2661_softc ring->data = malloc(count * sizeof (struct rt2661_rx_data), M_DEVBUF, M_NOWAIT); if (ring->data == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate soft data\n"); + aprint_error_dev(sc->sc_dev, "could not allocate soft data\n"); error = ENOMEM; goto fail; } @@ -602,20 +602,20 @@ rt2661_alloc_rx_ring(struct rt2661_softc error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, BUS_DMA_NOWAIT, &data->map); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not create DMA map\n"); + aprint_error_dev(sc->sc_dev, "could not create DMA map\n"); goto fail; } MGETHDR(data->m, M_DONTWAIT, MT_DATA); if (data->m == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf\n"); + aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf\n"); error = ENOMEM; goto fail; } MCLGET(data->m, M_DONTWAIT); if (!(data->m->m_flags & M_EXT)) { - aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf cluster\n"); + aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf cluster\n"); error = ENOMEM; goto fail; } @@ -623,7 +623,7 @@ rt2661_alloc_rx_ring(struct rt2661_softc error = bus_dmamap_load(sc->sc_dmat, data->map, mtod(data->m, void *), MCLBYTES, NULL, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not load rx buf DMA map"); + aprint_error_dev(sc->sc_dev, "could not load rx buf DMA map"); goto fail; } @@ -957,7 +957,7 @@ rt2661_tx_intr(struct rt2661_softc *sc) default: /* other failure */ - aprint_error_dev(&sc->sc_dev, "sending data frame failed 0x%08x\n", val); + aprint_error_dev(sc->sc_dev, "sending data frame failed 0x%08x\n", val); ifp->if_oerrors++; } @@ -1091,7 +1091,7 @@ rt2661_rx_intr(struct rt2661_softc *sc) if (error != 0) { /* very unlikely that it will fail... */ panic("%s: could not load old rx mbuf", - device_xname(&sc->sc_dev)); + device_xname(sc->sc_dev)); } /* physical address may have changed */ desc->physaddr = htole32(data->map->dm_segs->ds_addr); @@ -1494,7 +1494,7 @@ rt2661_tx_mgt(struct rt2661_softc *sc, s error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -1562,7 +1562,7 @@ rt2661_get_rts(struct rt2661_softc *sc, MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { sc->sc_ic.ic_stats.is_tx_nobuf++; - aprint_error_dev(&sc->sc_dev, "could not allocate RTS frame\n"); + aprint_error_dev(sc->sc_dev, "could not allocate RTS frame\n"); return NULL; } @@ -1651,7 +1651,7 @@ rt2661_tx_data(struct rt2661_softc *sc, m = rt2661_get_rts(sc, wh, dur); if (m == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate RTS " + aprint_error_dev(sc->sc_dev, "could not allocate RTS " "frame\n"); m_freem(m0); return ENOBUFS; @@ -1663,7 +1663,7 @@ rt2661_tx_data(struct rt2661_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", error); + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m); m_freem(m0); return error; @@ -1697,7 +1697,7 @@ rt2661_tx_data(struct rt2661_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0 && error != EFBIG) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; @@ -1729,7 +1729,7 @@ rt2661_tx_data(struct rt2661_softc *sc, error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); if (error != 0) { - aprint_error_dev(&sc->sc_dev, "could not map mbuf (error %d)\n", error); + aprint_error_dev(sc->sc_dev, "could not map mbuf (error %d)\n", error); m_freem(m0); return error; } @@ -1867,7 +1867,7 @@ rt2661_watchdog(struct ifnet *ifp) if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { - aprint_error_dev(&sc->sc_dev, "device timeout\n"); + aprint_error_dev(sc->sc_dev, "device timeout\n"); rt2661_init(ifp); ifp->if_oerrors++; return; @@ -1973,7 +1973,7 @@ rt2661_bbp_write(struct rt2661_softc *sc DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "could not write to BBP\n"); + aprint_error_dev(sc->sc_dev, "could not write to BBP\n"); return; } @@ -1995,7 +1995,7 @@ rt2661_bbp_read(struct rt2661_softc *sc, DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "could not read from BBP\n"); + aprint_error_dev(sc->sc_dev, "could not read from BBP\n"); return 0; } @@ -2009,7 +2009,7 @@ rt2661_bbp_read(struct rt2661_softc *sc, DELAY(1); } - aprint_error_dev(&sc->sc_dev, "could not read from BBP\n"); + aprint_error_dev(sc->sc_dev, "could not read from BBP\n"); return 0; } @@ -2025,7 +2025,7 @@ rt2661_rf_write(struct rt2661_softc *sc, DELAY(1); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "could not write to RF\n"); + aprint_error_dev(sc->sc_dev, "could not write to RF\n"); return; } tmp = RT2661_RF_BUSY | RT2661_RF_21BIT | (val & 0x1fffff) << 2 | @@ -2498,7 +2498,7 @@ rt2661_bbp_init(struct rt2661_softc *sc) DELAY(100); } if (ntries == 100) { - aprint_error_dev(&sc->sc_dev, "timeout waiting for BBP\n"); + aprint_error_dev(sc->sc_dev, "timeout waiting for BBP\n"); return EIO; } @@ -2535,7 +2535,7 @@ rt2661_init(struct ifnet *ifp) /* for CardBus, power on the socket */ if (!(sc->sc_flags & RT2661_ENABLED)) { if (sc->sc_enable != NULL && (*sc->sc_enable)(sc) != 0) { - aprint_error_dev(&sc->sc_dev, "could not enable device\n"); + aprint_error_dev(sc->sc_dev, "could not enable device\n"); return EIO; } sc->sc_flags |= RT2661_ENABLED; @@ -2557,21 +2557,21 @@ rt2661_init(struct ifnet *ifp) } if (firmware_open("ral", name, &fh) != 0) { - aprint_error_dev(&sc->sc_dev, "could not open microcode %s\n", name); + aprint_error_dev(sc->sc_dev, "could not open microcode %s\n", name); rt2661_stop(ifp, 1); return EIO; } size = firmware_get_size(fh); if (!(ucode = firmware_malloc(size))) { - aprint_error_dev(&sc->sc_dev, "could not alloc microcode memory\n"); + aprint_error_dev(sc->sc_dev, "could not alloc microcode memory\n"); firmware_close(fh); rt2661_stop(ifp, 1); return ENOMEM; } if (firmware_read(fh, 0, ucode, size) != 0) { - aprint_error_dev(&sc->sc_dev, "could not read microcode %s\n", name); + aprint_error_dev(sc->sc_dev, "could not read microcode %s\n", name); firmware_free(ucode, 0); firmware_close(fh); rt2661_stop(ifp, 1); @@ -2579,7 +2579,7 @@ rt2661_init(struct ifnet *ifp) } if (rt2661_load_microcode(sc, ucode, size) != 0) { - aprint_error_dev(&sc->sc_dev, "could not load 8051 microcode\n"); + aprint_error_dev(sc->sc_dev, "could not load 8051 microcode\n"); firmware_free(ucode, 0); firmware_close(fh); rt2661_stop(ifp, 1); @@ -2922,7 +2922,7 @@ rt2661_prepare_beacon(struct rt2661_soft m0 = ieee80211_beacon_alloc(ic, ni, &bo); if (m0 == NULL) { - aprint_error_dev(&sc->sc_dev, "could not allocate beacon frame\n"); + aprint_error_dev(sc->sc_dev, "could not allocate beacon frame\n"); return ENOBUFS; } Index: src/sys/dev/ic/rt2661var.h diff -u src/sys/dev/ic/rt2661var.h:1.10 src/sys/dev/ic/rt2661var.h:1.11 --- src/sys/dev/ic/rt2661var.h:1.10 Tue Jan 19 22:06:25 2010 +++ src/sys/dev/ic/rt2661var.h Sat Feb 18 13:38:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661var.h,v 1.10 2010/01/19 22:06:25 pooka Exp $ */ +/* $NetBSD: rt2661var.h,v 1.11 2012/02/18 13:38:36 drochner Exp $ */ /* $OpenBSD: rt2661var.h,v 1.4 2006/02/25 12:56:47 damien Exp $ */ /*- @@ -89,7 +89,7 @@ struct rt2661_node { }; struct rt2661_softc { - struct device sc_dev; + device_t sc_dev; struct ieee80211com sc_ic; int (*sc_newstate)(struct ieee80211com *, Index: src/sys/dev/pci/if_ral_pci.c diff -u src/sys/dev/pci/if_ral_pci.c:1.19 src/sys/dev/pci/if_ral_pci.c:1.20 --- src/sys/dev/pci/if_ral_pci.c:1.19 Mon Jan 30 19:41:20 2012 +++ src/sys/dev/pci/if_ral_pci.c Sat Feb 18 13:38:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ral_pci.c,v 1.19 2012/01/30 19:41:20 drochner Exp $ */ +/* $NetBSD: if_ral_pci.c,v 1.20 2012/02/18 13:38:36 drochner Exp $ */ /* $OpenBSD: if_ral_pci.c,v 1.6 2006/01/09 20:03:43 damien Exp $ */ /*- @@ -22,7 +22,7 @@ * PCI front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.19 2012/01/30 19:41:20 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.20 2012/02/18 13:38:36 drochner Exp $"); #include <sys/param.h> @@ -93,7 +93,7 @@ int ral_pci_match(device_t, cfdata_t, vo void ral_pci_attach(device_t, device_t, void *); int ral_pci_detach(device_t, int); -CFATTACH_DECL(ral_pci, sizeof (struct ral_pci_softc), +CFATTACH_DECL_NEW(ral_pci, sizeof (struct ral_pci_softc), ral_pci_match, ral_pci_attach, ral_pci_detach, NULL); int @@ -134,6 +134,7 @@ ral_pci_attach(device_t parent, device_t psc->sc_opns = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RALINK_RT2560) ? &ral_rt2560_opns : &ral_rt2661_opns; + sc->sc_dev = self; sc->sc_dmat = pa->pa_dmat; psc->sc_pc = pa->pa_pc; @@ -168,7 +169,7 @@ ral_pci_attach(device_t parent, device_t aprint_error("\n"); return; } - aprint_normal_dev(&sc->sc_dev, "interrupting at %s\n", intrstr); + aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr); (*psc->sc_opns->attach)(sc, PCI_PRODUCT(pa->pa_id)); }