]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMinformeeList.cpp
a9ea2fbcf60d036353cf6cc2325f0f8947fc093a
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <IOKit/pwr_mgt/IOPM.h>
26 #include <IOKit/pwr_mgt/IOPMinformeeList.h>
27 #include <IOKit/pwr_mgt/IOPMinformee.h>
29 #define super OSObject
30 OSDefineMetaClassAndStructors(IOPMinformeeList
,OSObject
)
32 //*********************************************************************************
35 //*********************************************************************************
36 void IOPMinformeeList::initialize ( void )
42 //*********************************************************************************
45 //*********************************************************************************
47 IOReturn
IOPMinformeeList::addToList ( IOPMinformee
* newInformee
)
49 IOPMinformee
* nextInformee
;
50 nextInformee
= firstItem
; // Is new object already in the list?
51 while ( nextInformee
!= NULL
) {
52 if ( nextInformee
->whatObject
== newInformee
->whatObject
) {
53 return IOPMNoErr
; // yes, just return
55 nextInformee
= nextInList(nextInformee
);
57 newInformee
->nextInList
= firstItem
; // add it to list
58 firstItem
= newInformee
;
64 //*********************************************************************************
67 //*********************************************************************************
69 IOPMinformee
* IOPMinformeeList::firstInList ( void )
74 //*********************************************************************************
77 //*********************************************************************************
79 IOPMinformee
* IOPMinformeeList::nextInList ( IOPMinformee
* currentItem
)
81 if ( currentItem
!= NULL
) {
82 return (currentItem
->nextInList
);
87 //*********************************************************************************
90 //*********************************************************************************
92 unsigned long IOPMinformeeList::numberOfItems ( void )
97 //*********************************************************************************
100 // Look through the list for the one which points to the object identified
101 // by the parameter. Return a pointer to the list item or NULL.
102 //*********************************************************************************
104 IOPMinformee
* IOPMinformeeList::findItem ( IOService
* driverOrChild
)
106 IOPMinformee
* nextObject
;
108 nextObject
= firstInList();
109 while ( nextObject
!= NULL
) {
110 if ( nextObject
->whatObject
== driverOrChild
) {
113 nextObject
= nextInList(nextObject
);
119 //*********************************************************************************
122 // Find the item in the list, unlink it, and free it.
123 //*********************************************************************************
125 IOReturn
IOPMinformeeList::removeFromList ( IOService
* theItem
)
127 IOPMinformee
* item
= firstItem
;
130 if ( item
!= NULL
) {
131 if ( item
->whatObject
== theItem
) {
132 firstItem
= item
->nextInList
;
137 while ( item
->nextInList
!= NULL
) {
138 if ( item
->nextInList
->whatObject
== theItem
) {
139 temp
= item
->nextInList
;
140 item
->nextInList
= temp
->nextInList
;
145 item
= item
->nextInList
;
152 //*********************************************************************************
155 // Free all items in the list, and then free the list itself
156 //*********************************************************************************
158 void IOPMinformeeList::free (void )
160 IOPMinformee
* next
= firstItem
;
162 while ( next
!= NULL
) {
163 firstItem
= next
->nextInList
;