Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev split device_t/softc



details:   https://anonhg.NetBSD.org/src/rev/c6bef6ef79dc
branches:  trunk
changeset: 777424:c6bef6ef79dc
user:      drochner <drochner%NetBSD.org@localhost>
date:      Sat Feb 18 13:38:35 2012 +0000

description:
split device_t/softc

diffstat:

 sys/dev/cardbus/if_ral_cardbus.c |   13 ++--
 sys/dev/ic/rt2560.c              |   92 +++++++++++++++++-----------------
 sys/dev/ic/rt2560var.h           |    4 +-
 sys/dev/ic/rt2661.c              |  102 +++++++++++++++++++-------------------
 sys/dev/ic/rt2661var.h           |    4 +-
 sys/dev/pci/if_ral_pci.c         |    9 +-
 6 files changed, 113 insertions(+), 111 deletions(-)

diffs (truncated from 946 to 300 lines):

diff -r f134c3e13dce -r c6bef6ef79dc sys/dev/cardbus/if_ral_cardbus.c
--- a/sys/dev/cardbus/if_ral_cardbus.c  Sat Feb 18 06:57:23 2012 +0000
+++ b/sys/dev/cardbus/if_ral_cardbus.c  Sat Feb 18 13:38:35 2012 +0000
@@ -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 @@
 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 @@
 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 @@
            (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 @@
 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 @@
        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;
diff -r f134c3e13dce -r c6bef6ef79dc sys/dev/ic/rt2560.c
--- a/sys/dev/ic/rt2560.c       Sat Feb 18 06:57:23 2012 +0000
+++ b/sys/dev/ic/rt2560.c       Sat Feb 18 13:38:35 2012 +0000
@@ -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 @@
        /* 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 @@
         */
        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 @@
        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 @@
 
        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 @@
        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 @@
        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 @@
            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 @@
        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_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 @@
        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 @@
            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 @@
        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 @@
                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 @@
                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 @@
                    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;



Home | Main Index | Thread Index | Old Index