Skip to contentSkip to conversation

hwmon: ntc: Ensure iio channel is of type IIO_VOLTGE

PATCH Applied Chris Lesiak 2 participants 2 messages May 26, 2015 – May 27, 2015 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: ntc: Ensure iio channel is of type IIO_VOLTGE

When configured via device tree, the associated iio device needs to be measuring voltage for the converstion to resistance to be correct. Return -EINVAL if that is not the case.

---
 drivers/hwmon/ntc_thermistor.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/hwmon/ntc_thermistor.c +9 -0
index 112e4d4..6880011 100644
@@ -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))
Signature · 7 lines
1.9.3


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
maintainer Applied
#1 lore raw
Quoted 5 lines · Chris Lesiak

When configured via device tree, the associated iio device needs to be measuring voltage for the converstion to resistance to be correct. Return -EINVAL if that is not the case.

Applied, after fixing the spelling errors in subject and description.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors