Date: Tue, 31 Jul 2007 14:17:28 GMT From: Christopher Davis <loafier@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124423 for review Message-ID: <200707311417.l6VEHSt9047156@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707311417.l6VEHSt9047156>