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
The following commit(s) were added to refs/heads/master by this push:
new 9dbb52861e0 supply: remove smps.c critical_section
9dbb52861e0 is described below
commit 9dbb52861e0a54c60d3c128371096a947d1327ab
Author: tengshuangshuang <[email protected]>
AuthorDate: Tue Jun 24 14:34:50 2025 +0800
supply: remove smps.c critical_section
Remove the redundant enter_critical_section()/leave_critical_section()
calls in the SMPS upper-half driver open and close paths.
Both smps_open() and smps_close() already hold the closelock mutex
while calling ops->setup() and ops->shutdown(). The critical section
inside the mutex-protected region is unnecessary: the mutex serializes
concurrent open/close calls, and the lower-half callbacks are not
called from interrupt context.
Signed-off-by: tengshuangshuang <[email protected]>
---
drivers/power/supply/smps.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/power/supply/smps.c b/drivers/power/supply/smps.c
index f0ea8ad465a..30730de94f2 100644
--- a/drivers/power/supply/smps.c
+++ b/drivers/power/supply/smps.c
@@ -115,8 +115,6 @@ 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)
{
@@ -124,8 +122,6 @@ static int smps_open(FAR struct file *filep)
dev->ocount = tmp;
}
-
- leave_critical_section(flags);
}
else
{
@@ -152,7 +148,6 @@ static int smps_close(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
FAR struct smps_dev_s *dev = inode->i_private;
- irqstate_t flags;
int ret;
ret = nxmutex_lock(&dev->closelock);
@@ -175,9 +170,7 @@ static int smps_close(FAR struct file *filep)
/* Free the IRQ and disable the SMPS device */
- flags = enter_critical_section(); /* Disable interrupts */
- dev->ops->shutdown(dev); /* Disable the SMPS */
- leave_critical_section(flags);
+ dev->ops->shutdown(dev); /* Disable the SMPS */
nxmutex_unlock(&dev->closelock);
}