ASoC: fsl: fsl_ssi: Use devm_ functions
Using devm_ functions can make the code cleaner and smaller. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
f1269ae41f
commit
b0a4747a5d
1 changed files with 10 additions and 28 deletions
|
@ -674,7 +674,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
/* The DAI name is the last part of the full name of the node. */
|
/* The DAI name is the last part of the full name of the node. */
|
||||||
p = strrchr(np->full_name, '/') + 1;
|
p = strrchr(np->full_name, '/') + 1;
|
||||||
ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p),
|
ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private) + strlen(p),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!ssi_private) {
|
if (!ssi_private) {
|
||||||
dev_err(&pdev->dev, "could not allocate DAI object\n");
|
dev_err(&pdev->dev, "could not allocate DAI object\n");
|
||||||
|
@ -692,26 +692,24 @@ static int fsl_ssi_probe(struct platform_device *pdev)
|
||||||
ret = of_address_to_resource(np, 0, &res);
|
ret = of_address_to_resource(np, 0, &res);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "could not determine device resources\n");
|
dev_err(&pdev->dev, "could not determine device resources\n");
|
||||||
goto error_kmalloc;
|
return ret;
|
||||||
}
|
}
|
||||||
ssi_private->ssi = of_iomap(np, 0);
|
ssi_private->ssi = of_iomap(np, 0);
|
||||||
if (!ssi_private->ssi) {
|
if (!ssi_private->ssi) {
|
||||||
dev_err(&pdev->dev, "could not map device resources\n");
|
dev_err(&pdev->dev, "could not map device resources\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto error_kmalloc;
|
|
||||||
}
|
}
|
||||||
ssi_private->ssi_phys = res.start;
|
ssi_private->ssi_phys = res.start;
|
||||||
|
|
||||||
ssi_private->irq = irq_of_parse_and_map(np, 0);
|
ssi_private->irq = irq_of_parse_and_map(np, 0);
|
||||||
if (ssi_private->irq == NO_IRQ) {
|
if (ssi_private->irq == NO_IRQ) {
|
||||||
dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
|
dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
|
||||||
ret = -ENXIO;
|
return -ENXIO;
|
||||||
goto error_iomap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The 'name' should not have any slashes in it. */
|
/* The 'name' should not have any slashes in it. */
|
||||||
ret = request_irq(ssi_private->irq, fsl_ssi_isr, 0, ssi_private->name,
|
ret = devm_request_irq(&pdev->dev, ssi_private->irq, fsl_ssi_isr, 0,
|
||||||
ssi_private);
|
ssi_private->name, ssi_private);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "could not claim irq %u\n", ssi_private->irq);
|
dev_err(&pdev->dev, "could not claim irq %u\n", ssi_private->irq);
|
||||||
goto error_irqmap;
|
goto error_irqmap;
|
||||||
|
@ -733,11 +731,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
|
||||||
u32 dma_events[2];
|
u32 dma_events[2];
|
||||||
ssi_private->ssi_on_imx = true;
|
ssi_private->ssi_on_imx = true;
|
||||||
|
|
||||||
ssi_private->clk = clk_get(&pdev->dev, NULL);
|
ssi_private->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(ssi_private->clk)) {
|
if (IS_ERR(ssi_private->clk)) {
|
||||||
ret = PTR_ERR(ssi_private->clk);
|
ret = PTR_ERR(ssi_private->clk);
|
||||||
dev_err(&pdev->dev, "could not get clock: %d\n", ret);
|
dev_err(&pdev->dev, "could not get clock: %d\n", ret);
|
||||||
goto error_irq;
|
goto error_irqmap;
|
||||||
}
|
}
|
||||||
clk_prepare_enable(ssi_private->clk);
|
clk_prepare_enable(ssi_private->clk);
|
||||||
|
|
||||||
|
@ -788,7 +786,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "could not create sysfs %s file\n",
|
dev_err(&pdev->dev, "could not create sysfs %s file\n",
|
||||||
ssi_private->dev_attr.attr.name);
|
ssi_private->dev_attr.attr.name);
|
||||||
goto error_irq;
|
goto error_clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register with ASoC */
|
/* Register with ASoC */
|
||||||
|
@ -851,23 +849,12 @@ error_dev:
|
||||||
device_remove_file(&pdev->dev, dev_attr);
|
device_remove_file(&pdev->dev, dev_attr);
|
||||||
|
|
||||||
error_clk:
|
error_clk:
|
||||||
if (ssi_private->ssi_on_imx) {
|
if (ssi_private->ssi_on_imx)
|
||||||
clk_disable_unprepare(ssi_private->clk);
|
clk_disable_unprepare(ssi_private->clk);
|
||||||
clk_put(ssi_private->clk);
|
|
||||||
}
|
|
||||||
|
|
||||||
error_irq:
|
|
||||||
free_irq(ssi_private->irq, ssi_private);
|
|
||||||
|
|
||||||
error_irqmap:
|
error_irqmap:
|
||||||
irq_dispose_mapping(ssi_private->irq);
|
irq_dispose_mapping(ssi_private->irq);
|
||||||
|
|
||||||
error_iomap:
|
|
||||||
iounmap(ssi_private->ssi);
|
|
||||||
|
|
||||||
error_kmalloc:
|
|
||||||
kfree(ssi_private);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,15 +867,10 @@ static int fsl_ssi_remove(struct platform_device *pdev)
|
||||||
if (ssi_private->ssi_on_imx) {
|
if (ssi_private->ssi_on_imx) {
|
||||||
imx_pcm_dma_exit(pdev);
|
imx_pcm_dma_exit(pdev);
|
||||||
clk_disable_unprepare(ssi_private->clk);
|
clk_disable_unprepare(ssi_private->clk);
|
||||||
clk_put(ssi_private->clk);
|
|
||||||
}
|
}
|
||||||
snd_soc_unregister_component(&pdev->dev);
|
snd_soc_unregister_component(&pdev->dev);
|
||||||
device_remove_file(&pdev->dev, &ssi_private->dev_attr);
|
device_remove_file(&pdev->dev, &ssi_private->dev_attr);
|
||||||
|
|
||||||
free_irq(ssi_private->irq, ssi_private);
|
|
||||||
irq_dispose_mapping(ssi_private->irq);
|
irq_dispose_mapping(ssi_private->irq);
|
||||||
|
|
||||||
kfree(ssi_private);
|
|
||||||
dev_set_drvdata(&pdev->dev, NULL);
|
dev_set_drvdata(&pdev->dev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue