summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDavid Yu <davyu@nvidia.com>2014-02-07 16:53:04 +0900
committerHarry Hong <hhong@nvidia.com>2014-02-11 20:28:27 -0800
commit33921eee6c2ab12c5ffbf62c0d60ef6fc5e37180 (patch)
tree906b04d76c9b22138c6074eacdf7c77b81ad066a /drivers
parentc4933507096028012dc28bd5475fa1ae3cc5cc86 (diff)
hwmon: ina230: fix i2c error
When ina230 is suspended, executing ina230_get_current() makes i2c error. Return INA230_ERROR when it is suspended. Change-Id: I738fd02e95dcd636ebc417bbc9d526cd0fb0ded7 Signed-off-by: David Yu <davyu@nvidia.com> Reviewed-on: http://git-master/r/364811 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Hyong Bin Kim <hyongbink@nvidia.com> Reviewed-by: Harry Hong <hhong@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/ina230.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/hwmon/ina230.c b/drivers/hwmon/ina230.c
index dc9a8e555a63..45c9424c1b00 100644
--- a/drivers/hwmon/ina230.c
+++ b/drivers/hwmon/ina230.c
@@ -3,7 +3,7 @@
* monitor sensor
*
*
- * Copyright (c) 2009-2013, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2009-2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -101,6 +101,7 @@ struct ina230_data {
struct mutex mutex;
bool running;
struct notifier_block nb;
+ bool suspended;
};
struct ina230_data *p_ina230_data;
@@ -579,7 +580,11 @@ s32 ina230_get_current(void)
client = p_ina230_data->client;
data = p_ina230_data;
+ if (data->suspended)
+ return INA230_ERROR;
+
mutex_lock(&data->mutex);
+
/* fill calib data */
retval = i2c_smbus_write_word_data(client, INA230_CAL,
__constant_cpu_to_be16(data->pdata->calibration_data));
@@ -728,13 +733,24 @@ static int __devexit ina230_remove(struct i2c_client *client)
static int ina230_suspend(struct i2c_client *client, pm_message_t mesg)
{
- return power_down_ina230(client);
+ int ret;
+ struct ina230_data *data = i2c_get_clientdata(client);
+
+ ret = power_down_ina230(client);
+ if (!ret)
+ data->suspended = true;
+
+ return ret;
}
static int ina230_resume(struct i2c_client *client)
{
+ struct ina230_data *data = i2c_get_clientdata(client);
+
evaluate_state(client);
+ data->suspended = false;
+
return 0;
}