diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-12-03 12:53:02 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-12-03 13:07:48 -0500 |
commit | b84c9ce809c91b3c613c967abcee90ebd6582092 (patch) | |
tree | 436d0646eeb3cb73e049fd05040638659f80df9d /sound/soc/jz4740 | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
ASoC: jz4740-i2s: Use managed resources
Makes the code a bit shorter.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/jz4740')
-rw-r--r-- | sound/soc/jz4740/jz4740-i2s.c | 85 |
1 files changed, 15 insertions, 70 deletions
diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 4c849a49c72a..a0b6a85d89cf 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c | |||
@@ -432,91 +432,36 @@ static const struct snd_soc_component_driver jz4740_i2s_component = { | |||
432 | static int jz4740_i2s_dev_probe(struct platform_device *pdev) | 432 | static int jz4740_i2s_dev_probe(struct platform_device *pdev) |
433 | { | 433 | { |
434 | struct jz4740_i2s *i2s; | 434 | struct jz4740_i2s *i2s; |
435 | struct resource *mem; | ||
435 | int ret; | 436 | int ret; |
436 | 437 | ||
437 | i2s = kzalloc(sizeof(*i2s), GFP_KERNEL); | 438 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); |
438 | |||
439 | if (!i2s) | 439 | if (!i2s) |
440 | return -ENOMEM; | 440 | return -ENOMEM; |
441 | 441 | ||
442 | i2s->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 442 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
443 | if (!i2s->mem) { | 443 | i2s->base = devm_ioremap_resource(&pdev->dev, mem); |
444 | ret = -ENOENT; | 444 | if (IS_ERR(i2s->base)) |
445 | goto err_free; | 445 | return PTR_ERR(i2s->base); |
446 | } | ||
447 | |||
448 | i2s->mem = request_mem_region(i2s->mem->start, resource_size(i2s->mem), | ||
449 | pdev->name); | ||
450 | if (!i2s->mem) { | ||
451 | ret = -EBUSY; | ||
452 | goto err_free; | ||
453 | } | ||
454 | |||
455 | i2s->base = ioremap_nocache(i2s->mem->start, resource_size(i2s->mem)); | ||
456 | if (!i2s->base) { | ||
457 | ret = -EBUSY; | ||
458 | goto err_release_mem_region; | ||
459 | } | ||
460 | 446 | ||
461 | i2s->phys_base = i2s->mem->start; | 447 | i2s->phys_base = mem->start; |
462 | 448 | ||
463 | i2s->clk_aic = clk_get(&pdev->dev, "aic"); | 449 | i2s->clk_aic = devm_clk_get(&pdev->dev, "aic"); |
464 | if (IS_ERR(i2s->clk_aic)) { | 450 | if (IS_ERR(i2s->clk_aic)) |
465 | ret = PTR_ERR(i2s->clk_aic); | 451 | return PTR_ERR(i2s->clk_aic); |
466 | goto err_iounmap; | ||
467 | } | ||
468 | 452 | ||
469 | i2s->clk_i2s = clk_get(&pdev->dev, "i2s"); | 453 | i2s->clk_i2s = devm_clk_get(&pdev->dev, "i2s"); |
470 | if (IS_ERR(i2s->clk_i2s)) { | 454 | if (IS_ERR(i2s->clk_i2s)) |
471 | ret = PTR_ERR(i2s->clk_i2s); | 455 | return PTR_ERR(i2s->clk_i2s); |
472 | goto err_clk_put_aic; | ||
473 | } | ||
474 | 456 | ||
475 | platform_set_drvdata(pdev, i2s); | 457 | platform_set_drvdata(pdev, i2s); |
476 | ret = snd_soc_register_component(&pdev->dev, &jz4740_i2s_component, | ||
477 | &jz4740_i2s_dai, 1); | ||
478 | |||
479 | if (ret) { | ||
480 | dev_err(&pdev->dev, "Failed to register DAI\n"); | ||
481 | goto err_clk_put_i2s; | ||
482 | } | ||
483 | |||
484 | return 0; | ||
485 | |||
486 | err_clk_put_i2s: | ||
487 | clk_put(i2s->clk_i2s); | ||
488 | err_clk_put_aic: | ||
489 | clk_put(i2s->clk_aic); | ||
490 | err_iounmap: | ||
491 | iounmap(i2s->base); | ||
492 | err_release_mem_region: | ||
493 | release_mem_region(i2s->mem->start, resource_size(i2s->mem)); | ||
494 | err_free: | ||
495 | kfree(i2s); | ||
496 | |||
497 | return ret; | ||
498 | } | ||
499 | |||
500 | static int jz4740_i2s_dev_remove(struct platform_device *pdev) | ||
501 | { | ||
502 | struct jz4740_i2s *i2s = platform_get_drvdata(pdev); | ||
503 | |||
504 | snd_soc_unregister_component(&pdev->dev); | ||
505 | |||
506 | clk_put(i2s->clk_i2s); | ||
507 | clk_put(i2s->clk_aic); | ||
508 | 458 | ||
509 | iounmap(i2s->base); | 459 | return devm_snd_soc_register_component(&pdev->dev, |
510 | release_mem_region(i2s->mem->start, resource_size(i2s->mem)); | 460 | &jz4740_i2s_component, &jz4740_i2s_dai, 1); |
511 | |||
512 | kfree(i2s); | ||
513 | |||
514 | return 0; | ||
515 | } | 461 | } |
516 | 462 | ||
517 | static struct platform_driver jz4740_i2s_driver = { | 463 | static struct platform_driver jz4740_i2s_driver = { |
518 | .probe = jz4740_i2s_dev_probe, | 464 | .probe = jz4740_i2s_dev_probe, |
519 | .remove = jz4740_i2s_dev_remove, | ||
520 | .driver = { | 465 | .driver = { |
521 | .name = "jz4740-i2s", | 466 | .name = "jz4740-i2s", |
522 | .owner = THIS_MODULE, | 467 | .owner = THIS_MODULE, |