- PowerChangeEntry *theNode;
- int theState;
- IOService *theTarget;
- UInt16 theAction;
-
- // Dequeue and process the state change request
- if((theNode = (PowerChangeEntry *)OSDequeueAtomic((void **)&changes, 0)))
- {
- theState = theNode->state;
- theTarget = theNode->target;
- theAction = theNode->actionType;
- IOFree((void *)theNode, sizeof(PowerChangeEntry));
-
- switch (theAction)
- {
- case kUnIdle:
- theTarget->command_received(theState, 0, 0, 0);
- break;
- }
- }
+ IOPMPowerStateQueueAction queueAction = (IOPMPowerStateQueueAction) action;
+ PowerEventEntry * entry;
+
+ IOLockLock(queueLock);
+ while (!queue_empty(&queueHead))
+ {
+ queue_remove_first(&queueHead, entry, PowerEventEntry *, chain);
+ IOLockUnlock(queueLock);
+
+ (*queueAction)(owner, entry->eventType, entry->arg0, entry->arg1);
+ IODelete(entry, PowerEventEntry, 1);
+
+ IOLockLock(queueLock);
+ }
+ IOLockUnlock(queueLock);