提交 e7947040 编写于 作者: B Bartosz Golaszewski 提交者: Guenter Roeck

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: NBartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 f4fe9027
...@@ -313,7 +313,8 @@ static int ina2xx_probe(struct i2c_client *client, ...@@ -313,7 +313,8 @@ static int ina2xx_probe(struct i2c_client *client,
data->config = &ina2xx_config[data->kind]; data->config = &ina2xx_config[data->kind];
data->client = client; data->client = client;
if (data->rshunt <= 0) if (data->rshunt <= 0 ||
data->rshunt > data->config->calibration_factor)
return -ENODEV; return -ENODEV;
ret = ina2xx_init(data); ret = ina2xx_init(data);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册