This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 40eb6bc7894faec60d4e56bc3c4b24f97e9f18ff Author: Daniel P. Carvalho <[email protected]> AuthorDate: Tue Oct 20 06:08:53 2026 -0300 drivers/power: fix the open count of the SMPS driver smps_open() stored the open count only on the first open, so a second open left it at 1 and the first close that followed took the count to zero and called the lower half shutdown, while another descriptor was still open. Store the count on every open. Also return the result of the first-open setup instead of always returning OK, so that a failing lower half setup is seen by the caller. Also add the blank line after the declaration that nxstyle reports in the same function. Found while running a LM51772 on an STM32G4: a monitoring program that opened and closed the device switched the converter off. With the fix the converter keeps running across other opens and closes. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Daniel P. Carvalho <[email protected]> --- drivers/power/supply/smps.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/smps.c b/drivers/power/supply/smps.c index 5d4f8221359..fe61df02011 100644 --- a/drivers/power/supply/smps.c +++ b/drivers/power/supply/smps.c @@ -116,6 +116,7 @@ static int smps_open(FAR struct file *filep) /* Yes.. perform one time hardware initialization. */ irqstate_t flags = enter_critical_section(); + ret = dev->ops->setup(dev); if (ret == OK) { @@ -126,12 +127,16 @@ static int smps_open(FAR struct file *filep) leave_critical_section(flags); } + else + { + dev->ocount = tmp; + } } nxmutex_unlock(&dev->closelock); } - return OK; + return ret; } /****************************************************************************
