diff options
author | Timo Alho <talho@nvidia.com> | 2013-05-31 21:58:07 +0300 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-14 13:16:22 -0700 |
commit | 0045ca2e46cad7e3d7979ac434836e3db58c584a (patch) | |
tree | 8628405746fa3ef9b8a64e129596d31615aca86c /drivers/hwmon | |
parent | bd6952be7afcc7880a448c40d825c091214fd554 (diff) |
hwmon: ina230: add function to check alert flag
This patch adds a function to check the status of alert flag. This
enables alert functionality to be used (by polling) for ina devices
that do not have alert IO signal connected to AP.
Change-Id: Id9cf87a324a6c817d431b544f38e4cd9ebb7f28f
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/234634
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ina230.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hwmon/ina230.c b/drivers/hwmon/ina230.c index eeb46e562e74..e9db50fa6674 100644 --- a/drivers/hwmon/ina230.c +++ b/drivers/hwmon/ina230.c @@ -516,6 +516,33 @@ static s32 show_power(struct device *dev, return sprintf(buf, "%d mW\n", power_mW); } +static s32 show_alert_flag(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct ina230_data *data = i2c_get_clientdata(client); + int retval; + s32 alert_flag; + + mutex_lock(&data->mutex); + retval = ensure_enabled_start(client); + if (retval < 0) { + mutex_unlock(&data->mutex); + return retval; + } + + alert_flag = be16_to_cpu(i2c_smbus_read_word_data(client, + INA230_MASK)); + + ensure_enabled_end(client); + mutex_unlock(&data->mutex); + + alert_flag = (alert_flag >> 4) & 0x1; + return sprintf(buf, "%d\n", alert_flag); +} + + static int ina230_hotplug_notify(struct notifier_block *nb, unsigned long event, void *hcpu) { @@ -541,6 +568,7 @@ static struct sensor_device_attribute ina230[] = { SENSOR_ATTR(in1_input, S_IRUGO, show_bus_voltage, NULL, 0), #endif SENSOR_ATTR(power1_input, S_IRUGO, show_power, NULL, 0), + SENSOR_ATTR(alert_flag, S_IRUGO, show_alert_flag, NULL, 0), }; |