Re: [PATCH] apds9802als: add runtime PM support

From: Andrew Morton
Date: Fri Oct 22 2010 - 16:04:07 EST


On Fri, 15 Oct 2010 14:47:25 +0100
Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:

> Update the driver for the needed runtime power features. Remove the old
> user controlled power functions.

How's this look?



put PM code under CONFIG_PM

Cc: Alan Cox <alan@xxxxxxxxxxxxxxx>
Cc: Hong Liu <hong.liu@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

drivers/misc/apds9802als.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff -puN drivers/misc/apds9802als.c~drivers-misc-apds9802alsc-add-runtime-pm-support-fix drivers/misc/apds9802als.c
--- a/drivers/misc/apds9802als.c~drivers-misc-apds9802alsc-add-runtime-pm-support-fix
+++ a/drivers/misc/apds9802als.c
@@ -266,6 +266,7 @@ static int apds9802als_remove(struct i2c
return 0;
}

+#ifdef CONFIG_PM
static int apds9802als_suspend(struct i2c_client *client, pm_message_t mesg)
{
als_set_power_state(client, false);
@@ -302,6 +303,14 @@ static const struct dev_pm_ops apds9802a
.runtime_resume = apds9802als_runtime_resume,
};

+#define APDS9802ALS_PM_OPS (&apds9802als_pm_ops)
+
+#else /* CONFIG_PM */
+#define apds9802als_suspend NULL
+#define apds9802als_resume NULL
+#define APDS9802ALS_PM_OPS NULL
+#endif /* CONFIG_PM */
+
static struct i2c_device_id apds9802als_id[] = {
{ DRIVER_NAME, 0 },
{ }
@@ -312,7 +321,7 @@ MODULE_DEVICE_TABLE(i2c, apds9802als_id)
static struct i2c_driver apds9802als_driver = {
.driver = {
.name = DRIVER_NAME,
- .pm = &apds9802als_pm_ops,
+ .pm = APDS9802ALS_PM_OPS,
},
.probe = apds9802als_probe,
.remove = apds9802als_remove,
_


And a question. This driver puts the .suspend and .resume pointers
into the `struct i2c_driver'. However drivers/misc/isl29020.c does not
do that. What's up with that?
--
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/