+//*********************************************************************************
+// PMfree
+//
+// Free up the data created in PMinit, if it exists.
+//*********************************************************************************
+void IOService::PMfree ( void )
+{
+ if ( priv ) {
+ if ( priv->clampTimerEventSrc != NULL ) {
+ getPMworkloop()->removeEventSource(priv->clampTimerEventSrc);
+ priv->clampTimerEventSrc->release();
+ priv->clampTimerEventSrc = NULL;
+ }
+ if ( priv->timerEventSrc != NULL ) {
+ pm_vars->PMworkloop->removeEventSource(priv->timerEventSrc);
+ priv->timerEventSrc->release();
+ priv->timerEventSrc = NULL;
+ }
+ if ( priv->settleTimer ) {
+ thread_call_cancel(priv->settleTimer);
+ thread_call_free(priv->settleTimer);
+ priv->settleTimer = NULL;
+ }
+ if ( priv->ackTimer ) {
+ thread_call_cancel(priv->ackTimer);
+ thread_call_free(priv->ackTimer);
+ priv->ackTimer = NULL;
+ }
+ if ( priv->our_lock ) {
+ IOLockFree(priv->our_lock);
+ priv->our_lock = NULL;
+ }
+ if ( priv->flags_lock ) {
+ IOLockFree(priv->flags_lock);
+ priv->flags_lock = NULL;
+ }
+ if ( priv->activityLock ) {
+ IOLockFree(priv->activityLock);
+ priv->activityLock = NULL;
+ }
+ priv->interestedDrivers->release();
+ priv->changeList->release();
+ // remove instance variables
+ priv->release();
+ }
+
+ if ( pm_vars ) {
+ if ( pm_vars->PMcommandGate ) {
+ if(pm_vars->PMworkloop)
+ pm_vars->PMworkloop->removeEventSource(pm_vars->PMcommandGate);
+ pm_vars->PMcommandGate->release();
+ pm_vars->PMcommandGate = NULL;
+ }
+ if ( pm_vars->PMworkloop ) {
+ // The work loop object returned from getPMworkLoop() is
+ // never retained, therefore it should not be released.
+ // pm_vars->PMworkloop->release();
+ pm_vars->PMworkloop = NULL;
+ }
+ if ( pm_vars->responseFlags ) {
+ pm_vars->responseFlags->release();
+ pm_vars->responseFlags = NULL;
+ }
+ // remove instance variables
+ pm_vars->release();
+ }
+}
+
+