diff options
author | Charles Keepax <ckeepax@opensource.cirrus.com> | 2021-09-14 17:13:44 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-09-15 15:12:30 +0300 |
commit | c2f14cc2bcdd532f8a18450407ffc27bbbff2319 (patch) | |
tree | cf7e1154bfc9aa9860d4c00ca7457731ee91ce32 /sound/soc | |
parent | 6d66c5ccf5cb8af866fe2bb014098a3dd7bfa3cc (diff) | |
download | linux-c2f14cc2bcdd532f8a18450407ffc27bbbff2319.tar.xz |
ASoC: cs35l41: Fix use of an uninitialised variable
The loop checking PDN_DONE doesn't check the return value from
regmap_read, nor does it initialise val. This means if regmap_read fails
val will be checked for the PDN_DONE bit whilst being uninitialised.
Fix this up by switching to regmap_read_poll_timeout which tidies up the
code and avoids the uninitialised variable.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210914141349.30218-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/cs35l41.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index dbec54a28a9e..d2a11cc33683 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -580,7 +580,6 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, unsigned int val; int ret = 0; bool pdn; - int i; switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -599,19 +598,11 @@ static int cs35l41_main_amp_event(struct snd_soc_dapm_widget *w, CS35L41_GLOBAL_EN_MASK, 0); pdn = false; - for (i = 0; i < 100; i++) { - regmap_read(cs35l41->regmap, - CS35L41_IRQ1_STATUS1, - &val); - if (val & CS35L41_PDN_DONE_MASK) { - pdn = true; - break; - } - usleep_range(1000, 1100); - } - - if (!pdn) - dev_warn(cs35l41->dev, "PDN failed\n"); + ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS1, + val, val & CS35L41_PDN_DONE_MASK, + 1000, 100000); + if (ret) + dev_warn(cs35l41->dev, "PDN failed: %d\n", ret); regmap_write(cs35l41->regmap, CS35L41_IRQ1_STATUS1, CS35L41_PDN_DONE_MASK); |