diff mbox series

[1/6] ASoC: cs35l41: Fix use of an uninitialised variable

Message ID 20210914141349.30218-1-ckeepax@opensource.cirrus.com
State Accepted
Commit c2f14cc2bcdd532f8a18450407ffc27bbbff2319
Headers show
Series [1/6] ASoC: cs35l41: Fix use of an uninitialised variable | expand

Commit Message

Charles Keepax Sept. 14, 2021, 2:13 p.m. UTC
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(-)

Comments

Charles Keepax Sept. 15, 2021, 10:53 a.m. UTC | #1
On Tue, Sep 14, 2021 at 03:23:01PM +0100, Mark Brown wrote:
> On Tue, Sep 14, 2021 at 03:13:49PM +0100, Charles Keepax wrote:
> > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> > ---
> >  sound/soc/codecs/cs35l41-i2c.c    |   5 +-
> >  sound/soc/codecs/cs35l41-spi.c    |  13 +-
> >  sound/soc/codecs/cs35l41-tables.c | 477 +++++++++++++++++++-------------------
> >  sound/soc/codecs/cs35l41.c        | 387 +++++++++++++++----------------
> >  sound/soc/codecs/cs35l41.h        |  81 ++++---
> 
> This was upstreamed with your review a week ago :/

Yeah sorry about that, they are all trivial patches (with the
exception of the first patch which I did only notice whilst
fixing up the other stuff) it didn't seem worth delaying the
series for another couple of rounds for such trivial commments.

Apologies if that was the wrong call.

Thanks,
Charles
Mark Brown Sept. 15, 2021, 11:38 a.m. UTC | #2
On Wed, Sep 15, 2021 at 10:53:52AM +0000, Charles Keepax wrote:
> On Tue, Sep 14, 2021 at 03:23:01PM +0100, Mark Brown wrote:
> > On Tue, Sep 14, 2021 at 03:13:49PM +0100, Charles Keepax wrote:
> > > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>

> > >  sound/soc/codecs/cs35l41-i2c.c    |   5 +-
> > >  sound/soc/codecs/cs35l41-spi.c    |  13 +-
> > >  sound/soc/codecs/cs35l41-tables.c | 477 +++++++++++++++++++-------------------
> > >  sound/soc/codecs/cs35l41.c        | 387 +++++++++++++++----------------
> > >  sound/soc/codecs/cs35l41.h        |  81 ++++---

> > This was upstreamed with your review a week ago :/

> Yeah sorry about that, they are all trivial patches (with the
> exception of the first patch which I did only notice whilst
> fixing up the other stuff) it didn't seem worth delaying the
> series for another couple of rounds for such trivial commments.

> Apologies if that was the wrong call.

These are pretty large changes, it's not just a couple of small cleanups
- especially this one is pretty huge.  Also note that Rob found a bunch
of errors in the DT binding that need fixing.
Mark Brown Sept. 15, 2021, 3:21 p.m. UTC | #3
On Tue, 14 Sep 2021 15:13:44 +0100, Charles Keepax wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: cs35l41: Fix use of an uninitialised variable
      commit: c2f14cc2bcdd532f8a18450407ffc27bbbff2319
[2/6] ASoC: cs35l41: Use regmap_read_poll_timeout to wait for OTP boot
      commit: 3a2eb0b4b02060340af10a1db3c452472471be2f
[3/6] ASoC: cs35l41: Combine adjacent register writes
      commit: fe1024d50477becf35128f3ef03bf3525a2cd140
[4/6] ASoC: cs35l41: Don't overwrite returned error code
      commit: e371eadf2a93a653211331b66beaac3b1bcbc931
[5/6] ASoC: cs35l41: Fixup the error messages
      commit: 3e60abeb5cb51bccc8bcc6808eef2037ab412334
[6/6] ASoC: cs35l41: Fix a bunch of trivial code formating/style issues
      commit: 4295c8cc17481e0d7d4c3a404eaf87dc8dfc26be

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

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);