Date:2013-03-22 14:12:11 (9 years 6 months ago)
Author:Lars C.
Commit:dc1fbaaaf3f0d762bf9c867fe331e5202a83528a
Message:ASoC: mmp-pcm: Allocate dma filter parameters on the stack

The dma filter parameters are only used within filter callback, so there is no
need to allocate them on the heap and keep them around until the PCM has been
closed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Files: sound/soc/pxa/mmp-pcm.c (3 diffs)

Change Details

sound/soc/pxa/mmp-pcm.c
118118    struct snd_soc_pcm_runtime *rtd = substream->private_data;
119119    struct platform_device *pdev = to_platform_device(rtd->platform->dev);
120120    struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
121    struct mmp_dma_data *dma_data;
121    struct mmp_dma_data dma_data;
122122    struct resource *r;
123    int ret;
124123
125124    r = platform_get_resource(pdev, IORESOURCE_DMA, substream->stream);
126125    if (!r)
...... 
128127
129128    snd_soc_set_runtime_hwparams(substream,
130129                &mmp_pcm_hardware[substream->stream]);
131    dma_data = devm_kzalloc(&pdev->dev,
132            sizeof(struct mmp_dma_data), GFP_KERNEL);
133    if (dma_data == NULL)
134        return -ENOMEM;
135130
136    dma_data->dma_res = r;
137    dma_data->ssp_id = cpu_dai->id;
131    dma_data.dma_res = r;
132    dma_data.ssp_id = cpu_dai->id;
138133
139    ret = snd_dmaengine_pcm_open(substream, filter, dma_data);
140    if (ret) {
141        devm_kfree(&pdev->dev, dma_data);
142        return ret;
143    }
144
145    snd_dmaengine_pcm_set_data(substream, dma_data);
146    return 0;
147}
148
149static int mmp_pcm_close(struct snd_pcm_substream *substream)
150{
151    struct mmp_dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
152    struct snd_soc_pcm_runtime *rtd = substream->private_data;
153    struct platform_device *pdev = to_platform_device(rtd->platform->dev);
154
155    snd_dmaengine_pcm_close(substream);
156    devm_kfree(&pdev->dev, dma_data);
157    return 0;
134    return snd_dmaengine_pcm_open(substream, filter, &dma_data);
158135}
159136
160137static int mmp_pcm_mmap(struct snd_pcm_substream *substream,
...... 
171148
172149struct snd_pcm_ops mmp_pcm_ops = {
173150    .open = mmp_pcm_open,
174    .close = mmp_pcm_close,
151    .close = snd_dmaengine_pcm_close,
175152    .ioctl = snd_pcm_lib_ioctl,
176153    .hw_params = mmp_pcm_hw_params,
177154    .trigger = snd_dmaengine_pcm_trigger,

Archive Download the corresponding diff file



interactive