From owner-p4-projects@FreeBSD.ORG Fri Jul 6 13:15:24 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 944F516A400; Fri, 6 Jul 2007 13:15:24 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4D9D816A468 for ; Fri, 6 Jul 2007 13:15:24 +0000 (UTC) (envelope-from loafier@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 3C2E813C458 for ; Fri, 6 Jul 2007 13:15:24 +0000 (UTC) (envelope-from loafier@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l66DFNre001195 for ; Fri, 6 Jul 2007 13:15:23 GMT (envelope-from loafier@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l66DFMZx001192 for perforce@freebsd.org; Fri, 6 Jul 2007 13:15:22 GMT (envelope-from loafier@FreeBSD.org) Date: Fri, 6 Jul 2007 13:15:22 GMT Message-Id: <200707061315.l66DFMZx001192@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to loafier@FreeBSD.org using -f From: Christopher Davis To: Perforce Change Reviews Cc: Subject: PERFORCE change 123011 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2007 13:15:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=123011 Change 123011 by loafier@chrisdsoc on 2007/07/06 13:15:08 Edited first 6 ARM drivers on BusAllocUpdate list. Affected files ... .. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_pio.c#2 edit .. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_rtc.c#2 edit .. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_spi.c#2 edit .. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_ssc.c#2 edit .. //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_twi.c#2 edit .. //depot/projects/soc2007/loafier_busalloc/arm/at91/if_ate.c#2 edit Differences ... ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_pio.c#2 (text) ==== @@ -42,12 +42,23 @@ #include #include +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec pio_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct at91_pio_softc { device_t dev; /* Myself */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ and Memory resources */ struct mtx sc_mtx; /* basically a perimeter lock */ struct cdev *cdev; int flags; @@ -57,13 +68,13 @@ static inline uint32_t RD4(struct at91_pio_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct at91_pio_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } #define AT91_PIO_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx) @@ -148,7 +159,7 @@ * Activate the interrupt, but disable all interrupts in the hardware */ WR4(sc, PIO_IDR, 0xffffffff); - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC, + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC, at91_pio_intr, NULL, sc, &sc->intrhand); if (err) { AT91_PIO_LOCK_DESTROY(sc); @@ -177,23 +188,15 @@ at91_pio_activate(device_t dev) { struct at91_pio_softc *sc; - int rid; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) - goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE | RF_SHAREABLE); - if (sc->irq_res == NULL) - goto errout; + + if (bus_alloc_resources(dev, pio_res_spec, sc->res)) { + at91_pio_deactivate(dev); + return (ENOMEM); + } + return (0); -errout: - at91_pio_deactivate(dev); - return (ENOMEM); } static void @@ -203,18 +206,10 @@ sc = device_get_softc(dev); if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, pio_res_spec, sc->res); } static int ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_rtc.c#2 (text) ==== @@ -43,25 +43,36 @@ #include "clock_if.h" +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec rtc_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct at91_rtc_softc { device_t dev; /* Myself */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ and Memory resources */ struct mtx sc_mtx; /* basically a perimeter lock */ }; static inline uint32_t RD4(struct at91_rtc_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct at91_rtc_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } #define AT91_RTC_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx) @@ -110,7 +121,7 @@ * Activate the interrupt, but disable all interrupts in the hardware */ WR4(sc, RTC_IDR, 0xffffffff); - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC, + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC, at91_rtc_intr, NULL, sc, &sc->intrhand); if (err) { AT91_RTC_LOCK_DESTROY(sc); @@ -133,23 +144,15 @@ at91_rtc_activate(device_t dev) { struct at91_rtc_softc *sc; - int rid; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) - goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE | RF_SHAREABLE); - if (sc->irq_res == NULL) - goto errout; + + if (bus_alloc_resources(dev, rtc_res_spec, sc->res)) { + at91_rtc_deactivate(dev); + return (ENOMEM); + } + return (0); -errout: - at91_rtc_deactivate(dev); - return (ENOMEM); } static void @@ -159,18 +162,10 @@ sc = device_get_softc(dev); if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, rtc_res_spec, sc->res); } static int ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_spi.c#2 (text) ==== @@ -43,12 +43,23 @@ #include #include "spibus_if.h" +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec spi_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct at91_spi_softc { device_t dev; /* Myself */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ and Memory resource */ bus_dma_tag_t dmatag; /* bus dma tag for mbufs */ bus_dmamap_t map[4]; /* Maps for the transaction */ int rxdone; @@ -57,13 +68,13 @@ static inline uint32_t RD4(struct at91_spi_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct at91_spi_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } /* bus entry points */ @@ -149,20 +160,14 @@ at91_spi_activate(device_t dev) { struct at91_spi_softc *sc; - int rid, err = ENOMEM; + int err = ENOMEM; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) + + if (bus_alloc_resources(dev, spi_res_spec, sc->res)) goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (sc->irq_res == NULL) - goto errout; - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC | INTR_MPSAFE, NULL, at91_spi_intr, sc, &sc->intrhand); if (err != 0) goto errout; @@ -179,18 +184,10 @@ sc = device_get_softc(dev); if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, spi_res_spec, sc->res); } static void ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_ssc.c#2 (text) ==== @@ -38,12 +38,23 @@ #include +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec ssc_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct at91_ssc_softc { device_t dev; /* Myself */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ and Memory resources */ struct mtx sc_mtx; /* basically a perimeter lock */ struct cdev *cdev; int flags; @@ -53,13 +64,13 @@ static inline uint32_t RD4(struct at91_ssc_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct at91_ssc_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } #define AT91_SSC_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -123,7 +134,7 @@ /* * Activate the interrupt */ - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC | INTR_MPSAFE, NULL, at91_ssc_intr, sc, &sc->intrhand); if (err) { AT91_SSC_LOCK_DESTROY(sc); @@ -165,23 +176,15 @@ at91_ssc_activate(device_t dev) { struct at91_ssc_softc *sc; - int rid; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) - goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (sc->irq_res == NULL) - goto errout; + + if (bus_alloc_resources(dev, ssc_res_spec, sc->res)) { + at91_ssc_deactivate(dev); + return (ENOMEM); + } + return (0); -errout: - at91_ssc_deactivate(dev); - return (ENOMEM); } static void @@ -191,18 +194,10 @@ sc = device_get_softc(dev); if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, ssc_res_spec, sc->res); } static void ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/at91_twi.c#2 (text) ==== @@ -49,12 +49,23 @@ #define TWI_FAST_CLOCK 45000 #define TWI_FASTEST_CLOCK 90000 +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec twi_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct at91_twi_softc { device_t dev; /* Myself */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ & Memory resources */ struct mtx sc_mtx; /* basically a perimeter lock */ volatile uint32_t flags; uint32_t cwgr; @@ -66,13 +77,13 @@ static inline uint32_t RD4(struct at91_twi_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct at91_twi_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } #define AT91_TWI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -121,7 +132,7 @@ /* * Activate the interrupt */ - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_MISC | INTR_MPSAFE, NULL, at91_twi_intr, sc, &sc->intrhand); if (err) { AT91_TWI_LOCK_DESTROY(sc); @@ -162,23 +173,15 @@ at91_twi_activate(device_t dev) { struct at91_twi_softc *sc; - int rid; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) - goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (sc->irq_res == NULL) - goto errout; + + if (bus_alloc_resources(dev, twi_res_spec, sc->res)) { + at91_twi_deactivate(dev); + return (ENOMEM); + } + return (0); -errout: - at91_twi_deactivate(dev); - return (ENOMEM); } static void @@ -188,18 +191,10 @@ sc = device_get_softc(dev); if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, twi_res_spec, sc->res); } static void ==== //depot/projects/soc2007/loafier_busalloc/arm/at91/if_ate.c#2 (text) ==== @@ -75,6 +75,18 @@ #define ATE_MAX_TX_BUFFERS 2 /* We have ping-pong tx buffers */ #define ATE_MAX_RX_BUFFERS 64 +enum { + RES_IRQ, + RES_MEM, + RES_SZ +}; + +static struct resource_spec ate_res_spec[] = { + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHARABLE}, + {SYS_RES_MEMORY, 0, RF_ACTIVE}, + {-1, 0, 0} +}; + struct ate_softc { struct ifnet *ifp; /* ifnet pointer */ @@ -82,8 +94,7 @@ device_t dev; /* Myself */ device_t miibus; /* My child miibus */ void *intrhand; /* Interrupt handle */ - struct resource *irq_res; /* IRQ resource */ - struct resource *mem_res; /* Memory resource */ + struct resource *res[RES_SZ]; /* IRQ & Memory resources */ struct callout tick_ch; /* Tick callout */ bus_dma_tag_t mtag; /* bus dma tag for mbufs */ bus_dmamap_t tx_map[ATE_MAX_TX_BUFFERS]; @@ -104,13 +115,13 @@ static inline uint32_t RD4(struct ate_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + return bus_read_4(sc->res[RES_MEM], off); } static inline void WR4(struct ate_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(sc->mem_res, off, val); + bus_write_4(sc->res[RES_MEM], off, val); } #define ATE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -225,7 +236,7 @@ /* * Activate the interrupt */ - err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, + err = bus_setup_intr(dev, sc->res[RES_IRQ], INTR_TYPE_NET | INTR_MPSAFE, NULL, ate_intr, sc, &sc->intrhand); if (err) { ether_ifdetach(ifp); @@ -324,20 +335,12 @@ ate_activate(device_t dev) { struct ate_softc *sc; - int rid, err, i; + int err, i; sc = device_get_softc(dev); - rid = 0; - sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->mem_res == NULL) + if (bus_alloc_resources(dev, ate_res_spec, sc->res)) goto errout; - rid = 0; - sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (sc->irq_res == NULL) - goto errout; - + /* * Allocate DMA tags and maps */ @@ -441,20 +444,12 @@ bus_dma_tag_destroy(sc->mcs_tag); #endif if (sc->intrhand) - bus_teardown_intr(dev, sc->irq_res, sc->intrhand); + bus_teardown_intr(dev, sc->res[RES_IRQ], sc->intrhand); sc->intrhand = 0; bus_generic_detach(sc->dev); if (sc->miibus) device_delete_child(sc->dev, sc->miibus); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; - if (sc->irq_res) - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + bus_release_resources(dev, ate_res_spec, sc->res); } /*