summaryrefslogtreecommitdiff
path: root/drivers/hwmon/ina2xx.c
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2015-01-05 17:20:54 +0300
committerGuenter Roeck <linux@roeck-us.net>2015-01-26 08:23:59 +0300
commite794704000cf7954039b8daab9dfae2a74142f07 (patch)
treefba0eb87a16f494cd99d20b8a7f26ad7cbf45fd2 /drivers/hwmon/ina2xx.c
parentf4fe902717f3a3fa10e30544cef97b2ff2811db8 (diff)
downloadlinux-e794704000cf7954039b8daab9dfae2a74142f07.tar.xz
hwmon: (ina2xx) don't accept shunt values greater than the calibration factor
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> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ina2xx.c')
-rw-r--r--drivers/hwmon/ina2xx.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 39e017bf92fd..3234e571805c 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -313,7 +313,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);