drivers/power/pm_changestate.c
/****************************************************************************
 * Name: pm_changestate
 *
 * Description:
 *   This function is used by platform-specific power management logic.  It
 *   will announce the power management power management state change to all
 *   drivers that have registered for power management event callbacks.
 *
 * Input Parameters:
 *   newstate - Identifies the new PM state
 *
 * Returned Value:
 *   0 (OK) means that the callback function for all registered drivers
 *   returned OK (meaning that they accept the state change).  Non-zero
 *   means that one of the drivers refused the state change.  In this case,
 *   the system will revert to the preceding state.
 *
 * Assumptions:
 *   It is assumed that interrupts are disabled when this function is
 *   called.  This function is probably called from the IDLE loop... the
 *   lowest priority task in the system.  Changing driver power management
 *   states may result in renewed system activity and, as a result, can
 *   suspend the IDLE thread before it completes the entire state change
 *   unless interrupts are disabled throughout the state change.
 *
 ****************************************************************************/
pm_changestate
Description:
This function is used by platform-specific power management logic.  It
will announce the power management power management state change to all
drivers that have registered for power management event callbacks.

Input Parameters:
newstate - Identifies the new PM state

Returned Value:
0 (OK) means that the callback function for all registered drivers
returned OK (meaning that they accept the state change).  Non-zero
means that one of the drivers refused the state change.  In this case,
the system will revert to the preceding state.

It is assumed that interrupts are disabled when this function is
called.  This function is probably called from the IDLE loop... the
lowest priority task in the system.  Changing driver power management
states may result in renewed system activity and, as a result, can
suspend the IDLE thread before it completes the entire state change
unless interrupts are disabled throughout the state change.
pm_changestate Description : This function is used by platform - specific power management logic . It will announce the power management power management state change to all drivers that have registered for power management event callbacks . Input Parameters : newstate - Identifies the new PM state Returned Value : 0 ( OK ) means that the callback function for all registered drivers returned OK ( meaning that they accept the state change ) . Non - zero means that one of the drivers refused the state change . In this case the system will revert to the preceding state . It is assumed that interrupts are disabled when this function is called . This function is probably called from the IDLE loop ... the lowest priority task in the system . Changing driver power management states may result in renewed system activity and as a result can suspend the IDLE thread before it completes the entire state change unless interrupts are disabled throughout the state change .
int pm_changestate(enum pm_state_e newstate)
{
  irqstate_t flags;
  int ret;
  flags = irqsave();
  ret = pm_prepall(newstate);
  if (ret != OK)
    {
      newstate = g_pmglobals.state;
      (void)pm_prepall(newstate);
    }
  pm_changeall(newstate);
  g_pmglobals.state = newstate;
  irqrestore(flags);
  return ret;
}
int pm_changestate ( enum pm_state_e newstate ) { irqstate_t flags ; int ret ; flags = irqsave ( ) ; ret = pm_prepall ( newstate ) ; if ( ret != OK ) { newstate = g_pmglobals . state ; ( void ) pm_prepall ( newstate ) ; } pm_changeall ( newstate ) ; g_pmglobals . state = newstate ; irqrestore ( flags ) ; return ret ; }
Name: pm_changestate
 Description:
   This function is used by platform-specific power management logic.
Name : pm_changestate Description : This function is used by platform - specific power management logic .
/* Disable interrupts throught this operation... changing driver states
   * could cause additional driver activity that might interfere with the
   * state change.  When the state change is complete, interrupts will be
   * re-enabled.
   */ /* First, prepare the drivers for the state change.  In this phase,
   * drivers may refuse the state state change.
   */ /* One or more drivers is not ready for this state change.  Revert to
       * the preceding state.
       */ /* All drivers have agreed to the state change (or, one or more have
   * disagreed and the state has been reverted).  Set the new state.
   */ /* Restore the interrupt state */