Commit 6ca3b824 authored by Chris Lesiak's avatar Chris Lesiak Committed by Jiri Slaby

hwmon: (ntc_thermistor) Ensure iio channel is of type IIO_VOLTAGE

commit adba6575 upstream.

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: default avatarChris Lesiak <chris.lesiak@licor.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent db020773
...@@ -181,8 +181,10 @@ static struct ntc_thermistor_platform_data * ...@@ -181,8 +181,10 @@ static struct ntc_thermistor_platform_data *
ntc_thermistor_parse_dt(struct platform_device *pdev) ntc_thermistor_parse_dt(struct platform_device *pdev)
{ {
struct iio_channel *chan; struct iio_channel *chan;
enum iio_chan_type type;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct ntc_thermistor_platform_data *pdata; struct ntc_thermistor_platform_data *pdata;
int ret;
if (!np) if (!np)
return NULL; return NULL;
...@@ -195,6 +197,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) ...@@ -195,6 +197,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
if (IS_ERR(chan)) if (IS_ERR(chan))
return ERR_CAST(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)) if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm)) if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment