Date: Thu, 15 Jan 2009 20:49:17 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r187313 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/le Message-ID: <200901152049.n0FKnHpA087072@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Thu Jan 15 20:49:17 2009 New Revision: 187313 URL: http://svn.freebsd.org/changeset/base/187313 Log: MFC: r183337 - Use bus_{read,write}_*(9) instead of bus_space_{read,write}_*(9) etc and take advantage of rman_get_rid(9) in order to save some softc members. - Provide and consume module dependency information for lebuffer(4). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/le/if_le_cbus.c stable/7/sys/dev/le/if_le_isa.c stable/7/sys/dev/le/if_le_lebuffer.c stable/7/sys/dev/le/if_le_pci.c stable/7/sys/dev/le/lebuffer_sbus.c Modified: stable/7/sys/dev/le/if_le_cbus.c ============================================================================== --- stable/7/sys/dev/le/if_le_cbus.c Thu Jan 15 20:45:59 2009 (r187312) +++ stable/7/sys/dev/le/if_le_cbus.c Thu Jan 15 20:49:17 2009 (r187313) @@ -70,12 +70,8 @@ __FBSDID("$FreeBSD$"); struct le_cbus_softc { struct am7990_softc sc_am7990; /* glue to MI code */ - int sc_rrid; struct resource *sc_rres; - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - int sc_irid; struct resource *sc_ires; void *sc_ih; @@ -128,10 +124,9 @@ le_cbus_wrbcr(struct lance_softc *sc, ui { struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_BDP, val); + bus_write_2(lesc->sc_rres, CNET98S_RAP, port); + bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, CNET98S_BDP, val); } #ifdef LEDEBUG @@ -140,10 +135,9 @@ le_cbus_rdbcr(struct lance_softc *sc, ui { struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, CNET98S_BDP)); + bus_write_2(lesc->sc_rres, CNET98S_RAP, port); + bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, CNET98S_BDP)); } #endif @@ -152,10 +146,9 @@ le_cbus_wrcsr(struct lance_softc *sc, ui { struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RDP, val); + bus_write_2(lesc->sc_rres, CNET98S_RAP, port); + bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, CNET98S_RDP, val); } static uint16_t @@ -163,10 +156,9 @@ le_cbus_rdcsr(struct lance_softc *sc, ui { struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, CNET98S_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RDP)); + bus_write_2(lesc->sc_rres, CNET98S_RAP, port); + bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, CNET98S_RDP)); } static void @@ -179,16 +171,16 @@ le_cbus_hwreset(struct lance_softc *sc) */ /* Reset the chip. */ - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RESET, - bus_space_read_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RESET)); + bus_write_2(lesc->sc_rres, CNET98S_RESET, + bus_read_2(lesc->sc_rres, CNET98S_RESET)); DELAY(500); /* ISA bus configuration */ /* ISACSR0 - set Master Mode Read Active time to 300ns. */ - le_cbus_wrbcr(sc, LE_BCR0, 0x0006); + le_cbus_wrbcr(sc, LE_BCR0, 0x0006); /* ISACSR1 - set Master Mode Write Active time to 300ns. */ - le_cbus_wrbcr(sc, LE_BCR1, 0x0006); -#ifdef LEDEBUG + le_cbus_wrbcr(sc, LE_BCR1, 0x0006); +#ifdef LEDEBUG device_printf(dev, "ISACSR2=0x%x\n", le_cbus_rdbcr(sc, LE_BCR2)); #endif /* ISACSR5 - LED1 */ @@ -215,7 +207,7 @@ le_cbus_probe(device_t dev) { struct le_cbus_softc *lesc; struct lance_softc *sc; - int error; + int error, i; /* * Skip PnP devices as some wedge when trying to probe them as @@ -227,18 +219,16 @@ le_cbus_probe(device_t dev) lesc = device_get_softc(dev); sc = &lesc->sc_am7990.lsc; - lesc->sc_rrid = 0; - lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &lesc->sc_rrid, + i = 0; + lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &i, le_ioaddr_cnet98s, CNET98S_IOSIZE, RF_ACTIVE); if (lesc->sc_rres == NULL) return (ENXIO); isa_load_resourcev(lesc->sc_rres, le_ioaddr_cnet98s, CNET98S_IOSIZE); - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); /* Reset the chip. */ - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RESET, - bus_space_read_2(lesc->sc_regt, lesc->sc_regh, CNET98S_RESET)); + bus_write_2(lesc->sc_rres, CNET98S_RESET, + bus_read_2(lesc->sc_rres, CNET98S_RESET)); DELAY(500); /* Stop the chip and put it in a known state. */ @@ -253,7 +243,8 @@ le_cbus_probe(device_t dev) error = BUS_PROBE_DEFAULT; fail: - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); return (error); } @@ -269,8 +260,8 @@ le_cbus_attach(device_t dev) LE_LOCK_INIT(sc, device_get_nameunit(dev)); - lesc->sc_rrid = 0; - lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &lesc->sc_rrid, + i = 0; + lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &i, le_ioaddr_cnet98s, CNET98S_IOSIZE, RF_ACTIVE); if (lesc->sc_rres == NULL) { device_printf(dev, "cannot allocate registers\n"); @@ -278,12 +269,10 @@ le_cbus_attach(device_t dev) goto fail_mtx; } isa_load_resourcev(lesc->sc_rres, le_ioaddr_cnet98s, CNET98S_IOSIZE); - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); - lesc->sc_irid = 0; + i = 0; if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate interrupt\n"); error = ENXIO; goto fail_rres; @@ -339,7 +328,7 @@ le_cbus_attach(device_t dev) error = bus_dmamap_load(lesc->sc_dmat, lesc->sc_dmam, sc->sc_mem, sc->sc_memsize, le_cbus_dma_callback, sc, 0); if (error != 0 || sc->sc_addr == 0) { - device_printf(dev, "cannot load DMA buffer map\n"); + device_printf(dev, "cannot load DMA buffer map\n"); goto fail_dmem; } @@ -350,8 +339,7 @@ le_cbus_attach(device_t dev) * Extract the physical MAC address from the ROM. */ for (i = 0; i < sizeof(sc->sc_enaddr); i++) - sc->sc_enaddr[i] = bus_space_read_1(lesc->sc_regt, - lesc->sc_regh, i * 2); + sc->sc_enaddr[i] = bus_read_1(lesc->sc_rres, i * 2); sc->sc_copytodesc = lance_copytobuf_contig; sc->sc_copyfromdesc = lance_copyfrombuf_contig; @@ -396,9 +384,11 @@ le_cbus_attach(device_t dev) fail_pdtag: bus_dma_tag_destroy(lesc->sc_pdmat); fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); fail_rres: - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); fail_mtx: LE_LOCK_DESTROY(sc); return (error); @@ -419,8 +409,10 @@ le_cbus_detach(device_t dev) bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); bus_dma_tag_destroy(lesc->sc_dmat); bus_dma_tag_destroy(lesc->sc_pdmat); - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); LE_LOCK_DESTROY(sc); return (0); Modified: stable/7/sys/dev/le/if_le_isa.c ============================================================================== --- stable/7/sys/dev/le/if_le_isa.c Thu Jan 15 20:45:59 2009 (r187312) +++ stable/7/sys/dev/le/if_le_isa.c Thu Jan 15 20:49:17 2009 (r187313) @@ -109,15 +109,10 @@ struct le_isa_softc { bus_size_t sc_rap; /* offsets to LANCE... */ bus_size_t sc_rdp; /* ...registers */ - int sc_rrid; struct resource *sc_rres; - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - int sc_drid; struct resource *sc_dres; - int sc_irid; struct resource *sc_ires; void *sc_ih; @@ -184,10 +179,9 @@ le_isa_wrcsr(struct lance_softc *sc, uin { struct le_isa_softc *lesc = (struct le_isa_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, lesc->sc_rap, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, lesc->sc_rap, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, lesc->sc_rdp, val); + bus_write_2(lesc->sc_rres, lesc->sc_rap, port); + bus_barrier(lesc->sc_rres, lesc->sc_rap, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, lesc->sc_rdp, val); } static uint16_t @@ -195,10 +189,9 @@ le_isa_rdcsr(struct lance_softc *sc, uin { struct le_isa_softc *lesc = (struct le_isa_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, lesc->sc_rap, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, lesc->sc_rap, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, lesc->sc_rdp)); + bus_write_2(lesc->sc_rres, lesc->sc_rap, port); + bus_barrier(lesc->sc_rres, lesc->sc_rap, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, lesc->sc_rdp)); } static void @@ -217,18 +210,16 @@ le_isa_probe_legacy(device_t dev, const { struct le_isa_softc *lesc; struct lance_softc *sc; - int error; + int error, i; lesc = device_get_softc(dev); sc = &lesc->sc_am7990.lsc; - lesc->sc_rrid = 0; - lesc->sc_rres = bus_alloc_resource(dev, SYS_RES_IOPORT, &lesc->sc_rrid, - 0, ~0, leip->iosize, RF_ACTIVE); + i = 0; + lesc->sc_rres = bus_alloc_resource(dev, SYS_RES_IOPORT, &i, 0, ~0, + leip->iosize, RF_ACTIVE); if (lesc->sc_rres == NULL) return (ENXIO); - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); lesc->sc_rap = leip->rap; lesc->sc_rdp = leip->rdp; @@ -243,7 +234,8 @@ le_isa_probe_legacy(device_t dev, const error = 0; fail: - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); return (error); } @@ -276,18 +268,18 @@ le_isa_attach(device_t dev) struct le_isa_softc *lesc; struct lance_softc *sc; bus_size_t macstart, rap, rdp; - int error, i, macstride; + int error, i, j, macstride; lesc = device_get_softc(dev); sc = &lesc->sc_am7990.lsc; LE_LOCK_INIT(sc, device_get_nameunit(dev)); - lesc->sc_rrid = 0; + j = 0; switch (ISA_PNP_PROBE(device_get_parent(dev), dev, le_isa_ids)) { case 0: lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, - &lesc->sc_rrid, RF_ACTIVE); + &j, RF_ACTIVE); rap = PCNET_RAP; rdp = PCNET_RDP; macstart = 0; @@ -298,7 +290,7 @@ le_isa_attach(device_t dev) sizeof(le_isa_params[0]); i++) { if (le_isa_probe_legacy(dev, &le_isa_params[i]) == 0) { lesc->sc_rres = bus_alloc_resource(dev, - SYS_RES_IOPORT, &lesc->sc_rrid, 0, ~0, + SYS_RES_IOPORT, &j, 0, ~0, le_isa_params[i].iosize, RF_ACTIVE); rap = le_isa_params[i].rap; rdp = le_isa_params[i].rdp; @@ -321,22 +313,20 @@ le_isa_attach(device_t dev) error = ENXIO; goto fail_mtx; } - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); lesc->sc_rap = rap; lesc->sc_rdp = rdp; - lesc->sc_drid = 0; + i = 0; if ((lesc->sc_dres = bus_alloc_resource_any(dev, SYS_RES_DRQ, - &lesc->sc_drid, RF_ACTIVE)) == NULL) { + &i, RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate DMA channel\n"); error = ENXIO; goto fail_rres; } - lesc->sc_irid = 0; + i = 0; if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate interrupt\n"); error = ENXIO; goto fail_dres; @@ -392,7 +382,7 @@ le_isa_attach(device_t dev) error = bus_dmamap_load(lesc->sc_dmat, lesc->sc_dmam, sc->sc_mem, sc->sc_memsize, le_isa_dma_callback, sc, 0); if (error != 0 || sc->sc_addr == 0) { - device_printf(dev, "cannot load DMA buffer map\n"); + device_printf(dev, "cannot load DMA buffer map\n"); goto fail_dmem; } @@ -405,8 +395,8 @@ le_isa_attach(device_t dev) * Extract the physical MAC address from the ROM. */ for (i = 0; i < sizeof(sc->sc_enaddr); i++) - sc->sc_enaddr[i] = bus_space_read_1(lesc->sc_regt, - lesc->sc_regh, macstart + i * macstride); + sc->sc_enaddr[i] = bus_read_1(lesc->sc_rres, + macstart + i * macstride); sc->sc_copytodesc = lance_copytobuf_contig; sc->sc_copyfromdesc = lance_copyfrombuf_contig; @@ -451,11 +441,14 @@ le_isa_attach(device_t dev) fail_pdtag: bus_dma_tag_destroy(lesc->sc_pdmat); fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); fail_dres: - bus_release_resource(dev, SYS_RES_DRQ, lesc->sc_drid, lesc->sc_dres); + bus_release_resource(dev, SYS_RES_DRQ, + rman_get_rid(lesc->sc_dres), lesc->sc_dres); fail_rres: - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); fail_mtx: LE_LOCK_DESTROY(sc); return (error); @@ -476,9 +469,12 @@ le_isa_detach(device_t dev) bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); bus_dma_tag_destroy(lesc->sc_dmat); bus_dma_tag_destroy(lesc->sc_pdmat); - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); - bus_release_resource(dev, SYS_RES_DRQ, lesc->sc_drid, lesc->sc_dres); - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); + bus_release_resource(dev, SYS_RES_DRQ, + rman_get_rid(lesc->sc_dres), lesc->sc_dres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); LE_LOCK_DESTROY(sc); return (0); Modified: stable/7/sys/dev/le/if_le_lebuffer.c ============================================================================== --- stable/7/sys/dev/le/if_le_lebuffer.c Thu Jan 15 20:45:59 2009 (r187312) +++ stable/7/sys/dev/le/if_le_lebuffer.c Thu Jan 15 20:49:17 2009 (r187313) @@ -63,17 +63,10 @@ __FBSDID("$FreeBSD$"); struct le_lebuffer_softc { struct am7990_softc sc_am7990; /* glue to MI code */ - int sc_brid; struct resource *sc_bres; - bus_space_tag_t sc_buft; - bus_space_handle_t sc_bufh; - int sc_rrid; struct resource *sc_rres; - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - int sc_irid; struct resource *sc_ires; void *sc_ih; }; @@ -103,6 +96,7 @@ DEFINE_CLASS_0(le, le_lebuffer_driver, l sizeof(struct le_lebuffer_softc)); DRIVER_MODULE(le, lebuffer, le_lebuffer_driver, le_lebuffer_devclass, 0, 0); MODULE_DEPEND(le, ether, 1, 1, 1); +MODULE_DEPEND(le, lebuffer, 1, 1, 1); /* * Media types supported @@ -126,10 +120,9 @@ le_lebuffer_wrcsr(struct lance_softc *sc { struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, LEREG1_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, LEREG1_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, LEREG1_RDP, val); + bus_write_2(lesc->sc_rres, LEREG1_RAP, port); + bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, LEREG1_RDP, val); } static uint16_t @@ -137,10 +130,9 @@ le_lebuffer_rdcsr(struct lance_softc *sc { struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, LEREG1_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, LEREG1_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, LEREG1_RDP)); + bus_write_2(lesc->sc_rres, LEREG1_RAP, port); + bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, LEREG1_RDP)); } /* @@ -163,17 +155,13 @@ le_lebuffer_copytodesc(struct lance_soft caddr_t from = fromv; for (; len >= 8; len -= 8, off += 8, from += 8) - bus_space_write_8(lesc->sc_buft, lesc->sc_bufh, off, - be64dec(from)); + bus_write_8(lesc->sc_bres, off, be64dec(from)); for (; len >= 4; len -= 4, off += 4, from += 4) - bus_space_write_4(lesc->sc_buft, lesc->sc_bufh, off, - be32dec(from)); + bus_write_4(lesc->sc_bres, off, be32dec(from)); for (; len >= 2; len -= 2, off += 2, from += 2) - bus_space_write_2(lesc->sc_buft, lesc->sc_bufh, off, - be16dec(from)); + bus_write_2(lesc->sc_bres, off, be16dec(from)); if (len == 1) - bus_space_write_1(lesc->sc_buft, lesc->sc_bufh, off, - *from); + bus_write_1(lesc->sc_bres, off, *from); } static void @@ -184,16 +172,15 @@ le_lebuffer_copyfromdesc(struct lance_so for (; len >= 8; len -= 8, off += 8, to += 8) be64enc(to, - bus_space_read_8(lesc->sc_buft, lesc->sc_bufh, off)); + bus_read_8(lesc->sc_bres, off)); for (; len >= 4; len -= 4, off += 4, to += 4) be32enc(to, - bus_space_read_4(lesc->sc_buft, lesc->sc_bufh, off)); + bus_read_4(lesc->sc_bres, off)); for (; len >= 2; len -= 2, off += 2, to += 2) be16enc(to, - bus_space_read_2(lesc->sc_buft, lesc->sc_bufh, off)); + bus_read_2(lesc->sc_bres, off)); if (len == 1) - *to = - bus_space_read_1(lesc->sc_buft, lesc->sc_bufh, off); + *to = bus_read_1(lesc->sc_bres, off); } static void @@ -203,11 +190,9 @@ le_lebuffer_copytobuf(struct lance_softc caddr_t from = fromv; for (; len >= 2; len -= 2, off += 2, from += 2) - bus_space_write_2(lesc->sc_buft, lesc->sc_bufh, off, - le16dec(from)); + bus_write_2(lesc->sc_bres, off, le16dec(from)); if (len == 1) - bus_space_write_1(lesc->sc_buft, lesc->sc_bufh, off + 1, - *from); + bus_write_1(lesc->sc_bres, off + 1, *from); } static void @@ -218,10 +203,9 @@ le_lebuffer_copyfrombuf(struct lance_sof for (; len >= 2; len -= 2, off += 2, to += 2) le16enc(to, - bus_space_read_2(lesc->sc_buft, lesc->sc_bufh, off)); + bus_read_2(lesc->sc_bres, off)); if (len == 1) - *to = - bus_space_read_1(lesc->sc_buft, lesc->sc_bufh, off + 1); + *to = bus_read_1(lesc->sc_bres, off + 1); } static void @@ -230,9 +214,9 @@ le_lebuffer_zerobuf(struct lance_softc * struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; for (; len >= 2; len -= 2, off += 2) - bus_space_write_2(lesc->sc_buft, lesc->sc_bufh, off, 0); + bus_write_2(lesc->sc_bres, off, 0); if (len == 1) - bus_space_write_1(lesc->sc_buft, lesc->sc_bufh, off + 1, 0); + bus_write_1(lesc->sc_bres, off + 1, 0); } static int @@ -251,7 +235,7 @@ le_lebuffer_attach(device_t dev) { struct le_lebuffer_softc *lesc; struct lance_softc *sc; - int error; + int error, i; lesc = device_get_softc(dev); sc = &lesc->sc_am7990.lsc; @@ -262,33 +246,29 @@ le_lebuffer_attach(device_t dev) * The "register space" of the parent is just a buffer where the * the LANCE descriptor rings and the RX/TX buffers can be stored. */ - lesc->sc_brid = 0; + i = 0; lesc->sc_bres = bus_alloc_resource_any(device_get_parent(dev), - SYS_RES_MEMORY, &lesc->sc_brid, RF_ACTIVE); + SYS_RES_MEMORY, &i, RF_ACTIVE); if (lesc->sc_bres == NULL) { device_printf(dev, "cannot allocate LANCE buffer\n"); error = ENXIO; goto fail_mtx; } - lesc->sc_buft = rman_get_bustag(lesc->sc_bres); - lesc->sc_bufh = rman_get_bushandle(lesc->sc_bres); /* Allocate LANCE registers. */ - lesc->sc_rrid = 0; + i = 0; lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &lesc->sc_rrid, RF_ACTIVE); + &i, RF_ACTIVE); if (lesc->sc_rres == NULL) { device_printf(dev, "cannot allocate LANCE registers\n"); error = ENXIO; goto fail_bres; } - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); /* Allocate LANCE interrupt. */ - lesc->sc_irid = 0; + i = 0; if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate interrupt\n"); error = ENXIO; goto fail_rres; @@ -352,12 +332,14 @@ le_lebuffer_attach(device_t dev) fail_am7990: am7990_detach(&lesc->sc_am7990); fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); fail_rres: - bus_release_resource(dev, SYS_RES_MEMORY, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); fail_bres: bus_release_resource(device_get_parent(dev), SYS_RES_MEMORY, - lesc->sc_brid, lesc->sc_bres); + rman_get_rid(lesc->sc_bres), lesc->sc_bres); fail_mtx: LE_LOCK_DESTROY(sc); return (error); @@ -374,10 +356,12 @@ le_lebuffer_detach(device_t dev) bus_teardown_intr(dev, lesc->sc_ires, lesc->sc_ih); am7990_detach(&lesc->sc_am7990); - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); - bus_release_resource(dev, SYS_RES_MEMORY, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); bus_release_resource(device_get_parent(dev), SYS_RES_MEMORY, - lesc->sc_brid, lesc->sc_bres); + rman_get_rid(lesc->sc_bres), lesc->sc_bres); LE_LOCK_DESTROY(sc); return (0); Modified: stable/7/sys/dev/le/if_le_pci.c ============================================================================== --- stable/7/sys/dev/le/if_le_pci.c Thu Jan 15 20:45:59 2009 (r187312) +++ stable/7/sys/dev/le/if_le_pci.c Thu Jan 15 20:49:17 2009 (r187313) @@ -111,12 +111,8 @@ __FBSDID("$FreeBSD$"); struct le_pci_softc { struct am79900_softc sc_am79900; /* glue to MI code */ - int sc_rrid; struct resource *sc_rres; - bus_space_tag_t sc_regt; - bus_space_handle_t sc_regh; - int sc_irid; struct resource *sc_ires; void *sc_ih; @@ -174,10 +170,9 @@ le_pci_wrbcr(struct lance_softc *sc, uin { struct le_pci_softc *lesc = (struct le_pci_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_BDP, val); + bus_write_2(lesc->sc_rres, PCNET_PCI_RAP, port); + bus_barrier(lesc->sc_rres, PCNET_PCI_RAP, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, PCNET_PCI_BDP, val); } static uint16_t @@ -185,10 +180,9 @@ le_pci_rdbcr(struct lance_softc *sc, uin { struct le_pci_softc *lesc = (struct le_pci_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_BDP)); + bus_write_2(lesc->sc_rres, PCNET_PCI_RAP, port); + bus_barrier(lesc->sc_rres, PCNET_PCI_RAP, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, PCNET_PCI_BDP)); } static void @@ -196,10 +190,9 @@ le_pci_wrcsr(struct lance_softc *sc, uin { struct le_pci_softc *lesc = (struct le_pci_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RDP, val); + bus_write_2(lesc->sc_rres, PCNET_PCI_RAP, port); + bus_barrier(lesc->sc_rres, PCNET_PCI_RAP, 2, BUS_SPACE_BARRIER_WRITE); + bus_write_2(lesc->sc_rres, PCNET_PCI_RDP, val); } static uint16_t @@ -207,10 +200,9 @@ le_pci_rdcsr(struct lance_softc *sc, uin { struct le_pci_softc *lesc = (struct le_pci_softc *)sc; - bus_space_write_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, port); - bus_space_barrier(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RAP, 2, - BUS_SPACE_BARRIER_WRITE); - return (bus_space_read_2(lesc->sc_regt, lesc->sc_regh, PCNET_PCI_RDP)); + bus_write_2(lesc->sc_rres, PCNET_PCI_RAP, port); + bus_barrier(lesc->sc_rres, PCNET_PCI_RAP, 2, BUS_SPACE_BARRIER_WRITE); + return (bus_read_2(lesc->sc_rres, PCNET_PCI_RDP)); } static int @@ -322,20 +314,18 @@ le_pci_attach(device_t dev) pci_enable_busmaster(dev); pci_enable_io(dev, PCIM_CMD_PORTEN); - lesc->sc_rrid = PCIR_BAR(0); + i = PCIR_BAR(0); lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, - &lesc->sc_rrid, RF_ACTIVE); + &i, RF_ACTIVE); if (lesc->sc_rres == NULL) { device_printf(dev, "cannot allocate registers\n"); error = ENXIO; goto fail_mtx; } - lesc->sc_regt = rman_get_bustag(lesc->sc_rres); - lesc->sc_regh = rman_get_bushandle(lesc->sc_rres); - lesc->sc_irid = 0; + i = 0; if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate interrupt\n"); error = ENXIO; goto fail_rres; @@ -392,7 +382,7 @@ le_pci_attach(device_t dev) error = bus_dmamap_load(lesc->sc_dmat, lesc->sc_dmam, sc->sc_mem, sc->sc_memsize, le_pci_dma_callback, sc, 0); if (error != 0 || sc->sc_addr == 0) { - device_printf(dev, "cannot load DMA buffer map\n"); + device_printf(dev, "cannot load DMA buffer map\n"); goto fail_dmem; } @@ -417,9 +407,8 @@ le_pci_attach(device_t dev) /* * Extract the physical MAC address from the ROM. */ - for (i = 0; i < sizeof(sc->sc_enaddr); i++) - sc->sc_enaddr[i] = - bus_space_read_1(lesc->sc_regt, lesc->sc_regh, i); + bus_read_region_1(lesc->sc_rres, 0, sc->sc_enaddr, + sizeof(sc->sc_enaddr)); sc->sc_copytodesc = lance_copytobuf_contig; sc->sc_copyfromdesc = lance_copyfrombuf_contig; @@ -461,9 +450,11 @@ le_pci_attach(device_t dev) fail_pdtag: bus_dma_tag_destroy(lesc->sc_pdmat); fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); fail_rres: - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); fail_mtx: LE_LOCK_DESTROY(sc); return (error); @@ -484,8 +475,10 @@ le_pci_detach(device_t dev) bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); bus_dma_tag_destroy(lesc->sc_dmat); bus_dma_tag_destroy(lesc->sc_pdmat); - bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires); - bus_release_resource(dev, SYS_RES_IOPORT, lesc->sc_rrid, lesc->sc_rres); + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(lesc->sc_ires), lesc->sc_ires); + bus_release_resource(dev, SYS_RES_IOPORT, + rman_get_rid(lesc->sc_rres), lesc->sc_rres); LE_LOCK_DESTROY(sc); return (0); Modified: stable/7/sys/dev/le/lebuffer_sbus.c ============================================================================== --- stable/7/sys/dev/le/lebuffer_sbus.c Thu Jan 15 20:45:59 2009 (r187312) +++ stable/7/sys/dev/le/lebuffer_sbus.c Thu Jan 15 20:49:17 2009 (r187313) @@ -100,6 +100,8 @@ static device_method_t lebuffer_methods[ DEFINE_CLASS_0(lebuffer, lebuffer_driver, lebuffer_methods, 1); DRIVER_MODULE(lebuffer, sbus, lebuffer_driver, lebuffer_devclass, 0, 0); +MODULE_DEPEND(lebuffer, sbus, 1, 1, 1); +MODULE_VERSION(lebuffer, 1); static int lebuffer_probe(device_t dev)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901152049.n0FKnHpA087072>