From owner-p4-projects@FreeBSD.ORG Tue Jul 31 14:17:28 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8BECF16A469; Tue, 31 Jul 2007 14:17:28 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5585C16A421 for ; Tue, 31 Jul 2007 14:17:28 +0000 (UTC) (envelope-from loafier@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 39F5A13C48D for ; Tue, 31 Jul 2007 14:17:28 +0000 (UTC) (envelope-from loafier@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6VEHS9r047161 for ; Tue, 31 Jul 2007 14:17:28 GMT (envelope-from loafier@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6VEHSt9047156 for perforce@freebsd.org; Tue, 31 Jul 2007 14:17:28 GMT (envelope-from loafier@FreeBSD.org) Date: Tue, 31 Jul 2007 14:17:28 GMT Message-Id: <200707311417.l6VEHSt9047156@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 124423 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: Tue, 31 Jul 2007 14:17:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=124423 Change 124423 by loafier@chrisdsoc on 2007/07/31 14:16:30 Edit for bus_alloc_resources(), etc. Affected files ... .. //depot/projects/soc2007/loafier_busalloc/src/sys/dev/sound/pci/atiixp.c#2 edit Differences ... ==== //depot/projects/soc2007/loafier_busalloc/src/sys/dev/sound/pci/atiixp.c#2 (text+ko) ==== @@ -100,18 +100,27 @@ int caps_32bit, dir; }; +enum { + RES_MEM, + RES_IRQ, + RES_SZ +}; + +static struct resource_spec atiixp_res_spec[] = { + {SYS_RES_MEMORY, PCIR_BAR(0), RF_ACTIVE}, + {SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE}, + {-1, 0, 0} +}; + struct atiixp_info { device_t dev; - bus_space_tag_t st; - bus_space_handle_t sh; bus_dma_tag_t parent_dmat; bus_dma_tag_t sgd_dmat; bus_dmamap_t sgd_dmamap; bus_addr_t sgd_addr; - struct resource *reg, *irq; - int regtype, regid, irqid; + struct resource *res[RES_SZ]; void *ih; struct ac97_info *codec; @@ -131,9 +140,9 @@ }; #define atiixp_rd(_sc, _reg) \ - bus_space_read_4((_sc)->st, (_sc)->sh, _reg) + bus_read_4((_sc)->res[RES_MEM], _reg) #define atiixp_wr(_sc, _reg, _val) \ - bus_space_write_4((_sc)->st, (_sc)->sh, _reg, _val) + bus_write_4((_sc)->res[RES_MEM], _reg, _val) #define atiixp_lock(_sc) snd_mtxlock((_sc)->lock) #define atiixp_unlock(_sc) snd_mtxunlock((_sc)->lock) @@ -1097,7 +1106,8 @@ #endif snprintf(status, SND_STATUSLEN, "at memory 0x%lx irq %ld %s", - rman_get_start(sc->reg), rman_get_start(sc->irq), + rman_get_start(sc->res[RES_MEM]), + rman_get_start(sc->res[RES_IRQ]), PCM_KLDSTRING(snd_atiixp)); pcm_setstatus(sc->dev, status); @@ -1130,17 +1140,10 @@ sc->codec = NULL; } if (sc->ih) { - bus_teardown_intr(sc->dev, sc->irq, sc->ih); + bus_teardown_intr(sc->dev, sc->res[RES_IRQ], sc->ih); sc->ih = NULL; } - if (sc->reg) { - bus_release_resource(sc->dev, sc->regtype, sc->regid, sc->reg); - sc->reg = NULL; - } - if (sc->irq) { - bus_release_resource(sc->dev, SYS_RES_IRQ, sc->irqid, sc->irq); - sc->irq = NULL; - } + bus_release_resources(sc->dev, atiixp_res_spec, sc->res); if (sc->parent_dmat) { bus_dma_tag_destroy(sc->parent_dmat); sc->parent_dmat = NULL; @@ -1204,26 +1207,15 @@ pci_set_powerstate(dev, PCI_POWERSTATE_D0); pci_enable_busmaster(dev); - sc->regid = PCIR_BAR(0); - sc->regtype = SYS_RES_MEMORY; - sc->reg = bus_alloc_resource_any(dev, sc->regtype, - &sc->regid, RF_ACTIVE); - - if (!sc->reg) { - device_printf(dev, "unable to allocate register space\n"); + if (bus_alloc_resources(dev, atiixp_res_spec, sc->res) != 0) { + device_printf(dev, "unable to allocate resources\n"); goto bad; } - sc->st = rman_get_bustag(sc->reg); - sc->sh = rman_get_bushandle(sc->reg); - sc->bufsz = pcm_getbuffersize(dev, ATI_IXP_BUFSZ_MIN, ATI_IXP_BUFSZ_DEFAULT, ATI_IXP_BUFSZ_MAX); - sc->irqid = 0; - sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid, - RF_ACTIVE | RF_SHAREABLE); - if (!sc->irq || snd_setup_intr(dev, sc->irq, INTR_MPSAFE, + if (snd_setup_intr(dev, sc->res[RES_IRQ], INTR_MPSAFE, atiixp_intr, sc, &sc->ih)) { device_printf(dev, "unable to map interrupt\n"); goto bad; @@ -1320,7 +1312,7 @@ return (r); } sc->codec = NULL; - if (sc->st != 0 && sc->sh != 0) + if (sc->res[RES_MEM] != NULL) atiixp_disable_interrupts(sc); atiixp_release_resource(sc); }