Commit be37adc
committed
hm0360: _set_pll(): detect read_reg failure before writing PLL1CFG
The old code stored the raw return value of read_reg() in an 8-bit
variable and wrote it straight back to PLL1CFG. A negative I²C/SCCB
error therefore became 0xFF (or similar), silently corrupting the
sensor’s clock tree while still returning “success”.
* Read PLL1CFG into an int (`ret`) and return immediately if `ret < 0`.
* Cast to uint8_t only after the error check, then proceed with the
masked write.
This propagates read failures to the caller and guarantees we never
write garbage to the PLL register under fault conditions.1 parent ed74d59 commit be37adc
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
| |||
0 commit comments