devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
@ 2013-07-31  6:17 Jean-Francois Moine
  2013-08-03 12:39 ` Russell King - ARM Linux
  2013-08-03 12:46 ` Russell King - ARM Linux
  0 siblings, 2 replies; 7+ messages in thread
From: Jean-Francois Moine @ 2013-07-31  6:17 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, Russell King, alsa-devel, linux-kernel, devicetree

The function kirkwood_i2s_dev_remove() may be used when probe fails.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 sound/soc/kirkwood/kirkwood-i2s.c           | 40 +++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 0109b1e..319086f 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -449,6 +449,19 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = {
 	.name		= DRV_NAME,
 };
 
+static int kirkwood_i2s_dev_remove(struct platform_device *pdev)
+{
+	struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
+
+	snd_soc_unregister_component(&pdev->dev);
+
+	if (!IS_ERR(priv->extclk))
+		clk_disable_unprepare(priv->extclk);
+	clk_disable_unprepare(priv->clk);
+
+	return 0;
+}
+
 static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 {
 	struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data;
@@ -519,30 +532,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 
 	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
 					 soc_dai, 1);
-	if (!err)
-		return 0;
-	dev_err(&pdev->dev, "snd_soc_register_component failed\n");
-
-	if (!IS_ERR(priv->extclk))
-		clk_disable_unprepare(priv->extclk);
-	clk_disable_unprepare(priv->clk);
+	if (err) {
+		dev_err(&pdev->dev, "snd_soc_register_component failed\n");
+		goto fail;
+	}
+	return 0;
 
+fail:
+	kirkwood_i2s_dev_remove(pdev);
 	return err;
 }
 
-static int kirkwood_i2s_dev_remove(struct platform_device *pdev)
-{
-	struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
-
-	snd_soc_unregister_component(&pdev->dev);
-
-	if (!IS_ERR(priv->extclk))
-		clk_disable_unprepare(priv->extclk);
-	clk_disable_unprepare(priv->clk);
-
-	return 0;
-}
-
 static struct platform_driver kirkwood_i2s_driver = {
 	.probe  = kirkwood_i2s_dev_probe,
 	.remove = kirkwood_i2s_dev_remove,

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-07-31  6:17 [PATCH v3 1/4] ASoc: kirkwood: simplify probe error Jean-Francois Moine
@ 2013-08-03 12:39 ` Russell King - ARM Linux
  2013-08-03 15:55   ` Jean-Francois Moine
  2013-08-03 12:46 ` Russell King - ARM Linux
  1 sibling, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux @ 2013-08-03 12:39 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

On Wed, Jul 31, 2013 at 08:17:39AM +0200, Jean-Francois Moine wrote:
> @@ -519,30 +532,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
>  
>  	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
>  					 soc_dai, 1);
> -	if (!err)
> -		return 0;
> -	dev_err(&pdev->dev, "snd_soc_register_component failed\n");
> -
> -	if (!IS_ERR(priv->extclk))
> -		clk_disable_unprepare(priv->extclk);
> -	clk_disable_unprepare(priv->clk);
> +	if (err) {
> +		dev_err(&pdev->dev, "snd_soc_register_component failed\n");
> +		goto fail;
> +	}
> +	return 0;

This doesn't apply to mainline as there's a clk_put() there.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-07-31  6:17 [PATCH v3 1/4] ASoc: kirkwood: simplify probe error Jean-Francois Moine
  2013-08-03 12:39 ` Russell King - ARM Linux
@ 2013-08-03 12:46 ` Russell King - ARM Linux
  2013-08-03 16:52   ` Jean-Francois Moine
  1 sibling, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux @ 2013-08-03 12:46 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

On Wed, Jul 31, 2013 at 08:17:39AM +0200, Jean-Francois Moine wrote:
> The function kirkwood_i2s_dev_remove() may be used when probe fails.

Looking at this deeper, I'm not happy with this.

> +static int kirkwood_i2s_dev_remove(struct platform_device *pdev)
> +{
> +	struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
> +
> +	snd_soc_unregister_component(&pdev->dev);
...
> @@ -519,30 +532,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
>  
>  	err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
>  					 soc_dai, 1);
> +	if (err) {
> +		dev_err(&pdev->dev, "snd_soc_register_component failed\n");
> +		goto fail;
> +	}
> +	return 0;
>  
> +fail:
> +	kirkwood_i2s_dev_remove(pdev);

What this means is that if snd_soc_register_component() fails, we end
up calling snd_soc_unregister_component().  This may be fine with the
way snd_soc_unregister_component() is currently implemented, but you're
making the assumption that it's fine to call snd_soc_unregister_component()
for a device which hasn't been registered.  Technically, this is a
layering violation, which makes this change fragile if the behaviour
of snd_soc_unregister_component() changes in the future.

For the sake of two calls in the error path, I don't think the benefits
of this patch outweigh the risk.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-08-03 12:39 ` Russell King - ARM Linux
@ 2013-08-03 15:55   ` Jean-Francois Moine
  2013-08-03 16:10     ` Russell King - ARM Linux
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Francois Moine @ 2013-08-03 15:55 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

On Sat, 3 Aug 2013 13:39:54 +0100
Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:

> This doesn't apply to mainline as there's a clk_put() there.

Right, it applies to linux-next:

On Fri, 26 Jul 2013 11:32:50 +0100, Mark Brown <broonie@kernel.org> wrote:

> Always submit against where the code will be applied - -next in this
> case.

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-08-03 15:55   ` Jean-Francois Moine
@ 2013-08-03 16:10     ` Russell King - ARM Linux
  2013-08-03 16:31       ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Russell King - ARM Linux @ 2013-08-03 16:10 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

On Sat, Aug 03, 2013 at 05:55:13PM +0200, Jean-Francois Moine wrote:
> On Sat, 3 Aug 2013 13:39:54 +0100
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> 
> > This doesn't apply to mainline as there's a clk_put() there.
> 
> Right, it applies to linux-next:
> 
> On Fri, 26 Jul 2013 11:32:50 +0100, Mark Brown <broonie@kernel.org> wrote:
> 
> > Always submit against where the code will be applied - -next in this
> > case.

Sorry, I'm just not going to bother with your patches unless you start
posting them in such a way that interested parties can test them without
having to run around and pull random trees.  In other words, you should
have Cc'd interested parties on that devm_* change patch - especially
myself as I was the one who introduced that code.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-08-03 16:10     ` Russell King - ARM Linux
@ 2013-08-03 16:31       ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2013-08-03 16:31 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jean-Francois Moine, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

On Sat, Aug 03, 2013 at 05:10:29PM +0100, Russell King - ARM Linux wrote:

> having to run around and pull random trees.  In other words, you should
> have Cc'd interested parties on that devm_* change patch - especially
> myself as I was the one who introduced that code.

That was me, sorry - Jean-Francios had nothing to do with the patch.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/4] ASoc: kirkwood: simplify probe error
  2013-08-03 12:46 ` Russell King - ARM Linux
@ 2013-08-03 16:52   ` Jean-Francois Moine
  0 siblings, 0 replies; 7+ messages in thread
From: Jean-Francois Moine @ 2013-08-03 16:52 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Rob Herring, alsa-devel, linux-kernel, devicetree

On Sat, 3 Aug 2013 13:46:52 +0100
Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:

> On Wed, Jul 31, 2013 at 08:17:39AM +0200, Jean-Francois Moine wrote:
> > The function kirkwood_i2s_dev_remove() may be used when probe fails.
> 
> Looking at this deeper, I'm not happy with this.
	[snip]
> What this means is that if snd_soc_register_component() fails, we end
> up calling snd_soc_unregister_component().  This may be fine with the
> way snd_soc_unregister_component() is currently implemented, but you're
> making the assumption that it's fine to call snd_soc_unregister_component()
> for a device which hasn't been registered.  Technically, this is a
> layering violation, which makes this change fragile if the behaviour
> of snd_soc_unregister_component() changes in the future.
> 
> For the sake of two calls in the error path, I don't think the benefits
> of this patch outweigh the risk.

You are right, but if snd_soc_unregister_component() could be
officially used safely with no previous call to
snd_soc_register_component(), this would simplify error handling in
other drivers too...

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-03 16:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-31  6:17 [PATCH v3 1/4] ASoc: kirkwood: simplify probe error Jean-Francois Moine
2013-08-03 12:39 ` Russell King - ARM Linux
2013-08-03 15:55   ` Jean-Francois Moine
2013-08-03 16:10     ` Russell King - ARM Linux
2013-08-03 16:31       ` Mark Brown
2013-08-03 12:46 ` Russell King - ARM Linux
2013-08-03 16:52   ` Jean-Francois Moine

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).