Repository navigation
ingenic: restore the temperature HAL wiring, and report degrees not millidegrees - #241
Merged
Merged
Conversation
…illidegrees 6e697a7 ("[INGENIC] Fix enable sensor clock") deleted the two lines in setup_hal_ingenic() that assigned hal_temperature behind the same access() guard the allwinner, rockchip, novatek, fh and gm HALs use. Nothing was reported, because no Ingenic SoC up to and including T40 has a die temperature sensor and so no Ingenic kernel registers a thermal zone: the guard would have left hal_temperature NULL anyway, which is also why ingenic_get_temp() has sat unreferenced ever since. Being unreachable, it also kept two bugs. It returned the sysfs value verbatim where every sibling HAL divides by 1000, so a 45 C chip would have been reported as 45000, and on a failed read it returned -237.0, which -t would have printed as a temperature instead of letting gethwtemp()'s NAN produce the honest "Temperature cannot be retrieved". Verified on the lab T31 (T31L, kernel 3.10.14 isvp_swan): /sys/class/ thermal does not exist there, so --temp still exits 1 with "Temperature cannot be retrieved", unchanged from the stock build. The reader itself was exercised against a real zone on the build host, 27800 -> 27.80, and with the zone hidden in a private mount namespace -> NAN. Native, mips32 and arm32 builds clean; cYAML_test and reginfo_test pass.
PR Summary by QodoRestore Ingenic temperature HAL wiring and report degrees Celsius
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ingenic_get_temp()has been dead code since May 2023.6e697a7 ("[INGENIC] Fix enable sensor clock") deleted the two lines in
setup_hal_ingenic()that assignedhal_temperaturebehind the sameaccess()guard the allwinner, rockchip, novatek, fh and gm HALs use. Thesubject of that commit was the sensor clock; the deletion looks like collateral.
Nothing reported it, and that is the interesting part: no Ingenic SoC up to and
including T40 has a die temperature sensor, so no Ingenic kernel registers a
thermal zone, so the guard would have left
hal_temperatureNULL anyway.-tanswered "Temperature cannot be retrieved" before this change and answers it
after. The wiring is restored because it is the shape every sibling HAL has —
a kernel that ever grows a zone then needs no change here — and because a
function no caller can reach is a trap for the next reader.
Being unreachable, it had also kept two bugs:
a 45 °C chip would have been reported as
45000;-237.0, which-twould have printed as atemperature instead of letting
gethwtemp()'s NAN produce the honest error.Verification
Builds, all four as CI does them: native, arm32 (hi3516cv100 musleabi), mips32
(ingenic-t31 musl) and arm64 (Bootlin aarch64 musl) — clean, no new warnings.
cYAML_testandreginfo_testpass;tools/test_pipeline.shpasses.On hardware — lab T31 (T31L, SC2332, kernel
3.10.14__isvp_swan_1.0__), mips32build copied to the camera:
Unchanged, as intended.
/sys/class/thermaldoes not exist on that board atall — with
CONFIG_THERMALoff the class is never registered — so the guard iswhat keeps
--temphonest, and the reader itself cannot be exercised there.It was exercised instead against a real zone through
libipchwon the buildhost:
27800→27.80, and with the zone hidden underunshare -rmplus atmpfs over
/sys/class/thermal→NAN.Note
The same dead
-237.0sentinel is innovatek.c,fh.c,gm.c,allwinner.candrockchip.c. It is near-unreachable there too (theaccess()guard, and
/1000turns it into-0.237), so it is left alone here rather thanwidening this diff — happy to sweep it separately if wanted.