aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorChris Lesiak <chris.lesiak@licor.com>2015-05-26 15:40:44 -0500
committerSasha Levin <sasha.levin@oracle.com>2015-06-09 13:43:55 -0400
commit2439971a06cb72e5c0bc0cdf33701a79fbb2c8d8 (patch)
treea1d38f3687c3452c9a0e8955062c6b962a7aadf7 /drivers/hwmon
parentda9888ac0e1a4c923ad3c4978d310bbf7c32f0d7 (diff)
hwmon: (ntc_thermistor) Ensure iio channel is of type IIO_VOLTAGE
[ Upstream commit adba657533bdd255f7b78bc8a324091f46b294cd ] 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ntc_thermistor.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 4ff89b2482e4..31597c504879 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -239,8 +239,10 @@ static struct ntc_thermistor_platform_data *
ntc_thermistor_parse_dt(struct platform_device *pdev)
{
struct iio_channel *chan;
+ enum iio_chan_type type;
struct device_node *np = pdev->dev.of_node;
struct ntc_thermistor_platform_data *pdata;
+ int ret;
if (!np)
return NULL;
@@ -253,6 +255,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
if (IS_ERR(chan))
return ERR_CAST(chan);
+ ret = iio_get_channel_type(chan, &type);
+ if (ret < 0)
+ return ERR_PTR(ret);
+
+ if (type != IIO_VOLTAGE)
+ return ERR_PTR(-EINVAL);
+
if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv))
return ERR_PTR(-ENODEV);
if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm))