Skip to contentSkip to conversation

Putting the device into runtime suspend after resume()/probe() is handled

PATCH RESEND In review Alan Cox 2 participants 4 messages Mar 9, 2011 Char and misc drivers

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH RESEND 1/1 Putting the device into runtime suspend after resume()/probe() is handled

From: Hong Liu <[email protected]>

by the PM core and the device core code. No need to manually add them in each single driver. And correct the runtime state in remove().

---

 drivers/misc/apds9802als.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/misc/apds9802als.c +10 -7
index 644d4cd..81db781 100644
@@ -245,9 +245,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:
@@ -255,12 +254,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;
 }
@@ -275,9 +281,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;
 }
 
@@ -323,7 +326,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 lore raw
Quoted 6 lines · On Wed, 09 Mar 2011 12:39:34 +0000 Alan Cox <[email protected]> wrote:

From: Alan Cox <[email protected]>
To: [email protected], [email protected]
Subject: [PATCH, RESEND] Putting the device into runtime suspend after resume()/probe() is handled
Date: Wed, 09 Mar 2011 12:39:34 +0000
User-Agent: StGIT/0.14.3

Quoted 7 lines

From: Hong Liu <[email protected]>

by the PM core and the device core code. No need to manually add them in each single driver. And correct the runtime state in remove().

I'd merged this a while back but was awaiting info on why v1 had a cc:stable so the changelog could be updated to indicate why a -stable backport was needed.

I see that the cc:stable has been removed so that settles that. But it's still unclear how serious the bugs-which-were fixed are. Oh well, a bug's a bug. I put it in my 2.6.38 queue anyway.

author
#2 lore raw
Quoted 17 lines · On Wed, 9 Mar 2011 13:45:04 -0800 Andrew Morton <[email protected]>…
Quoted 6 lines · On Wed, 09 Mar 2011 12:39:34 +0000 Alan Cox <[email protected]> wrote:

From: Alan Cox <[email protected]>
To: [email protected], [email protected]
Subject: [PATCH, RESEND] Putting the device into runtime suspend after resume()/probe() is handled
Date: Wed, 09 Mar 2011 12:39:34 +0000
User-Agent: StGIT/0.14.3

Quoted 7 lines

From: Hong Liu <[email protected]>

by the PM core and the device core code. No need to manually add them in each single driver. And correct the runtime state in remove().

Quoted 7 lines

I'd merged this a while back but was awaiting info on why v1 had a cc:stable so the changelog could be updated to indicate why a -stable backport was needed.

I see that the cc:stable has been removed so that settles that. But it's still unclear how serious the bugs-which-were fixed are. Oh well, a bug's a bug. I put it in my 2.6.38 queue anyway.

Don't think anything there is that important. Also anyone actually using the driver would I'm pretty sure currently be running an Intel spun kernel not a generic 2.6.older unless someone is also now relying on it for another platform anyway.

#3 lore raw
Quoted 24 lines · On Wed, 9 Mar 2011 21:59:32 +0000 Alan Cox <[email protected]> wrote:
Quoted 21 lines · On Wed, 9 Mar 2011 13:45:04 -0800 Andrew Morton <[email protected]>…
Quoted 6 lines · On Wed, 09 Mar 2011 12:39:34 +0000 Alan Cox <[email protected]> wrote:

From: Alan Cox <[email protected]>
To: [email protected], [email protected]
Subject: [PATCH, RESEND] Putting the device into runtime suspend after resume()/probe() is handled
Date: Wed, 09 Mar 2011 12:39:34 +0000
User-Agent: StGIT/0.14.3

Quoted 7 lines

From: Hong Liu <[email protected]>

by the PM core and the device core code. No need to manually add them in each single driver. And correct the runtime state in remove().

I'd merged this a while back but was awaiting info on why v1 had a cc:stable so the changelog could be updated to indicate why a -stable backport was needed.

Quoted 8 lines
Quoted 3 lines

I see that the cc:stable has been removed so that settles that. But it's still unclear how serious the bugs-which-were fixed are. Oh well, a bug's a bug. I put it in my 2.6.38 queue anyway.

Don't think anything there is that important. Also anyone actually using the driver would I'm pretty sure currently be running an Intel spun kernel not a generic 2.6.older unless someone is also now relying on it for another platform anyway.

OK, thanks. Let's shoot for 2.6.39 then.