From 75a33df5f6781cec0d2398b2686e594fab2531d0 Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Thu, 19 Feb 2026 21:17:58 +0100 Subject: [PATCH] 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: 6ef6014887c3 ("realtek: Add pinctrl support for RTL8231") Signed-off-by: Sander Vanheule --- ...804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch | 8 ++++---- ...804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch b/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch index 324b556998..3815ed5eda 100644 --- a/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch +++ b/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch @@ -194,10 +194,10 @@ Signed-off-by: Sander Vanheule + 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; + diff --git a/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch b/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch index b5c2a61c41..27c42c2e92 100644 --- a/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch +++ b/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch @@ -194,10 +194,10 @@ Signed-off-by: Sander Vanheule + 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; +