ASoC: imx-ssi: Use devm functions
Using devm_ functions can make the code simpler and smaller. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
02286190f3
commit
ad3ab1bba9
@ -523,7 +523,7 @@ static int imx_ssi_probe(struct platform_device *pdev)
|
||||
int ret = 0;
|
||||
struct snd_soc_dai_driver *dai;
|
||||
|
||||
ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);
|
||||
ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi), GFP_KERNEL);
|
||||
if (!ssi)
|
||||
return -ENOMEM;
|
||||
dev_set_drvdata(&pdev->dev, ssi);
|
||||
@ -536,7 +536,7 @@ static int imx_ssi_probe(struct platform_device *pdev)
|
||||
|
||||
ssi->irq = platform_get_irq(pdev, 0);
|
||||
|
||||
ssi->clk = clk_get(&pdev->dev, NULL);
|
||||
ssi->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(ssi->clk)) {
|
||||
ret = PTR_ERR(ssi->clk);
|
||||
dev_err(&pdev->dev, "Cannot get the clock: %d\n",
|
||||
@ -551,23 +551,17 @@ static int imx_ssi_probe(struct platform_device *pdev)
|
||||
goto failed_get_resource;
|
||||
}
|
||||
|
||||
if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) {
|
||||
dev_err(&pdev->dev, "request_mem_region failed\n");
|
||||
ret = -EBUSY;
|
||||
goto failed_get_resource;
|
||||
}
|
||||
|
||||
ssi->base = ioremap(res->start, resource_size(res));
|
||||
ssi->base = devm_request_and_ioremap(&pdev->dev, res);
|
||||
if (!ssi->base) {
|
||||
dev_err(&pdev->dev, "ioremap failed\n");
|
||||
ret = -ENODEV;
|
||||
goto failed_ioremap;
|
||||
goto failed_register;
|
||||
}
|
||||
|
||||
if (ssi->flags & IMX_SSI_USE_AC97) {
|
||||
if (ac97_ssi) {
|
||||
ret = -EBUSY;
|
||||
goto failed_ac97;
|
||||
goto failed_register;
|
||||
}
|
||||
ac97_ssi = ssi;
|
||||
setup_channel_to_ac97(ssi);
|
||||
@ -636,15 +630,10 @@ static int imx_ssi_probe(struct platform_device *pdev)
|
||||
failed_pdev_fiq_alloc:
|
||||
snd_soc_unregister_dai(&pdev->dev);
|
||||
failed_register:
|
||||
failed_ac97:
|
||||
iounmap(ssi->base);
|
||||
failed_ioremap:
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
failed_get_resource:
|
||||
clk_disable_unprepare(ssi->clk);
|
||||
clk_put(ssi->clk);
|
||||
failed_clk:
|
||||
kfree(ssi);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -662,11 +651,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev)
|
||||
if (ssi->flags & IMX_SSI_USE_AC97)
|
||||
ac97_ssi = NULL;
|
||||
|
||||
iounmap(ssi->base);
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
clk_disable_unprepare(ssi->clk);
|
||||
clk_put(ssi->clk);
|
||||
kfree(ssi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user