OSDN Git Service

ASoC: cs35l56: Avoid uninitialized variable in cs35l56_set_asp_slot_positions()
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 8 Aug 2023 16:46:58 +0000 (17:46 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 8 Aug 2023 21:34:00 +0000 (22:34 +0100)
commitebd0f7b08e032900e5327962f7da6bed6f37feb6
tree312e7dc84fe76cac7b061b84391f888fd7ee356e
parenta932f45a1832d18fb64704636a958ef993a1d1da
ASoC: cs35l56: Avoid uninitialized variable in cs35l56_set_asp_slot_positions()

Re-implement setting of ASP TDM slots so that only the common loop to
build the register word is factored out.

The original cs35l56_set_asp_slot_positions() had an apparent
uninitialized variable if the passed register address was neither of the
ASP slot registers. In fact this would never happen because the calling
code passed valid registers.

While it's trivial to initialize the variable or add a default case,
actually the only common code was the loop at the end of the function,
which simply manipulates some mask values and is identical for either
register. Factoring out the regmap_write() didn't really gain anything.

So instead re-implement the code to replace the original function with
cs35l56_make_tdm_config_word() that only does the loop, and change the
calling code to call regmap_write() directly.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230808164702.21272-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs35l56.c