diff options
| author | Chris Lesiak <chris.lesiak@licor.com> | 2015-05-26 16:40:44 -0400 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2015-05-26 20:22:49 -0400 |
| commit | adba657533bdd255f7b78bc8a324091f46b294cd (patch) | |
| tree | 523aa28acd02d21e19e3860c5ad943585d075b82 | |
| parent | ba155e2d21f6bf05de86a78dbe5bfd8757604a65 (diff) | |
hwmon: (ntc_thermistor) Ensure iio channel is of type IIO_VOLTAGE
When configured via device tree, the associated iio device needs to be
measuring voltage for the conversion to resistance to be correct.
Return -EINVAL if that is not the case.
Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
Cc: stable@vger.kernel.org # 3.10+
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
| -rw-r--r-- | drivers/hwmon/ntc_thermistor.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 112e4d45e4a0..68800115876b 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c | |||
| @@ -239,8 +239,10 @@ static struct ntc_thermistor_platform_data * | |||
| 239 | ntc_thermistor_parse_dt(struct platform_device *pdev) | 239 | ntc_thermistor_parse_dt(struct platform_device *pdev) |
| 240 | { | 240 | { |
| 241 | struct iio_channel *chan; | 241 | struct iio_channel *chan; |
| 242 | enum iio_chan_type type; | ||
| 242 | struct device_node *np = pdev->dev.of_node; | 243 | struct device_node *np = pdev->dev.of_node; |
| 243 | struct ntc_thermistor_platform_data *pdata; | 244 | struct ntc_thermistor_platform_data *pdata; |
| 245 | int ret; | ||
| 244 | 246 | ||
| 245 | if (!np) | 247 | if (!np) |
| 246 | return NULL; | 248 | return NULL; |
| @@ -253,6 +255,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) | |||
| 253 | if (IS_ERR(chan)) | 255 | if (IS_ERR(chan)) |
| 254 | return ERR_CAST(chan); | 256 | return ERR_CAST(chan); |
| 255 | 257 | ||
| 258 | ret = iio_get_channel_type(chan, &type); | ||
| 259 | if (ret < 0) | ||
| 260 | return ERR_PTR(ret); | ||
| 261 | |||
| 262 | if (type != IIO_VOLTAGE) | ||
| 263 | return ERR_PTR(-EINVAL); | ||
| 264 | |||
| 256 | if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv)) | 265 | if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv)) |
| 257 | return ERR_PTR(-ENODEV); | 266 | return ERR_PTR(-ENODEV); |
| 258 | if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm)) | 267 | if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm)) |
