Date: Mon, 26 Jan 2009 14:43:19 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r187717 - head/sys/dev/sound/macio Message-ID: <200901261443.n0QEhJKw053190@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Mon Jan 26 14:43:18 2009 New Revision: 187717 URL: http://svn.freebsd.org/changeset/base/187717 Log: Change the way our softc is stored to use the devinfo facility provided by pcm instead of the regular device softc interface. This brings the AOA driver in line with the other pcm drivers. Requested by: ariff Modified: head/sys/dev/sound/macio/aoa.c head/sys/dev/sound/macio/aoa.h head/sys/dev/sound/macio/davbus.c head/sys/dev/sound/macio/i2s.c Modified: head/sys/dev/sound/macio/aoa.c ============================================================================== --- head/sys/dev/sound/macio/aoa.c Mon Jan 26 14:26:35 2009 (r187716) +++ head/sys/dev/sound/macio/aoa.c Mon Jan 26 14:43:18 2009 (r187717) @@ -106,7 +106,7 @@ aoa_dma_set_program(struct aoa_dma *dma) static struct aoa_dma * aoa_dma_create(device_t self) { - struct aoa_softc *sc = device_get_softc(self); + struct aoa_softc *sc = pcm_getdevinfo(self); struct aoa_dma *dma; bus_dma_tag_t tag; int err; @@ -215,7 +215,7 @@ aoa_chan_init(kobj_t obj, void *devinfo, struct pcm_channel *c, int dir) { device_t self = devinfo; - struct aoa_softc *sc = device_get_softc(self); + struct aoa_softc *sc = pcm_getdevinfo(self); struct aoa_dma *dma; int max_slots, err; @@ -357,12 +357,12 @@ static kobj_method_t aoa_chan_methods[] CHANNEL_DECLARE(aoa_chan); int -aoa_attach(device_t self) +aoa_attach(device_t self, void *sc) { char status[SND_STATUSLEN]; int err; - if (pcm_register(self, self, 1, 0)) + if (pcm_register(self, sc, 1, 0)) return (ENXIO); err = pcm_getbuffersize(self, AOA_BUFFER_SIZE, AOA_BUFFER_SIZE, Modified: head/sys/dev/sound/macio/aoa.h ============================================================================== --- head/sys/dev/sound/macio/aoa.h Mon Jan 26 14:26:35 2009 (r187716) +++ head/sys/dev/sound/macio/aoa.h Mon Jan 26 14:43:18 2009 (r187717) @@ -28,17 +28,19 @@ #ifndef SOUND_AOA_H #define SOUND_AOA_H +#ifndef AOA_DEBUG #define DPRINTF(x) /* nothing */ -/* #define DPRINTF(x) printf x */ +#else +#define DPRINTF(x) printf x +#endif struct aoa_softc { - u_int8_t sc_super[PCM_SOFTC_SIZE]; void *sc_intrp; struct resource *sc_odma; }; void aoa_interrupt(void *); -int aoa_attach(device_t); +int aoa_attach(device_t, void *sc); #endif /* SOUND_AOA_H */ Modified: head/sys/dev/sound/macio/davbus.c ============================================================================== --- head/sys/dev/sound/macio/davbus.c Mon Jan 26 14:26:35 2009 (r187716) +++ head/sys/dev/sound/macio/davbus.c Mon Jan 26 14:43:18 2009 (r187717) @@ -78,7 +78,7 @@ static device_method_t pcm_davbus_method static driver_t pcm_davbus_driver = { "pcm", pcm_davbus_methods, - sizeof(struct davbus_softc) + PCM_SOFTC_SIZE }; DRIVER_MODULE(pcm_davbus, macio, pcm_davbus_driver, pcm_devclass, 0, 0); @@ -91,7 +91,6 @@ static int davbus_probe(device_t self) { const char *name; - struct davbus_softc *sc; name = ofw_bus_get_name(self); if (!name) @@ -100,11 +99,6 @@ davbus_probe(device_t self) if (strcmp(name, "davbus") != 0) return (ENXIO); - sc = device_get_softc(self); - if (!sc) - return (ENOMEM); - bzero(sc, sizeof(*sc)); - device_set_desc(self, "Apple DAVBus Audio Controller"); return (0); @@ -495,12 +489,14 @@ screamer_setrecsrc(struct snd_mixer *m, static int davbus_attach(device_t self) { - struct davbus_softc *sc = device_get_softc(self); + struct davbus_softc *sc; struct resource *dbdma_irq, *cintr; void *cookie; char compat[64]; int rid, oirq, err; + sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); + sc->dev = self; sc->node = ofw_bus_get_node(self); sc->soundnode = OF_child(sc->node); @@ -559,7 +555,7 @@ davbus_attach(device_t self) DAVBUS_OUTPUT_SUBFRAME0 | DAVBUS_RATE_44100 | DAVBUS_INTR_PORTCHG); /* Attach DBDMA engine and PCM layer */ - err = aoa_attach(self); + err = aoa_attach(self,sc); if (err) return (err); Modified: head/sys/dev/sound/macio/i2s.c ============================================================================== --- head/sys/dev/sound/macio/i2s.c Mon Jan 26 14:26:35 2009 (r187716) +++ head/sys/dev/sound/macio/i2s.c Mon Jan 26 14:43:18 2009 (r187717) @@ -111,7 +111,7 @@ static device_method_t pcm_i2s_methods[] static driver_t pcm_i2s_driver = { "pcm", pcm_i2s_methods, - sizeof(struct i2s_softc) + PCM_SOFTC_SIZE }; DRIVER_MODULE(pcm_i2s, macio, pcm_i2s_driver, pcm_devclass, 0, 0); @@ -153,7 +153,6 @@ static int i2s_probe(device_t self) { const char *name; - struct i2s_softc *sc; name = ofw_bus_get_name(self); if (!name) @@ -162,11 +161,6 @@ i2s_probe(device_t self) if (strcmp(name, "i2s") != 0) return (ENXIO); - sc = device_get_softc(self); - if (!sc) - return (ENOMEM); - bzero(sc, sizeof(*sc)); - device_set_desc(self, "Apple I2S Audio Controller"); return (0); @@ -177,11 +171,13 @@ static phandle_t of_find_firstchild_byna static int i2s_attach(device_t self) { - struct i2s_softc *sc = device_get_softc(self); + struct i2s_softc *sc; struct resource *dbdma_irq; void *dbdma_ih; int rid, oirq, err; phandle_t port; + + sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); sc->dev = self; sc->node = ofw_bus_get_node(self); @@ -242,7 +238,7 @@ i2s_attach(device_t self) if (config_intrhook_establish(i2s_delayed_attach) != 0) return (ENOMEM); - return (aoa_attach(self)); + return (aoa_attach(self,sc)); } /***************************************************************************** @@ -322,7 +318,6 @@ aoagpio_probe(device_t gpio) /* Try to find a match. */ for (m = gpio_controls; m->name != NULL; m++) { if (strcmp(name, m->name) == 0) { - sc = device_get_softc(gpio); gpio_ctrls[m->ctrl] = sc; sc->dev = gpio; @@ -731,7 +726,7 @@ i2s_postattach(void *arg) KASSERT(self != NULL, ("bad arg")); KASSERT(i2s_delayed_attach != NULL, ("bogus call")); - sc = device_get_softc(self); + sc = pcm_getdevinfo(self); /* Reset the codec. */ i2s_audio_hw_reset(sc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901261443.n0QEhJKw053190>