From: Timur Tabi <timur@freescale.com>
To: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com,
lrg@slimlogic.co.uk
Subject: [PATCH] asoc/multi-component: fsl: fix exit and error paths in DMA and SSI drivers
Date: Tue, 3 Aug 2010 17:55:28 -0500 [thread overview]
Message-ID: <1280876128-19263-1-git-send-email-timur@freescale.com> (raw)
The error handling code in the OF probe function of the SSI driver is not
freeing all resources correctly.
Since the machine driver no longer calls the DMA driver to provide information
about the SSI, we don't need to keep a list of DMA objects any more. In
addition, the fsl_soc_dma_remove() function is incorrectly removing *all*
DMA objects when it should only remove one.
Signed-off-by: Timur Tabi <timur@freescale.com>
---
sound/soc/fsl/fsl_dma.c | 23 +++++++----------------
sound/soc/fsl/fsl_ssi.c | 29 ++++++++++++++++-------------
2 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 4450f9d..57774cb 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -57,7 +57,6 @@
SNDRV_PCM_RATE_CONTINUOUS)
struct dma_object {
- struct list_head list;
struct snd_soc_platform_driver dai;
dma_addr_t ssi_stx_phys;
dma_addr_t ssi_srx_phys;
@@ -825,9 +824,6 @@ static void fsl_dma_free_dma_buffers(struct snd_pcm *pcm)
}
}
-/* List of DMA nodes that we've probed */
-static LIST_HEAD(dma_list);
-
/**
* find_ssi_node -- returns the SSI node that points to his DMA channel node
*
@@ -915,25 +911,20 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->channel = of_iomap(np, 0);
dma->irq = irq_of_parse_and_map(np, 0);
- list_add(&dma->list, &dma_list);
+
+ dev_set_drvdata(&of_dev->dev, dma);
return 0;
}
static int __devexit fsl_soc_dma_remove(struct of_device *of_dev)
{
- struct list_head *n, *ptr;
- struct dma_object *dma;
+ struct dma_object *dma = dev_get_drvdata(&of_dev->dev);
- list_for_each_safe(ptr, n, &dma_list) {
- dma = list_entry(ptr, struct dma_object, list);
- list_del_init(ptr);
-
- snd_soc_unregister_platform(&of_dev->dev);
- iounmap(dma->channel);
- irq_dispose_mapping(dma->irq);
- kfree(dma);
- }
+ snd_soc_unregister_platform(&of_dev->dev);
+ iounmap(dma->channel);
+ irq_dispose_mapping(dma->irq);
+ kfree(dma);
return 0;
}
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 51b089f..00e3e62 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -619,7 +619,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
{
struct fsl_ssi_private *ssi_private;
int ret = 0;
- struct device_attribute *dev_attr;
+ struct device_attribute *dev_attr = NULL;
struct device_node *np = of_dev->dev.of_node;
const char *p, *sprop;
struct resource res;
@@ -681,18 +681,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
if (ret) {
dev_err(&of_dev->dev, "could not create sysfs %s file\n",
ssi_private->dev_attr.attr.name);
- kfree(ssi_private);
- return ret;
+ goto error;
}
/* Register with ASoC */
dev_set_drvdata(&of_dev->dev, ssi_private);
ret = snd_soc_register_dai(&of_dev->dev, &ssi_private->cpu_dai_drv);
- if (ret != 0) {
+ if (ret) {
dev_err(&of_dev->dev, "failed to register DAI: %d\n", ret);
- kfree(ssi_private);
- return ret;
+ goto error;
}
/* Trigger the machine driver's probe function. The platform driver
@@ -713,18 +711,23 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
if (IS_ERR(ssi_private->pdev)) {
ret = PTR_ERR(ssi_private->pdev);
dev_err(&of_dev->dev, "failed to register platform: %d\n", ret);
- kfree(ssi_private);
- return ret;
+ goto error;
}
return 0;
+
+error:
+ snd_soc_unregister_dai(&of_dev->dev);
+ dev_set_drvdata(&of_dev->dev, NULL);
+ if (dev_attr)
+ device_remove_file(&of_dev->dev, dev_attr);
+ irq_dispose_mapping(ssi_private->irq);
+ iounmap(ssi_private->ssi);
+ kfree(ssi_private);
+
+ return ret;
}
-/**
- * fsl_ssi_destroy_dai: destroy the snd_soc_dai object
- *
- * This function undoes the operations of fsl_ssi_probe()
- */
static int fsl_ssi_remove(struct of_device *of_dev)
{
struct fsl_ssi_private *ssi_private = dev_get_drvdata(&of_dev->dev);
--
1.7.0.1
next reply other threads:[~2010-08-03 22:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 22:55 Timur Tabi [this message]
2010-08-03 23:35 ` [PATCH] asoc/multi-component: fsl: fix exit and error paths in DMA and SSI drivers Liam Girdwood
2010-08-05 13:52 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280876128-19263-1-git-send-email-timur@freescale.com \
--to=timur@freescale.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@slimlogic.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).