yangsong8-a1 opened a new pull request, #22193:
URL: https://github.com/apache/nuttx/pull/22193

   ## Summary
     
     Remove the redundant `!boot_on && !always_on` test in the else-if
     branch of regulator_register().
     
     The preceding if-branch already checks `boot_on || always_on`.  When
     control reaches the else-if, both boot_on and always_on are guaranteed
     to be false, so the explicit negation test is always true and can be
     dropped.
     
     Before:
     ```c
     if (rdev->desc->boot_on || rdev->desc->always_on)
         _regulator_do_enable(rdev);
     else if (!rdev->desc->boot_on && !rdev->desc->always_on
              && _regulator_is_enabled(rdev))
         _regulator_do_disable(rdev);
     
     After:
     
     if (rdev->desc->boot_on || rdev->desc->always_on)
         _regulator_do_enable(rdev);
     else if (_regulator_is_enabled(rdev))
         _regulator_do_disable(rdev);
     
     Impact
     
     No functional change.  The simplified condition is logically equivalent.
     
     In-tree callers of regulator_register(): regulator_gpio.c, 
regulator_rpmsg.c,
     act8945a.c — none are affected because the runtime behavior is unchanged.
     
     Testing
     
     Ubuntu 22.04, host gcc.  sim:nsh with REGULATOR, CMake, no new warnings.
     A temporary test program (not part of this PR) registers four dummy
     regulators that are already on, one for each boot_on/always_on
     combination, and prints the ops that regulator_register() calls.  The
     output is the same on master and with this change:
     
     nsh> hello
     boot_on 0 always_on 0, enabled before register:
         ops->disable
         rdev ok, enabled after 0
     boot_on 1 always_on 0, enabled before register:
         ops->enable
         rdev ok, enabled after 1
     boot_on 0 always_on 1, enabled before register:
         ops->enable
         rdev ok, enabled after 1
     boot_on 1 always_on 1, enabled before register:
         ops->enable
         rdev ok, enabled after 1
   


-- 
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]

Reply via email to