Loading...
iokit/Kernel/IOPMPowerSource.cpp xnu-3248.50.21 xnu-792.13.8
--- xnu/xnu-3248.50.21/iokit/Kernel/IOPMPowerSource.cpp
+++ xnu/xnu-792.13.8/iokit/Kernel/IOPMPowerSource.cpp
@@ -1,29 +1,31 @@
 /*
  * Copyright (c) 1998-2005 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
- * 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. The rights granted to you under the License
- * may not be used to create, or enable the creation or redistribution of,
- * unlawful or unlicensed copies of an Apple operating system, or to
- * circumvent, violate, or enable the circumvention or violation of, any
- * terms of an Apple operating system software license agreement.
- * 
- * 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
- * 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
+ * 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.  The rights granted to you under the 
+ * License may not be used to create, or enable the creation or 
+ * redistribution of, unlawful or unlicensed copies of an Apple operating 
+ * system, or to circumvent, violate, or enable the circumvention or 
+ * violation of, any terms of an Apple operating system software license 
+ * agreement.
+ *
+ * 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 
+ * 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.
- * 
- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
  */
 
 #include <IOKit/pwr_mgt/IOPMPowerSource.h>
@@ -132,9 +134,6 @@
     OSObject                        *iteratorKey;
     OSObject                        *obj;
 
-    // do nothing if settings haven't changed
-    if(!settingsChangedSinceUpdate) return;
-
     iterator = OSCollectionIterator::withCollection(properties);
     if(!iterator) return;
 
@@ -149,8 +148,6 @@
     }
     iterator->release();
 
-    settingsChangedSinceUpdate = false;
-
     // And up goes the flare
     messageClients(kIOPMMessageBatteryStatusHasChanged);
 }
@@ -162,132 +159,125 @@
  *
  ******************************************************************************/
  
-void IOPMPowerSource::setPSProperty(const OSSymbol *key, OSObject *val)
-{
-    OSObject    *lastVal;
-
-    if(!key || !val) return;
-
-    // Compare new setting with existing setting; update 
-    // 'settingsChangedSinceUpdate' if the setting has changed.
-    // If values are OSNumbers, do equality comparison.
-    // Otherwise, just compare pointers.
-    
-    if( (lastVal = properties->getObject(key)) ) {
-	if(val->isEqualTo(lastVal)) {
-	    // settings didn't change
-	} else {
-	    // num val is not equal to last val
-	    settingsChangedSinceUpdate = true;
-	}
-    } else {
-        // new setting; no last value
-        settingsChangedSinceUpdate = true;
-    }
-    
-    // here's the part where we go crazy.
-    properties->setObject(key, val);
-}
-
-
- 
 void IOPMPowerSource::setExternalConnected(bool b) {
-    setPSProperty(externalConnectedKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                externalConnectedKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 void IOPMPowerSource::setExternalChargeCapable(bool b) {
-    setPSProperty(externalChargeCapableKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                externalChargeCapableKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 void IOPMPowerSource::setBatteryInstalled(bool b) {
-    setPSProperty(batteryInstalledKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                batteryInstalledKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 void IOPMPowerSource::setIsCharging(bool b) {
-    setPSProperty(chargingKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                chargingKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 void IOPMPowerSource::setAtWarnLevel(bool b) {
-    setPSProperty(warnLevelKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                warnLevelKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 void IOPMPowerSource::setAtCriticalLevel(bool b) {
-    setPSProperty(criticalLevelKey,
-            b ? kOSBooleanTrue : kOSBooleanFalse);    
+    properties->setObject(
+                criticalLevelKey,
+                b ? kOSBooleanTrue:kOSBooleanFalse);    
 }
 
 
 void IOPMPowerSource::setCurrentCapacity(unsigned int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(currentCapacityKey, n);
+    properties->setObject(
+                currentCapacityKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setMaxCapacity(unsigned int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(maxCapacityKey, n);
+    properties->setObject(
+                maxCapacityKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setTimeRemaining(int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(timeRemainingKey, n);
+    properties->setObject(
+                timeRemainingKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setAmperage(int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(amperageKey, n);
+    properties->setObject(
+                amperageKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setVoltage(unsigned int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(voltageKey, n);
+    properties->setObject(
+                voltageKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setCycleCount(unsigned int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(cycleCountKey, n);
+    properties->setObject(
+                cycleCountKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setAdapterInfo(int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(adapterInfoKey, n);
+    properties->setObject(
+                adapterInfoKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setLocation(int val) {
     OSNumber *n = OSNumber::withNumber(val, 32);
-    setPSProperty(locationKey, n);
+    properties->setObject(
+                locationKey,
+                n);
     n->release();
 }
 
 void IOPMPowerSource::setErrorCondition(OSSymbol *s) {
-    setPSProperty(errorConditionKey, s);
+    properties->setObject(errorConditionKey, s);
 }
 
 void IOPMPowerSource::setManufacturer(OSSymbol *s) {
-    setPSProperty(manufacturerKey, s);
+    properties->setObject(manufacturerKey, s);
 }
 
 void IOPMPowerSource::setModel(OSSymbol *s) {
-    setPSProperty(modelKey, s);
+    properties->setObject(modelKey, s);
 }
 
 void IOPMPowerSource::setSerial(OSSymbol *s) {
-    setPSProperty(serialKey, s);
+    properties->setObject(serialKey, s);
 }
 
 void IOPMPowerSource::setLegacyIOBatteryInfo(OSDictionary *d) {
-    setPSProperty(batteryInfoKey, d);
+    properties->setObject(batteryInfoKey, d);
 }
 
 
@@ -298,11 +288,6 @@
  * PUBLIC Accessors. All the getters! Boo!
  *
  ******************************************************************************/
-
-OSObject *IOPMPowerSource::getPSProperty(const OSSymbol *symmie) {
-    if(!symmie) return NULL;
-    return properties->getObject(symmie);
-}
 
 bool IOPMPowerSource::externalConnected(void) {
     return (kOSBooleanTrue == properties->getObject(externalConnectedKey));