mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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
56 lines
1.5 KiB
C
56 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#undef TRACE_SYSTEM
|
|
#define TRACE_SYSTEM snd_ctl
|
|
|
|
#if !defined(_TRACE_SND_CTL_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
#define _TRACE_SND_CTL_H
|
|
|
|
#include <linux/tracepoint.h>
|
|
#include <uapi/sound/asound.h>
|
|
|
|
TRACE_EVENT(snd_ctl_put,
|
|
|
|
TP_PROTO(struct snd_ctl_elem_id *id, const char *iname, unsigned int card,
|
|
int expected, int actual),
|
|
|
|
TP_ARGS(id, iname, card, expected, actual),
|
|
|
|
TP_STRUCT__entry(
|
|
__field(unsigned int, numid)
|
|
__string(iname, iname)
|
|
__string(kname, id->name)
|
|
__field(unsigned int, index)
|
|
__field(unsigned int, device)
|
|
__field(unsigned int, subdevice)
|
|
__field(unsigned int, card)
|
|
__field(int, expected)
|
|
__field(int, actual)
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->numid = id->numid;
|
|
__assign_str(iname);
|
|
__assign_str(kname);
|
|
__entry->index = id->index;
|
|
__entry->device = id->device;
|
|
__entry->subdevice = id->subdevice;
|
|
__entry->card = card;
|
|
__entry->expected = expected;
|
|
__entry->actual = actual;
|
|
),
|
|
|
|
TP_printk("%s: expected=%d, actual=%d for ctl numid=%d, iface=%s, name='%s', index=%d, device=%d, subdevice=%d, card=%d\n",
|
|
__entry->expected == __entry->actual ? "success" : "fail",
|
|
__entry->expected, __entry->actual, __entry->numid,
|
|
__get_str(iname), __get_str(kname), __entry->index,
|
|
__entry->device, __entry->subdevice, __entry->card)
|
|
);
|
|
|
|
#endif /* _TRACE_SND_CTL_H */
|
|
|
|
/* This part must be outside protection */
|
|
#undef TRACE_INCLUDE_PATH
|
|
#define TRACE_INCLUDE_PATH .
|
|
#define TRACE_INCLUDE_FILE control_trace
|
|
#include <trace/define_trace.h>
|