diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-03-22 09:12:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-26 10:17:03 -0400 |
commit | ac581e60dfb4cc55ac20cca18202c7689d324aa7 (patch) | |
tree | 39d4a2c361d334a4891cedd673a95b1d859140dc | |
parent | 453807f3006757a5661c4000262d7d9284b5214c (diff) |
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>
-rw-r--r-- | sound/soc/pxa/mmp-pcm.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 190eb0bccf5f..6c3980252bf6 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c | |||
@@ -118,9 +118,8 @@ static int mmp_pcm_open(struct snd_pcm_substream *substream) | |||
118 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 118 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
119 | struct platform_device *pdev = to_platform_device(rtd->platform->dev); | 119 | struct platform_device *pdev = to_platform_device(rtd->platform->dev); |
120 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 120 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
121 | struct mmp_dma_data *dma_data; | 121 | struct mmp_dma_data dma_data; |
122 | struct resource *r; | 122 | struct resource *r; |
123 | int ret; | ||
124 | 123 | ||
125 | r = platform_get_resource(pdev, IORESOURCE_DMA, substream->stream); | 124 | r = platform_get_resource(pdev, IORESOURCE_DMA, substream->stream); |
126 | if (!r) | 125 | if (!r) |
@@ -128,33 +127,11 @@ static int mmp_pcm_open(struct snd_pcm_substream *substream) | |||
128 | 127 | ||
129 | snd_soc_set_runtime_hwparams(substream, | 128 | snd_soc_set_runtime_hwparams(substream, |
130 | &mmp_pcm_hardware[substream->stream]); | 129 | &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; | ||
135 | 130 | ||
136 | dma_data->dma_res = r; | 131 | dma_data.dma_res = r; |
137 | dma_data->ssp_id = cpu_dai->id; | 132 | dma_data.ssp_id = cpu_dai->id; |
138 | 133 | ||
139 | ret = snd_dmaengine_pcm_open(substream, filter, dma_data); | 134 | return 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 | |||
149 | static 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; | ||
158 | } | 135 | } |
159 | 136 | ||
160 | static int mmp_pcm_mmap(struct snd_pcm_substream *substream, | 137 | static int mmp_pcm_mmap(struct snd_pcm_substream *substream, |
@@ -171,7 +148,7 @@ static int mmp_pcm_mmap(struct snd_pcm_substream *substream, | |||
171 | 148 | ||
172 | struct snd_pcm_ops mmp_pcm_ops = { | 149 | struct snd_pcm_ops mmp_pcm_ops = { |
173 | .open = mmp_pcm_open, | 150 | .open = mmp_pcm_open, |
174 | .close = mmp_pcm_close, | 151 | .close = snd_dmaengine_pcm_close, |
175 | .ioctl = snd_pcm_lib_ioctl, | 152 | .ioctl = snd_pcm_lib_ioctl, |
176 | .hw_params = mmp_pcm_hw_params, | 153 | .hw_params = mmp_pcm_hw_params, |
177 | .trigger = snd_dmaengine_pcm_trigger, | 154 | .trigger = snd_dmaengine_pcm_trigger, |