Donny9 opened a new pull request, #18234: URL: https://github.com/apache/nuttx/pull/18234
## Summary This PR includes three improvements to the Power Management (PM) subsystem: code cleanup, new API addition, and refactoring for better maintainability and functionality. ### Changes Overview: #### 1. Remove Unnecessary CONFIG_PM Guards **Purpose**: Code cleanup and simplification **Details**: Remove redundant preprocessor guards from PM source files since the entire directory is already conditionally compiled by the build system. #### 2. Add pm_updatestate() API **Purpose**: Provide atomic check-and-change operation **Details**: New API that combines pm_checkstate() and pm_changestate() to avoid recursive locking issues when applications need to atomically check and update PM state. #### 3. Remove pm_domain_lock Wrapper **Purpose**: Code simplification and performance improvement **Details**: Replace wrapper functions with direct spinlock calls to reduce overhead and improve code clarity. ### Why These Changes: 1. **Code Quality**: Removing unnecessary guards and wrappers makes the code cleaner and easier to maintain 2. **Functionality**: The new pm_updatestate() API solves a real problem where applications need atomic state updates without recursive locking 3. **Performance**: Direct spinlock usage eliminates unnecessary function call overhead 4. **Maintainability**: More explicit locking code is easier to understand and debug ## Impact ### Stability: - **Positive**: pm_updatestate() eliminates potential deadlock scenarios - **Neutral**: Other changes are refactoring with no functional impact - **No regression**: All existing functionality preserved ### Compatibility: - **No breaking changes**: All existing APIs remain unchanged - **New API added**: pm_updatestate() is additive, doesn't affect existing code - **Backward compatible**: Applications using pm_checkstate() + pm_changestate() continue to work ### Code Quality: - **Improved**: Cleaner code without redundant preprocessor guards - **Improved**: More explicit locking with direct spinlock usage - **Enhanced**: New API provides better solution for atomic state updates - **Reduced**: Less code overall (removed wrapper functions) ## Testing ### Test Steps: #### 1. Build Test ```bash # Configure with PM support ./tools/configure.sh sim:nsh make menuconfig # Enable CONFIG_PM and CONFIG_PM_GOVERNOR_ACTIVITY # Build and verify no warnings make clean && make -- 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]
