From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: sreekuttan2156239@gmail.com, perex@perex.cz, tiwai@suse.de
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org
Subject: [PATCH v2] ALSA: vmaster: Restore follower values on put failure
Date: Thu, 26 Nov 2026 06:32:25 +0000 [thread overview]
Message-ID: <20261126063225.3166-1-sreekuttan2156239@gmail.com> (raw)
In-Reply-To: <20261126061910.2840-1-sreekuttan2156239@gmail.com>
Restore the cached follower values when the underlying put
callback fails.
Otherwise, a retry with the same value may be skipped
because the cache already contains the requested value.
Fixes: 3b0a5f22d464 ("[ALSA] Add virtual master control helpers")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
- Add Fixes trailer.
sound/core/vmaster.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index f43144ba2797..f5cc11eba25d 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -193,7 +193,7 @@ static int follower_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct link_follower *follower = snd_kcontrol_chip(kcontrol);
- int err, ch, changed = 0;
+ int err, ch, changed = 0, old_vals[2];
err = follower_init(follower);
if (err < 0)
@@ -204,6 +204,10 @@ static int follower_put(struct snd_kcontrol *kcontrol,
return -EINVAL;
}
+ /* save the original cached values */
+ for (ch = 0; ch < follower->info.count; ch++)
+ old_vals[ch] = follower->vals[ch];
+
for (ch = 0; ch < follower->info.count; ch++) {
if (follower->vals[ch] != ucontrol->value.integer.value[ch]) {
changed = 1;
@@ -213,8 +217,13 @@ static int follower_put(struct snd_kcontrol *kcontrol,
if (!changed)
return 0;
err = follower_put_val(follower, ucontrol);
- if (err < 0)
+ if (err < 0) {
+ /* restore cached values on failure */
+ for (ch = 0; ch < follower->info.count; ch++)
+ follower->vals[ch] = old_vals[ch];
return err;
+ }
+
return 1;
}
--
2.55.0
prev parent reply other threads:[~2026-11-26 6:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:19 [PATCH] " Sreeraj S Kurup
2026-11-26 6:32 ` Sreeraj S Kurup [this message]
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=20261126063225.3166-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/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
all inboxes | Powered by JetHome®