From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Janusz Krzysztofik <jmkrzyszt@gmail.com>,
linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
Bhumika Goyal <bhumirks@gmail.com>
Subject: [PATCH] ASoC: cx20442: Don't ignore regulator_get() errors.
Date: Sun, 24 Jun 2018 20:14:41 +0200 [thread overview]
Message-ID: <20180624181441.6975-1-jmkrzyszt@gmail.com> (raw)
In its current shape, the driver just ignores errors returned by
regulator_get() at component_probe(). This doesn't hurt on Amstrad
Delta board as long as it registers the codec device at late_initcall,
when the regulator which depends on basic-mmio-gpio device (probed as
late as at dev_initcall) is already available. Otherwise the driver
may end up trying to control a codec which is not powered up.
Remove that dependency on initialization order by handling the error.
If the regulator is not yet available and -ENODEV is returned, convert
it to -EPROBE_DEFER to get another chance.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
Created and tested on linux-4.18-rc1
sound/soc/codecs/cx20442.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c
index 07dd33b09596..ab174b5114dc 100644
--- a/sound/soc/codecs/cx20442.c
+++ b/sound/soc/codecs/cx20442.c
@@ -362,8 +362,27 @@ static int cx20442_component_probe(struct snd_soc_component *component)
return -ENOMEM;
cx20442->por = regulator_get(component->dev, "POR");
- if (IS_ERR(cx20442->por))
- dev_warn(component->dev, "failed to get the regulator");
+ if (IS_ERR(cx20442->por)) {
+ int err = PTR_ERR(cx20442->por);
+
+ dev_warn(component->dev, "failed to get POR supply (%d)", err);
+ /*
+ * When running on a non-dt platform and requested regulator
+ * is not available, regulator_get() never returns
+ * -EPROBE_DEFER as it is not able to justify if the regulator
+ * may still appear later. On the other hand, the board can
+ * still set full constraints flag at late_initcall in order
+ * to instruct regulator_get() to return a dummy one if
+ * sufficient. Hence, if we get -ENODEV here, let's convert
+ * it to -EPROBE_DEFER and wait for the board to decide or
+ * let Deferred Probe infrastructure handle this error.
+ */
+ if (err == -ENODEV)
+ err = -EPROBE_DEFER;
+ kfree(cx20442);
+ return err;
+ }
+
cx20442->tty = NULL;
snd_soc_component_set_drvdata(component, cx20442);
--
2.16.4
next reply other threads:[~2018-06-24 18:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-24 18:14 Janusz Krzysztofik [this message]
2018-06-25 13:15 ` Applied "ASoC: cx20442: Don't ignore regulator_get() errors." to the asoc tree 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=20180624181441.6975-1-jmkrzyszt@gmail.com \
--to=jmkrzyszt@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.com \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tiwai@suse.com \
/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