Based on comments from Alan Stern, correct the setting of runtime PM
state in probe() and remove().

Signed-off-by: Hong Liu <[email protected]>
---
 drivers/misc/apds9802als.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
index 5fba5ff..fdd43f3 100644
--- a/drivers/misc/apds9802als.c
+++ b/drivers/misc/apds9802als.c
@@ -239,9 +239,8 @@ static int apds9802als_probe(struct i2c_client *client,
        als_set_default_config(client);
        mutex_init(&data->mutex);
 
+       pm_runtime_set_active(&client->dev);
        pm_runtime_enable(&client->dev);
-       pm_runtime_get(&client->dev);
-       pm_runtime_put(&client->dev);
 
        return res;
 als_error1:
@@ -250,12 +249,19 @@ als_error1:
        return res;
 }
 
-static int apds9802als_remove(struct i2c_client *client)
+static int __devexit apds9802als_remove(struct i2c_client *client)
 {
        struct als_data *data = i2c_get_clientdata(client);
 
+       pm_runtime_get_sync(&client->dev);
+
        als_set_power_state(client, false);
        sysfs_remove_group(&client->dev.kobj, &m_als_gr);
+
+       pm_runtime_disable(&client->dev);
+       pm_runtime_set_suspended(&client->dev);
+       pm_runtime_put_noidle(&client->dev);
+
        kfree(data);
        return 0;
 }
@@ -269,9 +275,6 @@ static int apds9802als_suspend(struct i2c_client *client, 
pm_message_t mesg)
 static int apds9802als_resume(struct i2c_client *client)
 {
        als_set_default_config(client);
-
-       pm_runtime_get(&client->dev);
-       pm_runtime_put(&client->dev);
        return 0;
 }
 
@@ -309,7 +312,7 @@ static struct i2c_driver apds9802als_driver = {
                .pm = &apds9802als_pm_ops,
        },
        .probe = apds9802als_probe,
-       .remove = apds9802als_remove,
+       .remove = __devexit_p(apds9802als_remove),
        .suspend = apds9802als_suspend,
        .resume = apds9802als_resume,
        .id_table = apds9802als_id,
-- 
1.7.2.3

_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to