imeghar2408-max opened a new pull request, #21734: URL: https://github.com/apache/nuttx/pull/21734
## Summary Fix an ADC upper-half reference-count bug in `adc_open()`. Previously, `dev->ad_ocount` was updated even when the first `ao_setup()` call failed. This left a phantom open reference. A subsequent `open()` could then skip hardware initialization because the driver incorrectly considered the device already initialized. Update the open count only when setup succeeds. This allows subsequent open attempts to retry initialization after a failed setup. The ADC lifecycle regression test is provided in the companion `nuttx-apps` change. ## Impact - Fixes ADC upper-half open reference counting. - No public API or configuration changes. - Prevents failed initialization from leaving an incorrect open reference. - Adds documentation for the companion ADC lifecycle regression test. ## Testing **Build host:** Linux x86_64 **Target:** NuttX Simulator ### Build Command: ```bash make -j4 ``` Output: ```text LD: nuttx Pac SIM with dynamic libs.. '/usr/lib/x86_64-linux-gnu/libz.so.1' -> 'sim-pac/libs/libz.so.1' '/usr/lib/x86_64-linux-gnu/libc.so.6' -> 'sim-pac/libs/libc.so.6' '/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/ld-linux-x86-64.so.2' SIM elf with dynamic libs archive in nuttx.tgz ``` ### Runtime regression test Command: ```bash set -o pipefail printf 'cmocka_driver_adc_open\npoweroff\n' | timeout 30s ./nuttx ``` Output: ```text nsh> cmocka_driver_adc_open [==========] tests: Running 1 test(s). [ RUN ] test_adc_open_setup_failure [ OK ] test_adc_open_setup_failure [==========] tests: 1 test(s) run. [ PASSED ] 1 test(s). nsh> poweroff ``` ### Additional checks - `git diff --check` — passed. - `tools/checkpatch.sh` — passed for the modified ADC source. The regression test uses a mock ADC lower half registered through `adc_register()` and does not require a physical ADC peripheral. Physical hardware validation has not been performed. ## Related changes Companion regression test in `apache/nuttx-apps`: `fix/adc-open-setup-failure` -- 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]
