diff options
author | H Hartley Sweeten <hartleys@visionengravers.com> | 2012-03-26 19:00:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-01 06:28:29 -0400 |
commit | e7cff0abf99a0895bc2094e08809bd5e0c4f6a4a (patch) | |
tree | 5a8d0b74d86549aa14ed66ccaf49c2e9bbb43ebc /sound/soc/ep93xx | |
parent | b46b373f4084cc02d4d41a5a42199fe8462c2f13 (diff) |
ASoC: ep93xx-ac97: use devm_* helpers to cleanup probe
Use the devm_* helpers to cleanup the probe routine. This also eliminates
having to carry the mem and irq values in the private data for the remove.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Tested-by: Mika Westerberg <mika.westerberg@iki.fi>
Acked-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/ep93xx')
-rw-r--r-- | sound/soc/ep93xx/ep93xx-ac97.c | 74 |
1 files changed, 26 insertions, 48 deletions
diff --git a/sound/soc/ep93xx/ep93xx-ac97.c b/sound/soc/ep93xx/ep93xx-ac97.c index 0678637abd66..bdffab33e160 100644 --- a/sound/soc/ep93xx/ep93xx-ac97.c +++ b/sound/soc/ep93xx/ep93xx-ac97.c | |||
@@ -87,17 +87,13 @@ | |||
87 | * struct ep93xx_ac97_info - EP93xx AC97 controller info structure | 87 | * struct ep93xx_ac97_info - EP93xx AC97 controller info structure |
88 | * @lock: mutex serializing access to the bus (slot 1 & 2 ops) | 88 | * @lock: mutex serializing access to the bus (slot 1 & 2 ops) |
89 | * @dev: pointer to the platform device dev structure | 89 | * @dev: pointer to the platform device dev structure |
90 | * @mem: physical memory resource for the registers | ||
91 | * @regs: mapped AC97 controller registers | 90 | * @regs: mapped AC97 controller registers |
92 | * @irq: AC97 interrupt number | ||
93 | * @done: bus ops wait here for an interrupt | 91 | * @done: bus ops wait here for an interrupt |
94 | */ | 92 | */ |
95 | struct ep93xx_ac97_info { | 93 | struct ep93xx_ac97_info { |
96 | struct mutex lock; | 94 | struct mutex lock; |
97 | struct device *dev; | 95 | struct device *dev; |
98 | struct resource *mem; | ||
99 | void __iomem *regs; | 96 | void __iomem *regs; |
100 | int irq; | ||
101 | struct completion done; | 97 | struct completion done; |
102 | }; | 98 | }; |
103 | 99 | ||
@@ -359,66 +355,50 @@ static struct snd_soc_dai_driver ep93xx_ac97_dai = { | |||
359 | static int __devinit ep93xx_ac97_probe(struct platform_device *pdev) | 355 | static int __devinit ep93xx_ac97_probe(struct platform_device *pdev) |
360 | { | 356 | { |
361 | struct ep93xx_ac97_info *info; | 357 | struct ep93xx_ac97_info *info; |
358 | struct resource *res; | ||
359 | unsigned int irq; | ||
362 | int ret; | 360 | int ret; |
363 | 361 | ||
364 | info = kzalloc(sizeof(struct ep93xx_ac97_info), GFP_KERNEL); | 362 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
365 | if (!info) | 363 | if (!info) |
366 | return -ENOMEM; | 364 | return -ENOMEM; |
367 | 365 | ||
368 | dev_set_drvdata(&pdev->dev, info); | 366 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
369 | 367 | if (!res) | |
370 | mutex_init(&info->lock); | 368 | return -ENODEV; |
371 | init_completion(&info->done); | ||
372 | info->dev = &pdev->dev; | ||
373 | 369 | ||
374 | info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 370 | info->regs = devm_request_and_ioremap(&pdev->dev, res); |
375 | if (!info->mem) { | 371 | if (!info->regs) |
376 | ret = -ENXIO; | 372 | return -ENXIO; |
377 | goto fail_free_info; | ||
378 | } | ||
379 | 373 | ||
380 | info->irq = platform_get_irq(pdev, 0); | 374 | irq = platform_get_irq(pdev, 0); |
381 | if (!info->irq) { | 375 | if (!irq) |
382 | ret = -ENXIO; | 376 | return -ENODEV; |
383 | goto fail_free_info; | ||
384 | } | ||
385 | 377 | ||
386 | if (!request_mem_region(info->mem->start, resource_size(info->mem), | 378 | ret = devm_request_irq(&pdev->dev, irq, ep93xx_ac97_interrupt, |
387 | pdev->name)) { | 379 | IRQF_TRIGGER_HIGH, pdev->name, info); |
388 | ret = -EBUSY; | 380 | if (ret) |
389 | goto fail_free_info; | 381 | goto fail; |
390 | } | ||
391 | 382 | ||
392 | info->regs = ioremap(info->mem->start, resource_size(info->mem)); | 383 | dev_set_drvdata(&pdev->dev, info); |
393 | if (!info->regs) { | ||
394 | ret = -ENOMEM; | ||
395 | goto fail_release_mem; | ||
396 | } | ||
397 | 384 | ||
398 | ret = request_irq(info->irq, ep93xx_ac97_interrupt, IRQF_TRIGGER_HIGH, | 385 | mutex_init(&info->lock); |
399 | pdev->name, info); | 386 | init_completion(&info->done); |
400 | if (ret) | 387 | info->dev = &pdev->dev; |
401 | goto fail_unmap_mem; | ||
402 | 388 | ||
403 | ep93xx_ac97_info = info; | 389 | ep93xx_ac97_info = info; |
404 | platform_set_drvdata(pdev, info); | 390 | platform_set_drvdata(pdev, info); |
405 | 391 | ||
406 | ret = snd_soc_register_dai(&pdev->dev, &ep93xx_ac97_dai); | 392 | ret = snd_soc_register_dai(&pdev->dev, &ep93xx_ac97_dai); |
407 | if (ret) | 393 | if (ret) |
408 | goto fail_free_irq; | 394 | goto fail; |
409 | 395 | ||
410 | return 0; | 396 | return 0; |
411 | 397 | ||
412 | fail_free_irq: | 398 | fail: |
413 | platform_set_drvdata(pdev, NULL); | 399 | platform_set_drvdata(pdev, NULL); |
414 | free_irq(info->irq, info); | 400 | ep93xx_ac97_info = NULL; |
415 | fail_unmap_mem: | 401 | dev_set_drvdata(&pdev->dev, NULL); |
416 | iounmap(info->regs); | ||
417 | fail_release_mem: | ||
418 | release_mem_region(info->mem->start, resource_size(info->mem)); | ||
419 | fail_free_info: | ||
420 | kfree(info); | ||
421 | |||
422 | return ret; | 402 | return ret; |
423 | } | 403 | } |
424 | 404 | ||
@@ -431,11 +411,9 @@ static int __devexit ep93xx_ac97_remove(struct platform_device *pdev) | |||
431 | /* disable the AC97 controller */ | 411 | /* disable the AC97 controller */ |
432 | ep93xx_ac97_write_reg(info, AC97GCR, 0); | 412 | ep93xx_ac97_write_reg(info, AC97GCR, 0); |
433 | 413 | ||
434 | free_irq(info->irq, info); | ||
435 | iounmap(info->regs); | ||
436 | release_mem_region(info->mem->start, resource_size(info->mem)); | ||
437 | platform_set_drvdata(pdev, NULL); | 414 | platform_set_drvdata(pdev, NULL); |
438 | kfree(info); | 415 | ep93xx_ac97_info = NULL; |
416 | dev_set_drvdata(&pdev->dev, NULL); | ||
439 | 417 | ||
440 | return 0; | 418 | return 0; |
441 | } | 419 | } |