From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
Benoit Cousson <bcousson@baylibre.com>,
Patrick Titiano <ptitiano@baylibre.com>,
LM Sensors <lm-sensors@lm-sensors.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [PATCH v6 3/5] hwmon: ina2xx: don't accept shunt values greater than the calibration factor
Date: Fri, 12 Dec 2014 15:37:53 +0100 [thread overview]
Message-ID: <1418395075-16850-4-git-send-email-bgolaszewski@baylibre.com> (raw)
In-Reply-To: <1418395075-16850-1-git-send-email-bgolaszewski@baylibre.com>
Shunt resistance values greater than the chip's calibration factor make no
sense since the actual value written to the register equals:
<calibration factor> / <shunt>
Bail-out from ina2xx_probe() if the configured value is greater than the
calibration factor.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/hwmon/ina2xx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 24fce2a..12f0e12 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -299,7 +299,8 @@ static int ina2xx_probe(struct i2c_client *client,
data->config = &ina2xx_config[data->kind];
data->client = client;
- if (data->rshunt <= 0)
+ if (data->rshunt <= 0 ||
+ data->rshunt > data->config->calibration_factor)
return -ENODEV;
ret = ina2xx_init(data);
--
2.1.3
next prev parent reply other threads:[~2014-12-12 14:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 14:37 [PATCH v6 0/5] hwmon: ina2xx: implement chip reinitialization and add new attributes Bartosz Golaszewski
2014-12-12 14:37 ` [PATCH v6 1/5] hwmon: ina2xx: reinitialize the chip in case it's been reset Bartosz Golaszewski
2014-12-12 16:53 ` Guenter Roeck
2014-12-12 14:37 ` [PATCH v6 2/5] hwmon: ina2xx: remove a stray new line Bartosz Golaszewski
2014-12-12 14:37 ` Bartosz Golaszewski [this message]
2014-12-12 14:37 ` [PATCH v6 4/5] hwmon: ina2xx: make shunt resistance configurable at run-time Bartosz Golaszewski
2014-12-12 14:37 ` [PATCH v6 5/5] hwmon: ina2xx: allow to change the averaging rate " Bartosz Golaszewski
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=1418395075-16850-4-git-send-email-bgolaszewski@baylibre.com \
--to=bgolaszewski@baylibre.com \
--cc=bcousson@baylibre.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
--cc=ptitiano@baylibre.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