realtek: fix RTL8231 LED toggle interval clamping

The loop scanning the available toggle rates would stop when the
requested interval exceeded the tested interval. Since the intervals are
searched from small to large, this would always trigger on the shortest
interval, or skip to the largest interval for small requested values.

To correctly clamp (ceil) the toggle rate, the loop needs to continue
until the condition is met, instead of breaking the loop.

Fixes: 6ef6014887 ("realtek: Add pinctrl support for RTL8231")
Signed-off-by: Sander Vanheule <sander@svanheule.net>
This commit is contained in:
Sander Vanheule 2026-02-19 21:17:58 +01:00
parent 5ecbd2f90c
commit 75a33df5f6
2 changed files with 8 additions and 8 deletions

View File

@ -194,10 +194,10 @@ Signed-off-by: Sander Vanheule <sander@svanheule.net>
+ interval_ms = (*delay_on + *delay_off) / 2;
+ }
+
+ /* Find clamped toggle interval */
+ for (i = 0; i < (num_rates - 1); i++)
+ if (interval_ms > rates[i].interval_ms)
+ break;
+ /* Find ceiled (or maximum) toggle interval */
+ i = 0;
+ while (i < (num_rates - 1) && interval_ms > rates[i].interval_ms)
+ i++;
+
+ interval_ms = rates[i].interval_ms;
+

View File

@ -194,10 +194,10 @@ Signed-off-by: Sander Vanheule <sander@svanheule.net>
+ interval_ms = (*delay_on + *delay_off) / 2;
+ }
+
+ /* Find clamped toggle interval */
+ for (i = 0; i < (num_rates - 1); i++)
+ if (interval_ms > rates[i].interval_ms)
+ break;
+ /* Find ceiled (or maximum) toggle interval */
+ i = 0;
+ while (i < (num_rates - 1) && interval_ms > rates[i].interval_ms)
+ i++;
+
+ interval_ms = rates[i].interval_ms;
+