aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-11-22 20:21:16 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-23 05:24:10 -0500
commitbea0ed0825be288f9fc98696fc476066776b26be (patch)
treeb85ffed46af0c5886d8e0af57077b99fc3719680 /sound
parent65713ce8442b42c6f688bd8b0950a49d8f4dcf5f (diff)
ASoC: Tegra I2S: Use devm_ APIs and module_platform_driver
module_platform_drive saves some boiler-plate code. The devm_ APIs remove the need to manually clean up allocations, thus removing some code. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra_i2s.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index 33e62fcdfce3..76014f0d8a29 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -362,11 +362,11 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
362 return -EINVAL; 362 return -EINVAL;
363 } 363 }
364 364
365 i2s = kzalloc(sizeof(struct tegra_i2s), GFP_KERNEL); 365 i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra_i2s), GFP_KERNEL);
366 if (!i2s) { 366 if (!i2s) {
367 dev_err(&pdev->dev, "Can't allocate tegra_i2s\n"); 367 dev_err(&pdev->dev, "Can't allocate tegra_i2s\n");
368 ret = -ENOMEM; 368 ret = -ENOMEM;
369 goto exit; 369 goto err;
370 } 370 }
371 dev_set_drvdata(&pdev->dev, i2s); 371 dev_set_drvdata(&pdev->dev, i2s);
372 372
@@ -374,7 +374,7 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
374 if (IS_ERR(i2s->clk_i2s)) { 374 if (IS_ERR(i2s->clk_i2s)) {
375 dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); 375 dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
376 ret = PTR_ERR(i2s->clk_i2s); 376 ret = PTR_ERR(i2s->clk_i2s);
377 goto err_free; 377 goto err;
378 } 378 }
379 379
380 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 380 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -391,19 +391,19 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
391 goto err_clk_put; 391 goto err_clk_put;
392 } 392 }
393 393
394 memregion = request_mem_region(mem->start, resource_size(mem), 394 memregion = devm_request_mem_region(&pdev->dev, mem->start,
395 DRV_NAME); 395 resource_size(mem), DRV_NAME);
396 if (!memregion) { 396 if (!memregion) {
397 dev_err(&pdev->dev, "Memory region already claimed\n"); 397 dev_err(&pdev->dev, "Memory region already claimed\n");
398 ret = -EBUSY; 398 ret = -EBUSY;
399 goto err_clk_put; 399 goto err_clk_put;
400 } 400 }
401 401
402 i2s->regs = ioremap(mem->start, resource_size(mem)); 402 i2s->regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
403 if (!i2s->regs) { 403 if (!i2s->regs) {
404 dev_err(&pdev->dev, "ioremap failed\n"); 404 dev_err(&pdev->dev, "ioremap failed\n");
405 ret = -ENOMEM; 405 ret = -ENOMEM;
406 goto err_release; 406 goto err_clk_put;
407 } 407 }
408 408
409 i2s->capture_dma_data.addr = mem->start + TEGRA_I2S_FIFO2; 409 i2s->capture_dma_data.addr = mem->start + TEGRA_I2S_FIFO2;
@@ -422,43 +422,29 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
422 if (ret) { 422 if (ret) {
423 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); 423 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
424 ret = -ENOMEM; 424 ret = -ENOMEM;
425 goto err_unmap; 425 goto err_clk_put;
426 } 426 }
427 427
428 tegra_i2s_debug_add(i2s, pdev->id); 428 tegra_i2s_debug_add(i2s, pdev->id);
429 429
430 return 0; 430 return 0;
431 431
432err_unmap:
433 iounmap(i2s->regs);
434err_release:
435 release_mem_region(mem->start, resource_size(mem));
436err_clk_put: 432err_clk_put:
437 clk_put(i2s->clk_i2s); 433 clk_put(i2s->clk_i2s);
438err_free: 434err:
439 kfree(i2s);
440exit:
441 return ret; 435 return ret;
442} 436}
443 437
444static int __devexit tegra_i2s_platform_remove(struct platform_device *pdev) 438static int __devexit tegra_i2s_platform_remove(struct platform_device *pdev)
445{ 439{
446 struct tegra_i2s *i2s = dev_get_drvdata(&pdev->dev); 440 struct tegra_i2s *i2s = dev_get_drvdata(&pdev->dev);
447 struct resource *res;
448 441
449 snd_soc_unregister_dai(&pdev->dev); 442 snd_soc_unregister_dai(&pdev->dev);
450 443
451 tegra_i2s_debug_remove(i2s); 444 tegra_i2s_debug_remove(i2s);
452 445
453 iounmap(i2s->regs);
454
455 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
456 release_mem_region(res->start, resource_size(res));
457
458 clk_put(i2s->clk_i2s); 446 clk_put(i2s->clk_i2s);
459 447
460 kfree(i2s);
461
462 return 0; 448 return 0;
463} 449}
464 450
@@ -470,18 +456,7 @@ static struct platform_driver tegra_i2s_driver = {
470 .probe = tegra_i2s_platform_probe, 456 .probe = tegra_i2s_platform_probe,
471 .remove = __devexit_p(tegra_i2s_platform_remove), 457 .remove = __devexit_p(tegra_i2s_platform_remove),
472}; 458};
473 459module_platform_driver(tegra_i2s_driver);
474static int __init snd_tegra_i2s_init(void)
475{
476 return platform_driver_register(&tegra_i2s_driver);
477}
478module_init(snd_tegra_i2s_init);
479
480static void __exit snd_tegra_i2s_exit(void)
481{
482 platform_driver_unregister(&tegra_i2s_driver);
483}
484module_exit(snd_tegra_i2s_exit);
485 460
486MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 461MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
487MODULE_DESCRIPTION("Tegra I2S ASoC driver"); 462MODULE_DESCRIPTION("Tegra I2S ASoC driver");