*参照元 [#i450a3a2] #backlinks *説明 [#q115905f] -パス: [[linux-2.6.33/]] -パス: [[linux-2.6.33/drivers/base/power/runtime.c]] -FIXME: これは何? --説明 **引数 [#q618ee0d] -struct device *dev -- --[[linux-2.6.33/device]] -bool from_wq -- **返り値 [#t08c19ae] -int -- **参考 [#s8c3a499] *実装 [#x9772b18] /** * __pm_runtime_resume - Carry out run-time resume of given device. * @dev: Device to resume. * @from_wq: If set, the function has been called via pm_wq. * * Check if the device can be woken up and run the ->runtime_resume() callback * provided by its bus type. If another resume has been started earlier, wait * for it to finish. If there's a suspend running in parallel with this * function, wait for it to finish and resume the device. Cancel any scheduled * or pending requests. * * This function must be called under dev->power.lock with interrupts disabled. */ int __pm_runtime_resume(struct device *dev, bool from_wq) __releases(&dev->power.lock) __acquires(&dev->power.lock) { - --[[linux-2.6.33/__releases()]] - --[[linux-2.6.33/__acquires()]] struct device *parent = NULL; int retval = 0; dev_dbg(dev, "__pm_runtime_resume()%s!\n", from_wq ? " from workqueue" : ""); - --[[linux-2.6.33/dev_dbg()]] repeat: if (dev->power.runtime_error) { retval = -EINVAL; goto out; } pm_runtime_cancel_pending(dev); - --[[linux-2.6.33/pm_runtime_cancel_pending()]] if (dev->power.runtime_status == RPM_ACTIVE) retval = 1; else if (dev->power.disable_depth > 0) retval = -EAGAIN; if (retval) goto out; if (dev->power.runtime_status == RPM_RESUMING || dev->power.runtime_status == RPM_SUSPENDING) { DEFINE_WAIT(wait); - --[[linux-2.6.33/DEFINE_WAIT()]] if (from_wq) { if (dev->power.runtime_status == RPM_SUSPENDING) dev->power.deferred_resume = true; retval = -EINPROGRESS; goto out; } /* Wait for the operation carried out in parallel with us. */ for (;;) { prepare_to_wait(&dev->power.wait_queue, &wait, TASK_UNINTERRUPTIBLE); if (dev->power.runtime_status != RPM_RESUMING && dev->power.runtime_status != RPM_SUSPENDING) break; - --[[linux-2.6.33/prepare_to_wait()]] spin_unlock_irq(&dev->power.lock); - --[[linux-2.6.33/spin_unlock_irq()]] schedule(); - --[[linux-2.6.33/schedule()]] spin_lock_irq(&dev->power.lock); - --[[linux-2.6.33/spin_lock_irq()]] } finish_wait(&dev->power.wait_queue, &wait); goto repeat; - --[[linux-2.6.33/finish_wait()]] } if (!parent && dev->parent) { /* * Increment the parent's resume counter and resume it if * necessary. */ parent = dev->parent; spin_unlock(&dev->power.lock); pm_runtime_get_noresume(parent); - --[[linux-2.6.33/pm_runtime_get_noresume()]] spin_lock(&parent->power.lock); /* * We can resume if the parent's run-time PM is disabled or it * is set to ignore children. */ if (!parent->power.disable_depth && !parent->power.ignore_children) { __pm_runtime_resume(parent, false); if (parent->power.runtime_status != RPM_ACTIVE) retval = -EBUSY; } - --[[linux-2.6.33/__pm_runtime_resume()]] spin_unlock(&parent->power.lock); spin_lock(&dev->power.lock); if (retval) goto out; goto repeat; } dev->power.runtime_status = RPM_RESUMING; if (dev->bus && dev->bus->pm && dev->bus->pm->runtime_resume) { spin_unlock_irq(&dev->power.lock); retval = dev->bus->pm->runtime_resume(dev); spin_lock_irq(&dev->power.lock); dev->power.runtime_error = retval; } else if (dev->type && dev->type->pm && dev->type->pm->runtime_resume) { spin_unlock_irq(&dev->power.lock); retval = dev->type->pm->runtime_resume(dev); spin_lock_irq(&dev->power.lock); dev->power.runtime_error = retval; } else if (dev->class && dev->class->pm && dev->class->pm->runtime_resume) { spin_unlock_irq(&dev->power.lock); retval = dev->class->pm->runtime_resume(dev); spin_lock_irq(&dev->power.lock); dev->power.runtime_error = retval; } else { retval = -ENOSYS; } if (retval) { dev->power.runtime_status = RPM_SUSPENDED; pm_runtime_cancel_pending(dev); - --[[linux-2.6.33/pm_runtime_cancel_pending()]] } else { dev->power.runtime_status = RPM_ACTIVE; if (parent) atomic_inc(&parent->power.child_count); - --[[linux-2.6.33/atomic_inc()]] } wake_up_all(&dev->power.wait_queue); - --[[linux-2.6.33/wake_up_all()]] if (!retval) __pm_request_idle(dev); - --[[linux-2.6.33/__pm_request_idle()]] out: if (parent) { spin_unlock_irq(&dev->power.lock); pm_runtime_put(parent); - --[[linux-2.6.33/pm_runtime_put()]] spin_lock_irq(&dev->power.lock); } dev_dbg(dev, "__pm_runtime_resume() returns %d!\n", retval); return retval; } *コメント [#a388053f]