aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x
diff options
context:
space:
mode:
authorJulia Lawall <julia.lawall@lip6.fr>2011-12-29 11:51:26 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-02 08:08:13 -0500
commit6d8955262ab4cbfcb3ddaca4f978d27d9c088a75 (patch)
tree130ac129e273e3eda656a99f6c0facba14ab9d7b /sound/soc/au1x
parent8d9626d72833bf68791e4cf9ac151c96c44c0f87 (diff)
ASoC: i2sc.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_kzalloc, devm_request_mem_region and devm_ioremap for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/au1x')
-rw-r--r--sound/soc/au1x/i2sc.c45
1 files changed, 13 insertions, 32 deletions
diff --git a/sound/soc/au1x/i2sc.c b/sound/soc/au1x/i2sc.c
index cb53ad87d0a9..d4b9e364a47a 100644
--- a/sound/soc/au1x/i2sc.c
+++ b/sound/soc/au1x/i2sc.c
@@ -227,69 +227,50 @@ static struct snd_soc_dai_driver au1xi2s_dai_driver = {
227 227
228static int __devinit au1xi2s_drvprobe(struct platform_device *pdev) 228static int __devinit au1xi2s_drvprobe(struct platform_device *pdev)
229{ 229{
230 int ret;
231 struct resource *iores, *dmares; 230 struct resource *iores, *dmares;
232 struct au1xpsc_audio_data *ctx; 231 struct au1xpsc_audio_data *ctx;
233 232
234 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 233 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
235 if (!ctx) 234 if (!ctx)
236 return -ENOMEM; 235 return -ENOMEM;
237 236
238 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 237 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!iores) { 238 if (!iores)
240 ret = -ENODEV; 239 return -ENODEV;
241 goto out0;
242 }
243 240
244 ret = -EBUSY; 241 if (!devm_request_mem_region(&pdev->dev, iores->start,
245 if (!request_mem_region(iores->start, resource_size(iores), 242 resource_size(iores),
246 pdev->name)) 243 pdev->name))
247 goto out0; 244 return -EBUSY;
248 245
249 ctx->mmio = ioremap_nocache(iores->start, resource_size(iores)); 246 ctx->mmio = devm_ioremap_nocache(&pdev->dev, iores->start,
247 resource_size(iores));
250 if (!ctx->mmio) 248 if (!ctx->mmio)
251 goto out1; 249 return -EBUSY;
252 250
253 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 251 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
254 if (!dmares) 252 if (!dmares)
255 goto out2; 253 return -EBUSY;
256 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; 254 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
257 255
258 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); 256 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
259 if (!dmares) 257 if (!dmares)
260 goto out2; 258 return -EBUSY;
261 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; 259 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
262 260
263 platform_set_drvdata(pdev, ctx); 261 platform_set_drvdata(pdev, ctx);
264 262
265 ret = snd_soc_register_dai(&pdev->dev, &au1xi2s_dai_driver); 263 return snd_soc_register_dai(&pdev->dev, &au1xi2s_dai_driver);
266 if (ret)
267 goto out2;
268
269 return 0;
270
271out2:
272 iounmap(ctx->mmio);
273out1:
274 release_mem_region(iores->start, resource_size(iores));
275out0:
276 kfree(ctx);
277 return ret;
278} 264}
279 265
280static int __devexit au1xi2s_drvremove(struct platform_device *pdev) 266static int __devexit au1xi2s_drvremove(struct platform_device *pdev)
281{ 267{
282 struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev); 268 struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev);
283 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
284 269
285 snd_soc_unregister_dai(&pdev->dev); 270 snd_soc_unregister_dai(&pdev->dev);
286 271
287 WR(ctx, I2S_ENABLE, EN_D); /* clock off, disable */ 272 WR(ctx, I2S_ENABLE, EN_D); /* clock off, disable */
288 273
289 iounmap(ctx->mmio);
290 release_mem_region(r->start, resource_size(r));
291 kfree(ctx);
292
293 return 0; 274 return 0;
294} 275}
295 276