Files
openwrt/target/linux/realtek
Luiz Angelo Daros de Luca 57d7325964 realtek: fix D-Link DGS-1210-28P/MP fan controller
The fan_ctrl.sh script incorrectly assumed that hwmon0 would always be
the lm63 device. Since the introduction of cpu_thermal for this target,
the initialization order of hwmon devices has changed. This patch
dynamically locates the correct hwmon device used by lm63.

Additionally, the script was reading only the first two characters of
the temperature (truncating millidegrees to degrees Celsius, assuming it
never dropped below 10°C) but subsequently compared it against a
threshold defined in millidegrees (51000). This caused the comparison to
always fail. This patch removes the truncation, ensuring both values are
properly compared in millidegrees.

Previously, uci-defaults/04_dlinkfan was used to set pwm1_enable to 1.
However, this is not the appropriate place to set volatile sysfs
attributes, as the script is deleted after the first boot. While the
hardware defaults to 1 (manual mode), the chip retains its state across
warm reboots. Resetting this value on every boot ensures a predictable
state and overrides any manual changes made by the user.

Therefore, the pwm1_enable initialization was moved to fan_ctrl.sh.
It now uses a tmpfs flag to ensure it runs only once per boot,
simulating a cold boot state and preventing warm reboot inconsistencies,
while it still allows the user to overwrite it in sysfs.

As before, fan_ctrl.sh will only be triggered every 5 minutes via cron.
This means that after a boot, the switch might take up to 5 minutes to
configure the fan controller. However, because the chip retains its
state, if the fan was already running, it will remain active during a
warm reboot.

Note: The main branch uses a different approach for this fix
(d3290efad9). This is a 25.12 fix, not a direct backport.

Fixes: 3c152904c2 ("realtek: add fan controller support to D-Link DGS-1210-28MP")
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25100
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
2026-09-13 13:10:08 +02:00
..
2025-08-10 11:46:52 +02:00