* [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions
@ 2013-07-17 5:00 Fabio Estevam
2013-07-17 5:00 ` [PATCH 2/2] ASoC: fsl: fsl_ssi: Check the return value from clk_prepare_enable() Fabio Estevam
2013-07-17 10:05 ` [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2013-07-17 5:00 UTC (permalink / raw)
To: broonie; +Cc: Fabio Estevam, alsa-devel, shawn.guo, timur
From: Fabio Estevam <fabio.estevam@freescale.com>
Using devm_ functions can make the code cleaner and smaller.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
sound/soc/fsl/fsl_ssi.c | 38 ++++++++++----------------------------
1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 2f2d837..ab8d462 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -680,7 +680,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
/* The DAI name is the last part of the full name of the node. */
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);
if (!ssi_private) {
dev_err(&pdev->dev, "could not allocate DAI object\n");
@@ -698,26 +698,24 @@ static int fsl_ssi_probe(struct platform_device *pdev)
ret = of_address_to_resource(np, 0, &res);
if (ret) {
dev_err(&pdev->dev, "could not determine device resources\n");
- goto error_kmalloc;
+ return ret;
}
ssi_private->ssi = of_iomap(np, 0);
if (!ssi_private->ssi) {
dev_err(&pdev->dev, "could not map device resources\n");
- ret = -ENOMEM;
- goto error_kmalloc;
+ return -ENOMEM;
}
ssi_private->ssi_phys = res.start;
ssi_private->irq = irq_of_parse_and_map(np, 0);
if (ssi_private->irq == NO_IRQ) {
dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
- ret = -ENXIO;
- goto error_iomap;
+ return -ENXIO;
}
/* The 'name' should not have any slashes in it. */
- ret = request_irq(ssi_private->irq, fsl_ssi_isr, 0, ssi_private->name,
- ssi_private);
+ ret = devm_request_irq(&pdev->dev, ssi_private->irq, fsl_ssi_isr, 0,
+ ssi_private->name, ssi_private);
if (ret < 0) {
dev_err(&pdev->dev, "could not claim irq %u\n", ssi_private->irq);
goto error_irqmap;
@@ -739,11 +737,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
u32 dma_events[2];
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)) {
ret = PTR_ERR(ssi_private->clk);
dev_err(&pdev->dev, "could not get clock: %d\n", ret);
- goto error_irq;
+ goto error_irqmap;
}
clk_prepare_enable(ssi_private->clk);
@@ -794,7 +792,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev, "could not create sysfs %s file\n",
ssi_private->dev_attr.attr.name);
- goto error_irq;
+ goto error_clk;
}
/* Register with ASoC */
@@ -857,23 +855,12 @@ error_dev:
device_remove_file(&pdev->dev, dev_attr);
error_clk:
- if (ssi_private->ssi_on_imx) {
+ if (ssi_private->ssi_on_imx)
clk_disable_unprepare(ssi_private->clk);
- clk_put(ssi_private->clk);
- }
-
-error_irq:
- free_irq(ssi_private->irq, ssi_private);
error_irqmap:
irq_dispose_mapping(ssi_private->irq);
-error_iomap:
- iounmap(ssi_private->ssi);
-
-error_kmalloc:
- kfree(ssi_private);
-
return ret;
}
@@ -886,15 +873,10 @@ static int fsl_ssi_remove(struct platform_device *pdev)
if (ssi_private->ssi_on_imx) {
imx_pcm_dma_exit(pdev);
clk_disable_unprepare(ssi_private->clk);
- clk_put(ssi_private->clk);
}
snd_soc_unregister_component(&pdev->dev);
device_remove_file(&pdev->dev, &ssi_private->dev_attr);
-
- free_irq(ssi_private->irq, ssi_private);
irq_dispose_mapping(ssi_private->irq);
-
- kfree(ssi_private);
dev_set_drvdata(&pdev->dev, NULL);
return 0;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] ASoC: fsl: fsl_ssi: Check the return value from clk_prepare_enable()
2013-07-17 5:00 [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Fabio Estevam
@ 2013-07-17 5:00 ` Fabio Estevam
2013-07-17 10:05 ` [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2013-07-17 5:00 UTC (permalink / raw)
To: broonie; +Cc: Fabio Estevam, alsa-devel, shawn.guo, timur
From: Fabio Estevam <fabio.estevam@freescale.com>
clk_prepare_enable() may fail, so let's check its return value and propagate it
in the case of error.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
sound/soc/fsl/fsl_ssi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index ab8d462..73534b0 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -743,7 +743,12 @@ static int fsl_ssi_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "could not get clock: %d\n", ret);
goto error_irqmap;
}
- clk_prepare_enable(ssi_private->clk);
+ ret = clk_prepare_enable(ssi_private->clk);
+ if (ret) {
+ dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n",
+ ret);
+ goto error_irqmap;
+ }
/*
* We have burstsize be "fifo_depth - 2" to match the SSI
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions
2013-07-17 5:00 [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Fabio Estevam
2013-07-17 5:00 ` [PATCH 2/2] ASoC: fsl: fsl_ssi: Check the return value from clk_prepare_enable() Fabio Estevam
@ 2013-07-17 10:05 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-07-17 10:05 UTC (permalink / raw)
To: Fabio Estevam; +Cc: Fabio Estevam, alsa-devel, shawn.guo, timur
[-- Attachment #1.1: Type: text/plain, Size: 267 bytes --]
On Wed, Jul 17, 2013 at 02:00:38AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Using devm_ functions can make the code cleaner and smaller.
Applied both, thanks (assuming Timur is still in the process of moving
here).
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-17 10:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-17 5:00 [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Fabio Estevam
2013-07-17 5:00 ` [PATCH 2/2] ASoC: fsl: fsl_ssi: Check the return value from clk_prepare_enable() Fabio Estevam
2013-07-17 10:05 ` [PATCH 1/2] ASoC: fsl: fsl_ssi: Use devm_ functions Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).