Date: Tue, 31 Jul 2007 14:29:43 GMT From: Christopher Davis <loafier@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124424 for review Message-ID: <200707311429.l6VEThK0047830@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124424 Change 124424 by loafier@chrisdsoc on 2007/07/31 14:29:03 Remove bus tags & handles, change read/write functions, etc Affected files ... .. //depot/projects/soc2007/loafier_busalloc/src/sys/dev/sound/pci/cs4281.c#2 edit Differences ... ==== //depot/projects/soc2007/loafier_busalloc/src/sys/dev/sound/pci/cs4281.c#2 (text+ko) ==== @@ -78,8 +78,6 @@ device_t dev; u_int32_t type; - bus_space_tag_t st; - bus_space_handle_t sh; bus_dma_tag_t parent_dmat; struct resource *reg, *irq, *mem; @@ -140,13 +138,13 @@ static inline u_int32_t cs4281_rd(struct sc_info *sc, int regno) { - return bus_space_read_4(sc->st, sc->sh, regno); + return bus_read_4(sc->reg, regno); } static inline void cs4281_wr(struct sc_info *sc, int regno, u_int32_t data) { - bus_space_write_4(sc->st, sc->sh, regno, data); + bus_write_4(sc->reg, regno, data); DELAY(100); } @@ -730,6 +728,22 @@ /* -------------------------------------------------------------------- */ /* Probe and attach the card */ +static void +cs4281_destroy(device_t dev, struct sc_info *sc) +{ + if (sc->reg) + bus_release_resource(dev, sc->regtype, sc->regid, sc->reg); + if (sc->mem) + bus_release_resource(dev, SYS_RES_MEMORY, sc->memid, sc->mem); + if (sc->ih) + bus_teardown_intr(dev, sc->irq, sc->ih); + if (sc->irq) + bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); + if (sc->parent_dmat) + bus_dma_tag_destroy(sc->parent_dmat); + free(sc, M_DEVBUF); +} + static int cs4281_pci_probe(device_t dev) { @@ -751,16 +765,15 @@ { struct sc_info *sc; struct ac97_info *codec = NULL; - u_int32_t data; char status[SND_STATUSLEN]; sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); sc->dev = dev; sc->type = pci_get_devid(dev); - data = pci_read_config(dev, PCIR_COMMAND, 2); - data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); - pci_write_config(dev, PCIR_COMMAND, data, 2); + pci_enable_busmaster(dev); + pci_enable_io(dev, SYS_RES_IOPORT); + pci_enable_io(dev, SYS_RES_MEMORY); #if __FreeBSD_version > 500000 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { @@ -795,8 +808,6 @@ goto bad; } } - sc->st = rman_get_bustag(sc->reg); - sc->sh = rman_get_bushandle(sc->reg); sc->memid = PCIR_BAR(1); sc->mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->memid, 0, @@ -866,17 +877,7 @@ bad: if (codec) ac97_destroy(codec); - if (sc->reg) - bus_release_resource(dev, sc->regtype, sc->regid, sc->reg); - if (sc->mem) - bus_release_resource(dev, SYS_RES_MEMORY, sc->memid, sc->mem); - if (sc->ih) - bus_teardown_intr(dev, sc->irq, sc->ih); - if (sc->irq) - bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); - if (sc->parent_dmat) - bus_dma_tag_destroy(sc->parent_dmat); - free(sc, M_DEVBUF); + cs4281_destroy(dev, sc); return ENXIO; } @@ -895,13 +896,7 @@ /* power off */ cs4281_power(sc, 3); - - bus_release_resource(dev, sc->regtype, sc->regid, sc->reg); - bus_release_resource(dev, SYS_RES_MEMORY, sc->memid, sc->mem); - bus_teardown_intr(dev, sc->irq, sc->ih); - bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); - bus_dma_tag_destroy(sc->parent_dmat); - free(sc, M_DEVBUF); + cs4281_destroy(dev, sc); return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707311429.l6VEThK0047830>