From: Ninad Malwade <nmalwade@nvidia.com>
To: <nmalwade@nvidia.com>, <treding@nvidia.com>,
<jonathanh@nvidia.com>, <linux@roeck-us.net>, <jdelvare@suse.com>,
<nicolinc@nvidia.com>, <rkasirajan@nvidia.com>
Cc: <linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-pm@vger.kernel.org>
Subject: [PATCH] ina3221: correct the update_interval value
Date: Tue, 8 Nov 2022 13:00:29 +0800 [thread overview]
Message-ID: <20221108050029.24576-1-nmalwade@nvidia.com> (raw)
As per the INA3221 datasheet the samples value should not be
considered while calculating the update_interval value.
Section 8.4.2.2 from datasheet says - "The conversion-time
settings, along with the programmable-averaging mode, enable
the INA3221 to optimize available timing requirements in a given
application. For example, if a system requires data to be read
every 2 ms with all three channels monitored, configure the INA3221
with the conversion times for the shunt- and bus-voltage
measurements set to 332 μs"
As per above only conversion time and number of channels are
required to set the update_interval value. Correcting the same in
the driver.
Signed-off-by: Ninad Malwade <nmalwade@nvidia.com>
---
Documentation/hwmon/ina3221.rst | 3 +--
drivers/hwmon/ina3221.c | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/Documentation/hwmon/ina3221.rst b/Documentation/hwmon/ina3221.rst
index 8c12c54d2c24..a4f107d1e489 100644
--- a/Documentation/hwmon/ina3221.rst
+++ b/Documentation/hwmon/ina3221.rst
@@ -61,10 +61,9 @@ samples Number of samples using in the averaging mode.
update_interval Data conversion time in millisecond, following:
- update_interval = C x S x (BC + SC)
+ update_interval = C x (BC + SC)
* C: number of enabled channels
- * S: number of samples
* BC: bus-voltage conversion time in millisecond
* SC: shunt-voltage conversion time in millisecond
diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 2a57f4b60c29..e3aa57e3b039 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -183,11 +183,9 @@ static const int ina3221_avg_samples[] = {
static inline u32 ina3221_interval_ms_to_conv_time(u16 config, int interval)
{
u32 channels = hweight16(config & INA3221_CONFIG_CHs_EN_MASK);
- u32 samples_idx = INA3221_CONFIG_AVG(config);
- u32 samples = ina3221_avg_samples[samples_idx];
/* Bisect the result to Bus and Shunt conversion times */
- return DIV_ROUND_CLOSEST(interval * 1000 / 2, channels * samples);
+ return DIV_ROUND_CLOSEST(interval / 2, channels);
}
/* Converting CONFIG register value to update_interval in usec */
--
2.17.1
next reply other threads:[~2022-11-08 5:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 5:00 Ninad Malwade [this message]
2022-11-08 13:24 ` [PATCH] ina3221: correct the update_interval value Thierry Reding
2022-11-11 16:38 ` 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=20221108050029.24576-1-nmalwade@nvidia.com \
--to=nmalwade@nvidia.com \
--cc=jdelvare@suse.com \
--cc=jonathanh@nvidia.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nicolinc@nvidia.com \
--cc=rkasirajan@nvidia.com \
--cc=treding@nvidia.com \
/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