mirror of https://gitee.com/openkylin/linux.git
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;
|
int ret = 0;
|
||||||
struct snd_soc_dai_driver *dai;
|
struct snd_soc_dai_driver *dai;
|
||||||
|
|
||||||
ssi = kzalloc(sizeof(*ssi), GFP_KERNEL);
|
ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi), GFP_KERNEL);
|
||||||
if (!ssi)
|
if (!ssi)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
dev_set_drvdata(&pdev->dev, ssi);
|
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->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)) {
|
if (IS_ERR(ssi->clk)) {
|
||||||
ret = PTR_ERR(ssi->clk);
|
ret = PTR_ERR(ssi->clk);
|
||||||
dev_err(&pdev->dev, "Cannot get the clock: %d\n",
|
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;
|
goto failed_get_resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) {
|
ssi->base = devm_request_and_ioremap(&pdev->dev, res);
|
||||||
dev_err(&pdev->dev, "request_mem_region failed\n");
|
|
||||||
ret = -EBUSY;
|
|
||||||
goto failed_get_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssi->base = ioremap(res->start, resource_size(res));
|
|
||||||
if (!ssi->base) {
|
if (!ssi->base) {
|
||||||
dev_err(&pdev->dev, "ioremap failed\n");
|
dev_err(&pdev->dev, "ioremap failed\n");
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto failed_ioremap;
|
goto failed_register;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssi->flags & IMX_SSI_USE_AC97) {
|
if (ssi->flags & IMX_SSI_USE_AC97) {
|
||||||
if (ac97_ssi) {
|
if (ac97_ssi) {
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto failed_ac97;
|
goto failed_register;
|
||||||
}
|
}
|
||||||
ac97_ssi = ssi;
|
ac97_ssi = ssi;
|
||||||
setup_channel_to_ac97(ssi);
|
setup_channel_to_ac97(ssi);
|
||||||
|
@ -636,15 +630,10 @@ static int imx_ssi_probe(struct platform_device *pdev)
|
||||||
failed_pdev_fiq_alloc:
|
failed_pdev_fiq_alloc:
|
||||||
snd_soc_unregister_dai(&pdev->dev);
|
snd_soc_unregister_dai(&pdev->dev);
|
||||||
failed_register:
|
failed_register:
|
||||||
failed_ac97:
|
|
||||||
iounmap(ssi->base);
|
|
||||||
failed_ioremap:
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
release_mem_region(res->start, resource_size(res));
|
||||||
failed_get_resource:
|
failed_get_resource:
|
||||||
clk_disable_unprepare(ssi->clk);
|
clk_disable_unprepare(ssi->clk);
|
||||||
clk_put(ssi->clk);
|
|
||||||
failed_clk:
|
failed_clk:
|
||||||
kfree(ssi);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -662,11 +651,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev)
|
||||||
if (ssi->flags & IMX_SSI_USE_AC97)
|
if (ssi->flags & IMX_SSI_USE_AC97)
|
||||||
ac97_ssi = NULL;
|
ac97_ssi = NULL;
|
||||||
|
|
||||||
iounmap(ssi->base);
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
release_mem_region(res->start, resource_size(res));
|
||||||
clk_disable_unprepare(ssi->clk);
|
clk_disable_unprepare(ssi->clk);
|
||||||
clk_put(ssi->clk);
|
|
||||||
kfree(ssi);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue