Commit f2296d7b authored by Stephen Warren's avatar Stephen Warren Committed by Mark Brown

ASoC: Tegra DAS: 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: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 99c92ae4
...@@ -172,11 +172,11 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) ...@@ -172,11 +172,11 @@ static int __devinit tegra_das_probe(struct platform_device *pdev)
if (das) if (das)
return -ENODEV; return -ENODEV;
das = kzalloc(sizeof(struct tegra_das), GFP_KERNEL); das = devm_kzalloc(&pdev->dev, sizeof(struct tegra_das), GFP_KERNEL);
if (!das) { if (!das) {
dev_err(&pdev->dev, "Can't allocate tegra_das\n"); dev_err(&pdev->dev, "Can't allocate tegra_das\n");
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto err;
} }
das->dev = &pdev->dev; das->dev = &pdev->dev;
...@@ -184,22 +184,22 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) ...@@ -184,22 +184,22 @@ static int __devinit tegra_das_probe(struct platform_device *pdev)
if (!res) { if (!res) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
ret = -ENODEV; ret = -ENODEV;
goto err_free; goto err;
} }
region = request_mem_region(res->start, resource_size(res), region = devm_request_mem_region(&pdev->dev, res->start,
pdev->name); resource_size(res), pdev->name);
if (!region) { if (!region) {
dev_err(&pdev->dev, "Memory region already claimed\n"); dev_err(&pdev->dev, "Memory region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_free; goto err;
} }
das->regs = ioremap(res->start, resource_size(res)); das->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (!das->regs) { if (!das->regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_release; goto err;
} }
tegra_das_debug_add(das); tegra_das_debug_add(das);
...@@ -208,32 +208,18 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) ...@@ -208,32 +208,18 @@ static int __devinit tegra_das_probe(struct platform_device *pdev)
return 0; return 0;
err_release: err:
release_mem_region(res->start, resource_size(res));
err_free:
kfree(das);
das = NULL; das = NULL;
exit:
return ret; return ret;
} }
static int __devexit tegra_das_remove(struct platform_device *pdev) static int __devexit tegra_das_remove(struct platform_device *pdev)
{ {
struct resource *res;
if (!das) if (!das)
return -ENODEV; return -ENODEV;
platform_set_drvdata(pdev, NULL);
tegra_das_debug_remove(das); tegra_das_debug_remove(das);
iounmap(das->regs);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
kfree(das);
das = NULL; das = NULL;
return 0; return 0;
...@@ -246,18 +232,7 @@ static struct platform_driver tegra_das_driver = { ...@@ -246,18 +232,7 @@ static struct platform_driver tegra_das_driver = {
.name = DRV_NAME, .name = DRV_NAME,
}, },
}; };
module_platform_driver(tegra_das_driver);
static int __init tegra_das_modinit(void)
{
return platform_driver_register(&tegra_das_driver);
}
module_init(tegra_das_modinit);
static void __exit tegra_das_modexit(void)
{
platform_driver_unregister(&tegra_das_driver);
}
module_exit(tegra_das_modexit);
MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
MODULE_DESCRIPTION("Tegra DAS driver"); MODULE_DESCRIPTION("Tegra DAS driver");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment