From: Nicolin Chen <nicoleotsuka@gmail.com>
To: jdelvare@suse.com, linux@roeck-us.net
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 1/4] hwmon: (ina3221) Check channel status for alarms attribute read
Date: Mon, 5 Nov 2018 12:48:40 -0800 [thread overview]
Message-ID: <20181105204843.4081-2-nicoleotsuka@gmail.com> (raw)
In-Reply-To: <20181105204843.4081-1-nicoleotsuka@gmail.com>
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>
---
Changelog
v2->v5:
* N/A
v1->v2:
* Returned 0 for alert flags instead of -ENODATA
drivers/hwmon/ina3221.c | 6 ++++++
1 file changed, 6 insertions(+)
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], ®val);
if (ret)
return ret;
--
2.17.1
next prev parent reply other threads:[~2018-11-05 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 20:48 [PATCH v5 0/4] hwmon: (ina3221) Implement PM runtime to save power Nicolin Chen
2018-11-05 20:48 ` Nicolin Chen [this message]
2018-11-05 20:48 ` [PATCH v5 2/4] hwmon: (ina3221) Serialize sysfs ABI accesses Nicolin Chen
2018-11-05 20:48 ` [PATCH v5 3/4] hwmon: (ina3221) Make sure data is ready before reading Nicolin Chen
2018-11-05 20:48 ` [PATCH v5 4/4] hwmon: (ina3221) Add PM runtime support Nicolin Chen
2018-11-09 22:57 ` [PATCH v5 0/4] hwmon: (ina3221) Implement PM runtime to save power Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181105204843.4081-2-nicoleotsuka@gmail.com \
--to=nicoleotsuka@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).