Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs35l41: Handle mdsync_up reg write errors

The return code of regmap_multi_reg_write() call related to "MDSYNC up"
sequence is shadowed by the subsequent regmap_read_poll_timeout()
invocation, which will hit a timeout in case the write operation above
fails.

Make sure cs35l41_global_enable() returns the correct error code instead
of -ETIMEDOUT.

Additionally, to be able to distinguish between the timeouts of
wait_for_completion_timeout() and regmap_read_poll_timeout(), print an
error message for the former and return immediately. This also avoids
having to wait unnecessarily for the second time.

Fixes: f8264c759208 ("ALSA: cs35l41: Poll for Power Up/Down rather than waiting a fixed delay")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230907171010.1447274-3-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Cristian Ciocaltea and committed by
Mark Brown
4bb5870a a9a3f54a

+10 -7
+10 -7
sound/soc/codecs/cs35l41-lib.c
··· 1251 1251 1252 1252 ret = wait_for_completion_timeout(pll_lock, msecs_to_jiffies(1000)); 1253 1253 if (ret == 0) { 1254 - ret = -ETIMEDOUT; 1255 - } else { 1256 - regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); 1257 - pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; 1258 - cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; 1259 - ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, 1260 - ARRAY_SIZE(cs35l41_mdsync_up_seq)); 1254 + dev_err(dev, "Timed out waiting for pll_lock\n"); 1255 + return -ETIMEDOUT; 1261 1256 } 1257 + 1258 + regmap_read(regmap, CS35L41_PWR_CTRL3, &pwr_ctrl3); 1259 + pwr_ctrl3 |= CS35L41_SYNC_EN_MASK; 1260 + cs35l41_mdsync_up_seq[0].def = pwr_ctrl3; 1261 + ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_up_seq, 1262 + ARRAY_SIZE(cs35l41_mdsync_up_seq)); 1263 + if (ret) 1264 + return ret; 1262 1265 1263 1266 ret = regmap_read_poll_timeout(regmap, CS35L41_IRQ1_STATUS1, 1264 1267 int_status, int_status & pup_pdn_mask,