*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
*
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
}
}
}
-
+
theNub->release();
if ( (pm_vars->theControllingDriver == NULL) || // if not fully initialized
return IOPMNoErr; // we can do no more
}
- // Perhaps the departing child was holding up idle or system sleep - we need to re-evaluate our
- // childrens' requests. Clear and re-calculate our kIOPMChildClamp and kIOPMChildClamp2 bits.
- rebuildChildClampBits();
-
computeDesiredState(); // this may be different now
changeState(); // change state if we can now tolerate lower power
IOLockUnlock(pm_vars->parentLock);
}
-//*********************************************************************************
-// rebuildChildClampBits
-//
-// The ChildClamp bits (kIOPMChildClamp & kIOPMChildClamp2) in our capabilityFlags
-// indicate that one of our children (or grandchildren or great-grandchildren or ...)
-// doesn't support idle or system sleep in its current state. Since we don't track the
-// origin of each bit, every time any child changes state we have to clear these bits
-// and rebuild them.
-//*********************************************************************************
-
-void IOService::rebuildChildClampBits(void)
-{
- unsigned long i;
- OSIterator * iter;
- OSObject * next;
- IOPowerConnection * connection;
-
-
- // A child's desires has changed. We need to rebuild the child-clamp bits in our
- // power state array. Start by clearing the bits in each power state.
-
- for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
- pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
- }
-
- // Now loop through the children. When we encounter the calling child, save
- // the computed state as this child's desire. And while we're at it, set the ChildClamp bits
- // in any of our states that some child has requested with clamp on.
-
- iter = getChildIterator(gIOPowerPlane);
-
- if ( iter )
- {
- while ( (next = iter->getNextObject()) )
- {
- if ( (connection = OSDynamicCast(IOPowerConnection,next)) )
- {
- if ( connection->getPreventIdleSleepFlag() )
- pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
- if ( connection->getPreventSystemSleepFlag() )
- pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
- }
- }
- iter->release();
- }
-
-}
-
//*********************************************************************************
// requestPowerDomainState
IOLockLock(pm_vars->childLock);
- // Now loop through the children. When we encounter the calling child, save
- // the computed state as this child's desire.
+// A child's desires has changed. We need to rebuild the child-clamp bits in our
+// power state array. Start by clearing the bits in each power state.
+
+ for ( i = 0; i < pm_vars->theNumberOfPowerStates; i++ ) {
+ pm_vars->thePowerStates[i].capabilityFlags &= ~(kIOPMChildClamp | kIOPMChildClamp2);
+ }
+
+// Now loop through the children. When we encounter the calling child, save
+// the computed state as this child's desire. And while we're at it, set the ChildClamp bits
+// in any of our states that some child has requested with clamp on.
+
iter = getChildIterator(gIOPowerPlane);
if ( iter ) {
connection->setPreventSystemSleepFlag(desiredState & kIOPMPreventSystemSleep);
connection->setChildHasRequestedPower();
}
+ if ( connection->getPreventIdleSleepFlag() ) {
+ pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp;
+ }
+ if ( connection->getPreventSystemSleepFlag() ) {
+ pm_vars->thePowerStates[connection->getDesiredDomainState()].capabilityFlags |= kIOPMChildClamp2;
+ }
}
}
iter->release();
}
-
- // Since a child's power requirements may have changed, clear and rebuild
- // kIOPMChildClamp and kIOPMChildClamp2 (idle and system sleep clamps)
- rebuildChildClampBits();
IOLockUnlock(pm_vars->childLock);
ourRequest |= kIOPMPreventSystemSleep;
}
- // is this a new desire?
- if ( priv->previousRequest == ourRequest )
- {
- // no, the parent knows already, just return
- return IOPMNoErr;
+ if ( priv->previousRequest == ourRequest ) { // is this a new desire?
+ return IOPMNoErr; // no, the parent knows already, just return
}
if ( priv->we_are_root ) {