]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ALSA: control: Verify put() result when in debug mode
authorCezary Rojewski <cezary.rojewski@intel.com>
Tue, 24 Feb 2026 20:56:19 +0000 (21:56 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 28 Feb 2026 08:32:39 +0000 (09:32 +0100)
commit84446536f63d471ab16b2faa25eeab1df21ace0a
tree365d8b5ba9bff72a9eed854f8229a9fd863c85bb
parentd4d5633d8b19b0e745a7910aea49956b3b47900d
ALSA: control: Verify put() result when in debug mode

The put() operation is expected to return:
1) 0 on success if no changes were made
2) 1 on success if changes were made
3) error code otherwise

Currently 2) is usually ignored when writing control-operations. While
forcing compliance is not an option right now, make it easier for
developers to adhere to the expectations and notice problems by logging
them when CONFIG_SND_CTL_DEBUG is enabled.

Due to large size of struct snd_ctl_elem_value, 'value_buf' is provided
as a reusable buffer for kctl->put() verification. This prevents
exhausting the stack when verifying the operation.

>From user perspective, patch introduces a new trace/events category
'snd_ctl' containing a single 'snd_ctl_put' event type. Log sample:

  amixer-1086    [003] .....    8.035939: snd_ctl_put: success: expected=0, actual=0 for ctl numid=1, iface=MIXER, name='Master Playback Volume', index=0, device=0, subdevice=0, card=0
  amixer-1087    [003] .....    8.938721: snd_ctl_put: success: expected=1, actual=1 for ctl numid=1, iface=MIXER, name='Master Playback Volume', index=0, device=0, subdevice=0, card=0
  amixer-1088    [003] .....    9.631470: snd_ctl_put: success: expected=1, actual=1 for ctl numid=1, iface=MIXER, name='Master Playback Volume', index=0, device=0, subdevice=0, card=0
  amixer-1089    [000] .....    9.636786: snd_ctl_put: fail: expected=1, actual=0 for ctl numid=5, iface=MIXER, name='Loopback Mute', index=0, device=0, subdevice=0, card=0

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260224205619.584795-1-cezary.rojewski@intel.com
include/sound/core.h
sound/core/Makefile
sound/core/control.c
sound/core/control_trace.h [new file with mode: 0644]
sound/core/init.c