summaryrefslogtreecommitdiff
path: root/drivers/hwmon/ina3221.c
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2018-11-05 12:48:40 -0800
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 15:13:11 -0800
commitefb0489ea8fa12c6a5b51c0b3e35f4f3d5d54939 (patch)
tree6e7da4f369e6f637bc5ef29f3725fa3222cb67f3 /drivers/hwmon/ina3221.c
parentdf04ced684d48f6ec5729ccd034702952160c6b3 (diff)
hwmon: (ina3221) Check channel status for alarms attribute read
There is nothing critically wrong to read these two attributes without having a is_enabled() check at this point. But reading the MASK_ENABLE register would clear the CVRF bit according to the datasheet. So it'd be safer to fence for disabled channels in order to add pm runtime feature. Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ina3221.c')
-rw-r--r--drivers/hwmon/ina3221.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index d61688f04594..26cdf3342d80 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -200,6 +200,12 @@ static int ina3221_read_curr(struct device *dev, u32 attr,
return 0;
case hwmon_curr_crit_alarm:
case hwmon_curr_max_alarm:
+ /* No actual register read if channel is disabled */
+ if (!ina3221_is_enabled(ina, channel)) {
+ /* Return 0 for alert flags */
+ *val = 0;
+ return 0;
+ }
ret = regmap_field_read(ina->fields[reg], &regval);
if (ret)
return ret;