diff options
| author | Old-Ding <[email protected]> | 2026-07-06 05:24:07 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2026-07-08 13:24:42 +0800 |
| commit | b9550aad85cfedbad660a1d948417fa93be85163 (patch) | |
| tree | fc6e774922ee69ff448f40b29431084cee51ff1f | |
| parent | d8a7e3eeb03ef68b85d957aa2077d81f437ca67f (diff) | |
drivers: dac: Fix disable callback check
_dac_control() checked the enabled callback before invoking disabled for RT_DAC_CMD_DISABLE. That can reject DAC drivers that provide a disable callback without enable, and can call through a NULL disabled callback when only enable is implemented.
Check the disabled callback in the disable command path so the guard matches the operation being dispatched.
Generated-by: OpenAI Codex
Signed-off-by: Old-Ding <[email protected]>
| -rw-r--r-- | components/drivers/misc/dac.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/components/drivers/misc/dac.c b/components/drivers/misc/dac.c index 78db9b1a55..8a1b0ccc72 100644 --- a/components/drivers/misc/dac.c +++ b/components/drivers/misc/dac.c @@ -46,7 +46,7 @@ static rt_err_t _dac_control(rt_device_t dev, int cmd, void *args) { result = dac->ops->enabled(dac, (rt_uint32_t)args); } - else if (cmd == RT_DAC_CMD_DISABLE && dac->ops->enabled) + else if (cmd == RT_DAC_CMD_DISABLE && dac->ops->disabled) { result = dac->ops->disabled(dac, (rt_uint32_t)args); } |
