linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/alsa: Fix the step check for INTEGER controls
@ 2026-09-03 12:38 HyeongJun An
  2026-09-03 16:07 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: HyeongJun An @ 2026-09-03 12:38 UTC (permalink / raw)
  To: Mark Brown, Takashi Iwai, Jaroslav Kysela, Shuah Khan
  Cc: linux-sound, linux-kselftest, linux-kernel, HyeongJun An

The modulo sits inside the subtraction, so the check evaluates
int_val - (min % step) rather than (int_val - min) % step. The
INTEGER64 branch below it is parenthesised correctly.

The written form passes only when the value equals min % step, and such
a value is always on a step boundary, so it never misses a real
violation. It only reports valid values as invalid.

snd-aloop declares step 1 on four controls, so every non-zero value on
them is reported. Before:

  # PCM Rate Shift 100000.0 value 100000 invalid for step 1 minimum 80000
  # Totals: pass:660 fail:101 xfail:0 xpass:0 skip:296 error:0

After, same card, nothing else changed:

  # Totals: pass:740 fail:21 xfail:0 xpass:0 skip:296 error:0

Eighteen files under sound/ declare a non-zero step.

Fixes: 5aaf9efffc57 ("kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest")
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Assisted-by: Claude:claude-opus-5
---
 tools/testing/selftests/alsa/mixer-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index a329f901c5ed..0857d64c322a 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -319,8 +319,8 @@ static bool ctl_value_index_valid(struct ctl_data *ctl,
 
 		/* Only check step size if there is one and we're in bounds */
 		if (snd_ctl_elem_info_get_step(ctl->info) &&
-		    (int_val - snd_ctl_elem_info_get_min(ctl->info) %
-		     snd_ctl_elem_info_get_step(ctl->info))) {
+		    (int_val - snd_ctl_elem_info_get_min(ctl->info)) %
+		    snd_ctl_elem_info_get_step(ctl->info)) {
 			ksft_print_msg("%s.%d value %ld invalid for step %ld minimum %ld\n",
 				       ctl->name, index, int_val,
 				       snd_ctl_elem_info_get_step(ctl->info),
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests/alsa: Fix the step check for INTEGER controls
  2026-09-03 12:38 [PATCH] selftests/alsa: Fix the step check for INTEGER controls HyeongJun An
@ 2026-09-03 16:07 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-03 16:07 UTC (permalink / raw)
  To: HyeongJun An
  Cc: Mark Brown, Takashi Iwai, Jaroslav Kysela, Shuah Khan,
	linux-sound, linux-kselftest, linux-kernel

On Thu, 03 Sep 2026 14:38:32 +0200,
HyeongJun An wrote:
> 
> The modulo sits inside the subtraction, so the check evaluates
> int_val - (min % step) rather than (int_val - min) % step. The
> INTEGER64 branch below it is parenthesised correctly.
> 
> The written form passes only when the value equals min % step, and such
> a value is always on a step boundary, so it never misses a real
> violation. It only reports valid values as invalid.
> 
> snd-aloop declares step 1 on four controls, so every non-zero value on
> them is reported. Before:
> 
>   # PCM Rate Shift 100000.0 value 100000 invalid for step 1 minimum 80000
>   # Totals: pass:660 fail:101 xfail:0 xpass:0 skip:296 error:0
> 
> After, same card, nothing else changed:
> 
>   # Totals: pass:740 fail:21 xfail:0 xpass:0 skip:296 error:0
> 
> Eighteen files under sound/ declare a non-zero step.
> 
> Fixes: 5aaf9efffc57 ("kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest")
> Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
> Assisted-by: Claude:claude-opus-5

Applied now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-03 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 12:38 [PATCH] selftests/alsa: Fix the step check for INTEGER controls HyeongJun An
2026-09-03 16:07 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).