All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sgtl5000: defer the probe if clock is not found
@ 2013-07-15 14:55 Shawn Guo
  2013-07-15 16:12 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2013-07-15 14:55 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Shawn Guo

It's not always the case that clock is already available when sgtl5000
get probed at the first time, e.g. the clock is provided by CPU DAI
which may be probed after sgtl5000.  So let's defer the probe when
devm_clk_get() call fails and give it chance to try later.

It fixes the following problem on imx28.

[    1.927637] sgtl5000 0-000a: Failed to get mclock: -2
[    1.934280] sgtl5000: probe of 0-000a failed with error -2

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
Mark,

This is a fix for 3.11.

Shawn

 sound/soc/codecs/sgtl5000.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index d441559..7ebf923 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1527,7 +1527,8 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
 	if (IS_ERR(sgtl5000->mclk)) {
 		ret = PTR_ERR(sgtl5000->mclk);
 		dev_err(&client->dev, "Failed to get mclock: %d\n", ret);
-		return ret;
+		/* Defer the probe to see if the clk will be provided later */
+		return ret == -ENOENT ? -EPROBE_DEFER : ret;
 	}
 
 	ret = clk_prepare_enable(sgtl5000->mclk);
-- 
1.7.9.5

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

* Re: [PATCH] ASoC: sgtl5000: defer the probe if clock is not found
  2013-07-15 14:55 [PATCH] ASoC: sgtl5000: defer the probe if clock is not found Shawn Guo
@ 2013-07-15 16:12 ` Mark Brown
  2013-07-15 16:19   ` Shawn Guo
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-07-15 16:12 UTC (permalink / raw)
  To: Shawn Guo; +Cc: alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 637 bytes --]

On Mon, Jul 15, 2013 at 10:55:10PM +0800, Shawn Guo wrote:
> It's not always the case that clock is already available when sgtl5000
> get probed at the first time, e.g. the clock is provided by CPU DAI
> which may be probed after sgtl5000.  So let's defer the probe when
> devm_clk_get() call fails and give it chance to try later.

My previous comments about this being better handled in the clock core
appear to have been ignored and...

> +		/* Defer the probe to see if the clk will be provided later */
> +		return ret == -ENOENT ? -EPROBE_DEFER : ret;

...please try to avoid the ternery operator, it's not helpful for
legibility.

[-- 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] 4+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: defer the probe if clock is not found
  2013-07-15 16:12 ` Mark Brown
@ 2013-07-15 16:19   ` Shawn Guo
  2013-07-15 17:13     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2013-07-15 16:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

On Mon, Jul 15, 2013 at 05:12:50PM +0100, Mark Brown wrote:
> On Mon, Jul 15, 2013 at 10:55:10PM +0800, Shawn Guo wrote:
> > It's not always the case that clock is already available when sgtl5000
> > get probed at the first time, e.g. the clock is provided by CPU DAI
> > which may be probed after sgtl5000.  So let's defer the probe when
> > devm_clk_get() call fails and give it chance to try later.
> 
> My previous comments about this being better handled in the clock core
> appear to have been ignored and...

I'm not really fond of fixing a regression for -rc with involving clock
core change.  I think we can do that when that becomes a really common
pattern.

> 
> > +		/* Defer the probe to see if the clk will be provided later */
> > +		return ret == -ENOENT ? -EPROBE_DEFER : ret;
> 
> ...please try to avoid the ternery operator, it's not helpful for
> legibility.

Okay, will change that to respect your taste.

Shawn

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

* Re: [PATCH] ASoC: sgtl5000: defer the probe if clock is not found
  2013-07-15 16:19   ` Shawn Guo
@ 2013-07-15 17:13     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-07-15 17:13 UTC (permalink / raw)
  To: Shawn Guo; +Cc: alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 513 bytes --]

On Tue, Jul 16, 2013 at 12:19:43AM +0800, Shawn Guo wrote:
> On Mon, Jul 15, 2013 at 05:12:50PM +0100, Mark Brown wrote:

> > My previous comments about this being better handled in the clock core
> > appear to have been ignored and...

> I'm not really fond of fixing a regression for -rc with involving clock
> core change.  I think we can do that when that becomes a really common
> pattern.

It's already a common pattern (or should be anyway) - look at all the
drivers that fail if they can't get a clock...

[-- 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] 4+ messages in thread

end of thread, other threads:[~2013-07-15 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15 14:55 [PATCH] ASoC: sgtl5000: defer the probe if clock is not found Shawn Guo
2013-07-15 16:12 ` Mark Brown
2013-07-15 16:19   ` Shawn Guo
2013-07-15 17:13     ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.