Re: [PATCH] apds9802als: add runtime PM support

From: Alan Stern
Date: Wed Oct 27 2010 - 10:14:08 EST


On Wed, 27 Oct 2010, Hong Liu wrote:

> In apds9802als_resume, I just want to power up the device, do some
> configuration, and then runtime_suspend the device.

Then you should change the function the way I suggested. The PM core
will automatically do a runtime suspend after the system has fully
woken up.

> We don't have runtime_idle() implemented, the driver exported sysfs
> entries to user space for data reading, and we do runtime_resume,
> measaure data, runtime_suspend in the read/write funciton of those sysfs
> entries. This is why I want to put the device into runtime suspend
> manually whenever possible.

Your approach will not work. You _must_ define runtime_idle() if you
want your driver to suspend correctly. It doesn't have to be
complicated; just make it call pm_runtime_suspend().

...

> We don't have runtime_idle() implemented, so I have to manually put the
> device into runtime suspend.

The problem is that the device can be runtime-resumed by code other
than your own, and that other code will not always do a runtime-suspend
afterward -- it will do a runtime-idle. That's why you need to define
a runtime_idle() callback.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/