[alsa-devel] [PATCH] ASoC: sgtl5000: defer the probe if clock is not found
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);
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.
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
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...
participants (2)
-
Mark Brown
-
Shawn Guo