forked from protheus313/fanctrlplus
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Fix PWM10+ discovery and sort order in Common.php #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrebrait
merged 5 commits into
andrebrait:main
from
mrjacobarussell:fix-pwm10-plus-glob-and-sort
Oct 4, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
669ee0a
Fix PWM10+ discovery and sort order in Common.php
mrjacobarussell 75e0dcd
Address review: drop find/regextype, avoid pwm[0-9]* auxiliary-attrib…
mrjacobarussell 763f86a
fanctrlplus2: list PWM channels by their device path
andrebrait 301e8b0
fanctrlplus2: share PWM enumeration and keep legacy-layout channels
andrebrait 30c1274
fanctrlplus2: name legacy-layout channels after their hwmon device
andrebrait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <?php | ||
|
|
||
| require_once __DIR__ . '/../src/usr/local/emhttp/plugins/fanctrlplus2/include/Common.php'; | ||
|
|
||
| $failures = []; | ||
| $root = realpath(sys_get_temp_dir()) . '/fcp_pwm_discovery_' . getmypid(); | ||
|
|
||
| $chip = function (string $hwmon, string $device, string $name, array $files) use ($root): void { | ||
| @mkdir("$root/devices/$device", 0777, true); | ||
| @mkdir("$root/class/hwmon", 0777, true); | ||
| symlink("$root/devices/$device", "$root/class/hwmon/$hwmon"); | ||
| file_put_contents("$root/devices/$device/name", "$name\n"); | ||
| foreach ($files as $f) touch("$root/devices/$device/$f"); | ||
| }; | ||
| $usb = 'usb1/1-14/1-14:1.0/0003:3904:F001.0005/hwmon/hwmon5'; | ||
| $chip('hwmon5', $usb, 'arctic_fan_controller', | ||
| ['pwm1', 'pwm2', 'pwm10', 'pwm1_enable', 'pwm10_enable', 'pwm1_auto_point1_pwm']); | ||
|
|
||
| // Older drivers put the attributes on the parent device; hwmonN is a stub | ||
| // that may or may not carry the name. | ||
| $legacy = function (string $hwmon, string $device, string $name, bool $nameOnDevice) use ($root, $chip): void { | ||
| @mkdir("$root/devices/$device/hwmon/$hwmon", 0777, true); | ||
| symlink("$root/devices/$device", "$root/devices/$device/hwmon/$hwmon/device"); | ||
| $chip($hwmon, "$device/hwmon/$hwmon", $name, []); | ||
| if ($nameOnDevice) { | ||
| unlink("$root/devices/$device/hwmon/$hwmon/name"); | ||
| file_put_contents("$root/devices/$device/name", "$name\n"); | ||
| } | ||
| touch("$root/devices/$device/pwm1"); | ||
| }; | ||
| $legacy('hwmon2', 'platform/w83627hf.656', 'w83627hf', true); | ||
| $legacy('hwmon3', 'platform/it87.552', 'it8728', false); | ||
|
|
||
| $pwms = list_pwm("$root/class/hwmon/hwmon*"); | ||
|
|
||
| $expected = [ | ||
| ['chip' => 'it8728', 'name' => 'pwm1', 'sensor' => "$root/devices/platform/it87.552/pwm1"], | ||
| ['chip' => 'w83627hf', 'name' => 'pwm1', 'sensor' => "$root/devices/platform/w83627hf.656/pwm1"], | ||
| ['chip' => 'arctic_fan_controller', 'name' => 'pwm1', 'sensor' => "$root/devices/$usb/pwm1"], | ||
| ['chip' => 'arctic_fan_controller', 'name' => 'pwm2', 'sensor' => "$root/devices/$usb/pwm2"], | ||
| ['chip' => 'arctic_fan_controller', 'name' => 'pwm10', 'sensor' => "$root/devices/$usb/pwm10"], | ||
| ]; | ||
| // Labels and controller settings are keyed by the /sys/devices path, so a | ||
| // /sys/class/hwmon/hwmonN path would orphan every saved one. | ||
| if ($pwms !== $expected) { | ||
| $failures[] = "PWM channels must include pwm10 and legacy-layout channels, exclude per-channel attributes,\n" | ||
| . "sort numerically and use the resolved device path. Got:\n" . var_export($pwms, true); | ||
| } | ||
|
|
||
| exec('rm -rf ' . escapeshellarg($root)); | ||
|
|
||
| if ($failures) { | ||
| fwrite(STDERR, implode("\n", $failures) . "\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| echo "pwm discovery tests passed\n"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.