drivers: sensor: drop int64 casts where int32 suffices #127517
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 272 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.336
Real PR Conversation Timeline
1 comments
"Review active on #127517"
general
weight: 0.35
rbuisson-invn
Description
The hmc5883l, icm42605 and mpu9250 conversion helpers cast small int16 samples to
int64_tfor fraction math even though every intermediate fits in int32, pulling the software 64-bit division helper (__aeabi_ldivmod) onto divider-less cores on every sample:drivers/sensor/honeywell/hmc5883l/hmc5883l.c\u2014(((int64_t)raw_val % divider) 1000000L) / divider: the largest gain divisor inhmc5883l_gain[]is 1370, soremainder 1000000peaks at 1.37e9.drivers/sensor/tdk/icm42605/icm42605.c\u2014 the temperature conversion divides and mods a 64-bitraw_val 100by 207; the value peaks at 3.3e6 and the remainder fraction at 2.06e8. This is the direct TDK sibling of the icm40627 conversion #125508 rewrote.drivers/sensor/tdk/mpu9250/mpu9250.c\u2014((int64_t)(raw_val % 334) 1000000) / 334: peaks at 3.34e8.The int64 casts are dropped so the conversions run in int32 arithmetic.
Motivation and context
Same class as #125508 and #126044. Found by rescanning
drivers/sensor/for 64-bit divisions and modulos by non-power-of-two constants after #126044; these three drivers cast values whose full intermediate chains fit int32. Neighboring/ 256-style sites were excluded because the compiler already lowers signed power-of-two divides to shifts, andlis3mdl(largest divisor 6842) is excluded because the naive cast-drop would overflow int32 there \u2014 noted in #127516 as needing the wider per-gain reduction technique.Fixes #127516
How was this tested?
Equivalence verified exhaustively against the previous int64 form with C truncation semantics (not Python floor): all 2^16 signed int16 input values, for each hmc5883l gain divisor (all eight), for icm42605, and for mpu9250 \u2014 identical results, and every intermediate proven int32-bounded (largest: 1.37e9 in the hmc5883l 1370-divisor case). No local twister run available on this machine; CI compiles the drivers and runs the sensor test suites.
Note
Developed with AI assistance (rescan, rewrite and equivalence proof), reviewed and verified by the contributor \u2014 recorded via the
Assisted-by:trailer in the commit message.