summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/wsa883x.c
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2022-06-30 16:00:23 +0300
committerMark Brown <broonie@kernel.org>2022-06-30 18:10:50 +0300
commit0df73e1a9f7b1152ace21b6406138f7487239128 (patch)
treec569440fa62f7e5fb65db2b7101d8e380f885e41 /sound/soc/codecs/wsa883x.c
parentcf6af24b54903f9f70c29b3e5b19cb72cc862d60 (diff)
downloadlinux-0df73e1a9f7b1152ace21b6406138f7487239128.tar.xz
ASoC: codecs: wsa883x: handle timeouts in resume path
Currently we do not check if SoundWire slave initialization timeout expired before continuing to access its registers. Its possible that the registers are not accessible if timeout is expired. Handle this by returning timeout in resume path. Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20220630130023.9308-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/wsa883x.c')
-rw-r--r--sound/soc/codecs/wsa883x.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
index e8f519e89213..40c7d64a9c41 100644
--- a/sound/soc/codecs/wsa883x.c
+++ b/sound/soc/codecs/wsa883x.c
@@ -1455,6 +1455,7 @@ static int __maybe_unused wsa883x_runtime_resume(struct device *dev)
struct sdw_slave *slave = dev_to_sdw_dev(dev);
struct regmap *regmap = dev_get_regmap(dev, NULL);
struct wsa883x_priv *wsa883x = dev_get_drvdata(dev);
+ unsigned long time;
int ret;
ret = regulator_enable(wsa883x->vdd);
@@ -1465,8 +1466,14 @@ static int __maybe_unused wsa883x_runtime_resume(struct device *dev)
gpiod_direction_output(wsa883x->sd_n, 1);
- wait_for_completion_timeout(&slave->initialization_complete,
- msecs_to_jiffies(WSA883X_PROBE_TIMEOUT));
+ time = wait_for_completion_timeout(&slave->initialization_complete,
+ msecs_to_jiffies(WSA883X_PROBE_TIMEOUT));
+ if (!time) {
+ dev_err(dev, "Initialization not complete, timed out\n");
+ gpiod_direction_output(wsa883x->sd_n, 0);
+ regulator_disable(wsa883x->vdd);
+ return -ETIMEDOUT;
+ }
usleep_range(20000, 20010);
regcache_cache_only(regmap, false);