diff options
author | Julia Lawall <julia.lawall@lip6.fr> | 2011-12-29 11:51:29 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-02 08:08:28 -0500 |
commit | 6065abf5ce8ba0ad945d21255a1d581ca30f2e18 (patch) | |
tree | f47deade36014381201cadda5a0ec4b88e37a60b /sound/soc/au1x | |
parent | be547dd1727fce22ec001006ea4da169df32b6c6 (diff) |
ASoC: ac97c.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/ac97c.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/sound/soc/au1x/ac97c.c b/sound/soc/au1x/ac97c.c index 7771934b93e2..c5ac2449563a 100644 --- a/sound/soc/au1x/ac97c.c +++ b/sound/soc/au1x/ac97c.c | |||
@@ -229,35 +229,34 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) | |||
229 | struct resource *iores, *dmares; | 229 | struct resource *iores, *dmares; |
230 | struct au1xpsc_audio_data *ctx; | 230 | struct au1xpsc_audio_data *ctx; |
231 | 231 | ||
232 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | 232 | ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); |
233 | if (!ctx) | 233 | if (!ctx) |
234 | return -ENOMEM; | 234 | return -ENOMEM; |
235 | 235 | ||
236 | mutex_init(&ctx->lock); | 236 | mutex_init(&ctx->lock); |
237 | 237 | ||
238 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 238 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
239 | if (!iores) { | 239 | if (!iores) |
240 | ret = -ENODEV; | 240 | return -ENODEV; |
241 | goto out0; | ||
242 | } | ||
243 | 241 | ||
244 | ret = -EBUSY; | 242 | if (!devm_request_mem_region(&pdev->dev, iores->start, |
245 | if (!request_mem_region(iores->start, resource_size(iores), | 243 | resource_size(iores), |
246 | pdev->name)) | 244 | pdev->name)) |
247 | goto out0; | 245 | return -EBUSY; |
248 | 246 | ||
249 | ctx->mmio = ioremap_nocache(iores->start, resource_size(iores)); | 247 | ctx->mmio = devm_ioremap_nocache(&pdev->dev, iores->start, |
248 | resource_size(iores)); | ||
250 | if (!ctx->mmio) | 249 | if (!ctx->mmio) |
251 | goto out1; | 250 | return -EBUSY; |
252 | 251 | ||
253 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 252 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
254 | if (!dmares) | 253 | if (!dmares) |
255 | goto out2; | 254 | return -EBUSY; |
256 | ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; | 255 | ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; |
257 | 256 | ||
258 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); | 257 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); |
259 | if (!dmares) | 258 | if (!dmares) |
260 | goto out2; | 259 | return -EBUSY; |
261 | ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; | 260 | ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; |
262 | 261 | ||
263 | /* switch it on */ | 262 | /* switch it on */ |
@@ -271,33 +270,20 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) | |||
271 | 270 | ||
272 | ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver); | 271 | ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver); |
273 | if (ret) | 272 | if (ret) |
274 | goto out2; | 273 | return ret; |
275 | 274 | ||
276 | ac97c_workdata = ctx; | 275 | ac97c_workdata = ctx; |
277 | return 0; | 276 | return 0; |
278 | |||
279 | out2: | ||
280 | iounmap(ctx->mmio); | ||
281 | out1: | ||
282 | release_mem_region(iores->start, resource_size(iores)); | ||
283 | out0: | ||
284 | kfree(ctx); | ||
285 | return ret; | ||
286 | } | 277 | } |
287 | 278 | ||
288 | static int __devexit au1xac97c_drvremove(struct platform_device *pdev) | 279 | static int __devexit au1xac97c_drvremove(struct platform_device *pdev) |
289 | { | 280 | { |
290 | struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev); | 281 | struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev); |
291 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
292 | 282 | ||
293 | snd_soc_unregister_dai(&pdev->dev); | 283 | snd_soc_unregister_dai(&pdev->dev); |
294 | 284 | ||
295 | WR(ctx, AC97_ENABLE, EN_D); /* clock off, disable */ | 285 | WR(ctx, AC97_ENABLE, EN_D); /* clock off, disable */ |
296 | 286 | ||
297 | iounmap(ctx->mmio); | ||
298 | release_mem_region(r->start, resource_size(r)); | ||
299 | kfree(ctx); | ||
300 | |||
301 | ac97c_workdata = NULL; /* MDEV */ | 287 | ac97c_workdata = NULL; /* MDEV */ |
302 | 288 | ||
303 | return 0; | 289 | return 0; |