[linux-pm] [PATCH 01/11] PM: Add wake lock api.

Arve Hjønnevåg arve at android.com
Wed Jan 14 15:07:32 PST 2009


On Wed, Jan 14, 2009 at 1:09 AM, Nigel Cunningham
<ncunningham at crca.org.au> wrote:
>> +/* A wake_lock prevents the system from entering suspend or other low power
>> + * states when active. If the type is set to WAKE_LOCK_SUSPEND, the wake_lock
>> + * prevents a full system suspend. If the type is WAKE_LOCK_IDLE, low power
>
> Does this include hibernation? If so, you might like to say 'sleep'
> instead of suspend.
>

Not as it is currently implemented, but it probably should. The main
reason I avoid saying 'sleep' is that we enter cpu sleep modes from
idle as well.

>> + * states that cause large interrupt latencies or that disable a set of
>> + * interrupts will not entered from idle until the wake_locks are released.
>
> This makes me wonder if 'wake_locks' is an appropriate name - you're
> locking against sleeping rather than waking.
>

It depends on how you look at it. We lock the system in the wake
state, or we lock against the suspend/sleep state. I have also seen
the term sleep vote used for a very similar mechanism, but I don't
like this either as a sleep vote is a veto against sleep.
I initially called it a suspend lock, then wake lock in user space.
Wake lock is the term that stuck so I changed the kernel api to use
it.

>
> If CONFIG_HAS_WAKELOCK and CONFIG_WAKELOCK_STAT are both off, you've got
> an empty struct wake_lock definition. It wouldn't have any users, would
> it? (And therefore doesn't need to be defined at all).
>

I do this to avoid #ifdefs on CONFIG_HAS_WAKELOCK in the drivers.

>> +/* wake_lock_active returns a non-zero value if the wake_lock is currently
>> + * locked. If the wake_lock has a timeout, it does not check the timeout
>> + * but if the timeout had aready been checked it will return 0.
>
> s/aready/already/
>
> What does it mean for the timeout to already have been checked? Is that
> the same as the timeout having already expired?
>

What I meant was that the wake lock had been checked and deactivated
from another code-path, after the timeout expired.


-- 
Arve Hjønnevåg


More information about the linux-pm mailing list