1
0
Fork 0

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>
hifive-unleashed-5.1
Daniel Mack 2009-05-06 16:03:00 -07:00 committed by Linus Torvalds
parent 57226e7898
commit 74614f8d9d
1 changed files with 7 additions and 2 deletions

View File

@ -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