Re: runtime PM: common hooks for static and runtime PM

Alan Stern
2010-02-05T21:40:11Z

On Fri, 5 Feb 2010, Mark Brown wrote:

> > As you have found out, that approach doesn't work. You need to figure
> > out some way of your own to avoid double disabling. The PM core can't
> > do it for you, because there may be devices that enter _different_
> > power states for runtime suspend and system suspend. For the sake of
> > such devices the core _has_ to do double suspends.
>
> Right, but my point is that one reason for wanting to call into the
> runtime PM API during vanilla suspend is that the indirection buys you
> the reference counting.

It's not reference counting; it's just a state variable. (There _is_ a
reference counter involved, but you don't want to use it.)

> I wonder if it's worth the PM core providing an off the shelf suspend
> and resume via runtime PM implementation so drivers only need to assign
> function pointers? As Kevin says this is going to be *very* common for
> embedded drivers.

What's so hard about doing this?

int my_suspend(struct device *dev)
{
if (dev->power.runtime_status == RPM_SUSPENDED)
return 0;
return my_runtime_suspend(dev);
}

Or if you prefer, stick the "if" statement at the beginning of your
suspend method and then set both function pointers to the same method.

Alan Stern