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

commit adba657533bdd255f7b78bc8a324091f46b294cd 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: Chris Lesiak <chris.lesiak@licor.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Chris Lesiak 2015-05-26 15:40:44 -05:00 committed by Greg Kroah-Hartman
parent d2e3dbf9c3
commit e9aba80e28
1 changed files with 9 additions and 0 deletions

View File

@ -181,8 +181,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;
@ -195,6 +197,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))