isl29003: fix resume functionality

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, May 7, 2009 - 10:59 am

Gitweb:     http://git.kernel.org/linus/74614f8d9d4141a3752fc1c38706859b63f4842b
Commit:     74614f8d9d4141a3752fc1c38706859b63f4842b
Parent:     57226e7898076f864d6ce41ddeff4bbc772b950c
Author:     Daniel Mack <daniel@caiaq.de>
AuthorDate: Wed May 6 16:03:00 2009 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Wed May 6 16:36:10 2009 -0700

    isl29003: fix resume functionality
    
    The isl29003 does not interpret the return value of
    i2c_smbus_write_byte_data() correctly and hence causes an error on system
    resume.
    
    Also introduce power_state_before_suspend and restore the chip's power
    state upon wakeup.
    
    Signed-off-by: Daniel Mack <daniel@caiaq.de>
    Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
    Cc: Jean Delvare <khali@linux-fr.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 drivers/misc/isl29003.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/isl29003.c b/drivers/misc/isl29003.c
index 2e2a592..a71e245 100644
--- a/drivers/misc/isl29003.c
+++ b/drivers/misc/isl29003.c
@@ -64,6 +64,7 @@ struct isl29003_data {
 	struct i2c_client *client;
 	struct mutex lock;
 	u8 reg_cache[ISL29003_NUM_CACHABLE_REGS];
+	u8 power_state_before_suspend;
 };
 
 static int gain_range[] = {
@@ -411,6 +412,9 @@ static int __devexit isl29003_remove(struct i2c_client *client)
 #ifdef CONFIG_PM
 static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg)
 {
+	struct isl29003_data *data = i2c_get_clientdata(client);
+
+	data->power_state_before_suspend = isl29003_get_power_state(client);
 	return isl29003_set_power_state(client, 0);
 }
 
@@ -421,10 +425,11 @@ static int isl29003_resume(struct i2c_client *client)
 
 	/* restore registers from cache */
 	for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
-		if (!i2c_smbus_write_byte_data(client, i, data->reg_cache[i]))
+		if (i2c_smbus_write_byte_data(client, i, data->reg_cache[i]))
 			return -EIO;
 
-	return 0;
+	return isl29003_set_power_state(client,
+		data->power_state_before_suspend);
 }
 
 #else
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
isl29003: fix resume functionality, Linux Kernel Mailing ..., (Thu May 7, 10:59 am)