From: Pengpeng Hou <hppiscas@163.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Pengpeng Hou <hppiscas@163.com>,
Oder Chiou <oder_chiou@realtek.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Bard Liao <bardliao@realtek.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/9] ASoC: rt5682: stop jack resume after restore errors
Date: Sun, 6 Sep 2026 11:43:18 +0800 [thread overview]
Message-ID: <20260906034321.86080-7-hppiscas@163.com> (raw)
rt5682_resume() ignores cache replay and headset register update
failures, then clears the jack state, schedules jack detection and
enables the IRQ. The published jack work can therefore run against a
partially restored codec.
Check cache synchronization and each fallible headset register update
before publishing jack work or enabling the IRQ. Return the first error
to the ASoC component wrapper, which reports it while retaining
best-effort card resume. The successful resume order is unchanged and no
rollback is attempted after a partial register update.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: 0ddce71c21f0 ("ASoC: rt5682: add rt5682 codec driver")
Assisted-by: gpt 5
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
sound/soc/codecs/rt5682.c | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 6f7e68c20d13..59c3f8b7a600 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -3010,23 +3010,42 @@ static int rt5682_suspend(struct snd_soc_component *component)
static int rt5682_resume(struct snd_soc_component *component)
{
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
+ int ret;
if (rt5682->is_sdw)
return 0;
regcache_cache_only(rt5682->regmap, false);
- regcache_sync(rt5682->regmap);
+ ret = regcache_sync(rt5682->regmap);
+ if (ret)
+ return ret;
if (rt5682->hs_jack && (rt5682->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) {
- snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1,
- RT5682_SAR_BUTDET_MODE_MASK | RT5682_SAR_SEL_MB1_MB2_MASK,
- RT5682_SAR_BUTDET_POW_NORM | RT5682_SAR_SEL_MB1_MB2_AUTO);
+ ret = snd_soc_component_update_bits(component,
+ RT5682_SAR_IL_CMD_1,
+ RT5682_SAR_BUTDET_MODE_MASK |
+ RT5682_SAR_SEL_MB1_MB2_MASK,
+ RT5682_SAR_BUTDET_POW_NORM |
+ RT5682_SAR_SEL_MB1_MB2_AUTO);
+ if (ret < 0)
+ return ret;
+
usleep_range(5000, 6000);
- snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
- RT5682_MB1_PATH_MASK | RT5682_MB2_PATH_MASK,
- RT5682_CTRL_MB1_FSM | RT5682_CTRL_MB2_FSM);
- snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
- RT5682_PWR_CBJ, RT5682_PWR_CBJ);
+ ret = snd_soc_component_update_bits(component,
+ RT5682_CBJ_CTRL_1,
+ RT5682_MB1_PATH_MASK |
+ RT5682_MB2_PATH_MASK,
+ RT5682_CTRL_MB1_FSM |
+ RT5682_CTRL_MB2_FSM);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_component_update_bits(component,
+ RT5682_PWR_ANLG_3,
+ RT5682_PWR_CBJ,
+ RT5682_PWR_CBJ);
+ if (ret < 0)
+ return ret;
}
rt5682->jack_type = 0;
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-09-06 3:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260906034321.86080-7-hppiscas@163.com \
--to=hppiscas@163.com \
--cc=bardliao@realtek.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox