Swatantra-66 commented on PR #20642: URL: https://github.com/apache/nuttx/pull/20642#issuecomment-6155042072
Hi @michallenc, To provide some context on the bug this PR fixes: `adc_sampletime_cfg()` is called from the upper-half character driver path where the input argument `dev` is `struct adc_dev_s *`. The underlying STM32 private hardware state is stored in `dev->ad_priv` (`struct stm32_dev_s *`). `stm32_adc_m0_v1.c` was mistakenly passing the upper-half pointer `dev` directly into `adc_sampletime_set()` and `adc_sampletime_write()`. Both functions cast their parameter to `(struct stm32_dev_s *)`, reading `priv->base` from bogus offsets in `struct adc_dev_s`. Passing `(struct stm32_adc_dev_s *)dev->ad_priv` aligns this driver with sibling implementations in `stm32_adc_m3m4_v1v2.c:2621` and `stm32_adc.c:1591`. Regarding the two structures: `stm32_dev_s` is the actual hardware instance state, while `stm32_adc_dev_s` serves as the handle for `CONFIG_STM32_ADC_LL_OPS` (used by lower-level subsystems like motor control / FOC). Unifying or renaming them (e.g. `stm32_dev_s` -> `stm32_adc_priv_s`) would certainly improve clarity in a dedicated refactoring PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
