All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] ASoC: cs35l41: Fix use of an uninitialised variable
@ 2021-09-14 14:13 Charles Keepax
  2021-09-14 14:13 ` [PATCH 2/6] ASoC: cs35l41: Use regmap_read_poll_timeout to wait for OTP boot Charles Keepax
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Charles Keepax @ 2021-09-14 14:13 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, james.schulman, lgirdwood, david.rhodes

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>
---
 sound/soc/codecs/cs35l41.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index dbec54a28a9e3..d2a11cc336833 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);
-- 
2.11.0


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

end of thread, other threads:[~2021-09-15 15:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 14:13 [PATCH 1/6] ASoC: cs35l41: Fix use of an uninitialised variable Charles Keepax
2021-09-14 14:13 ` [PATCH 2/6] ASoC: cs35l41: Use regmap_read_poll_timeout to wait for OTP boot Charles Keepax
2021-09-14 14:13 ` [PATCH 3/6] ASoC: cs35l41: Combine adjacent register writes Charles Keepax
2021-09-14 14:13 ` [PATCH 4/6] ASoC: cs35l41: Don't overwrite returned error code Charles Keepax
2021-09-14 14:13 ` [PATCH 5/6] ASoC: cs35l41: Fixup the error messages Charles Keepax
2021-09-14 14:13 ` [PATCH 6/6] ASoC: cs35l41: Fix a bunch of trivial code formating/style issues Charles Keepax
2021-09-14 14:23   ` Mark Brown
2021-09-15 10:53     ` Charles Keepax
2021-09-15 11:38       ` Mark Brown
2021-09-15 15:21 ` [PATCH 1/6] ASoC: cs35l41: Fix use of an uninitialised variable 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.