aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-11-22 20:21:20 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-23 06:09:13 -0500
commite4e4c18a930ff11940ba2c525676566bd631706f (patch)
tree57fd1273ff412525b8271fe42b2b8a4dccf36dc7 /sound/soc/tegra
parent186bcda6f6217dc4b5353c3474121bc1194847f6 (diff)
ASoC: Tegra+WM8903 machine: Use devm_ APIs and module_platform_driver
module_platform_driver 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/soc/tegra')
-rw-r--r--sound/soc/tegra/tegra_wm8903.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index 9b0ee151093..33feee81668 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -390,17 +390,19 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
390 return -EINVAL; 390 return -EINVAL;
391 } 391 }
392 392
393 machine = kzalloc(sizeof(struct tegra_wm8903), GFP_KERNEL); 393 machine = devm_kzalloc(&pdev->dev, sizeof(struct tegra_wm8903),
394 GFP_KERNEL);
394 if (!machine) { 395 if (!machine) {
395 dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n"); 396 dev_err(&pdev->dev, "Can't allocate tegra_wm8903 struct\n");
396 return -ENOMEM; 397 ret = -ENOMEM;
398 goto err;
397 } 399 }
398 400
399 machine->pdata = pdata; 401 machine->pdata = pdata;
400 402
401 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); 403 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
402 if (ret) 404 if (ret)
403 goto err_free_machine; 405 goto err;
404 406
405 card->dev = &pdev->dev; 407 card->dev = &pdev->dev;
406 platform_set_drvdata(pdev, card); 408 platform_set_drvdata(pdev, card);
@@ -431,8 +433,7 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
431 433
432err_fini_utils: 434err_fini_utils:
433 tegra_asoc_utils_fini(&machine->util_data); 435 tegra_asoc_utils_fini(&machine->util_data);
434err_free_machine: 436err:
435 kfree(machine);
436 return ret; 437 return ret;
437} 438}
438 439
@@ -460,8 +461,6 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
460 461
461 tegra_asoc_utils_fini(&machine->util_data); 462 tegra_asoc_utils_fini(&machine->util_data);
462 463
463 kfree(machine);
464
465 return 0; 464 return 0;
466} 465}
467 466
@@ -474,18 +473,7 @@ static struct platform_driver tegra_wm8903_driver = {
474 .probe = tegra_wm8903_driver_probe, 473 .probe = tegra_wm8903_driver_probe,
475 .remove = __devexit_p(tegra_wm8903_driver_remove), 474 .remove = __devexit_p(tegra_wm8903_driver_remove),
476}; 475};
477 476module_platform_driver(tegra_wm8903_driver);
478static int __init tegra_wm8903_modinit(void)
479{
480 return platform_driver_register(&tegra_wm8903_driver);
481}
482module_init(tegra_wm8903_modinit);
483
484static void __exit tegra_wm8903_modexit(void)
485{
486 platform_driver_unregister(&tegra_wm8903_driver);
487}
488module_exit(tegra_wm8903_modexit);
489 477
490MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 478MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
491MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver"); 479MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");