Commit 209218ef authored by Linus Walleij's avatar Linus Walleij Committed by Guenter Roeck

hwmon: (ntc_thermistor) Drop read_uv() depend on OF and IIO

The only possible assignment of a function to get a voltage to
convert to a resistance is to use the internal function
ntc_adc_iio_read() which is only available when using IIO
and OF.

Bite the bullet and mandate OF and IIO, drop the read_uv()
callback abstraction and some ifdefs.

As no board is using the platform data, all users are using
OF and IIO anyway.

Cc: Peter Rosin <peda@axentia.se>
Cc: Chris Lesiak <chris.lesiak@licor.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20211125020841.3616359-4-linus.walleij@linaro.orgSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 76f240ff
...@@ -1414,8 +1414,9 @@ config SENSORS_PC87427 ...@@ -1414,8 +1414,9 @@ config SENSORS_PC87427
will be called pc87427. will be called pc87427.
config SENSORS_NTC_THERMISTOR config SENSORS_NTC_THERMISTOR
tristate "NTC thermistor support from Murata" tristate "NTC thermistor support"
depends on !OF || IIO=n || IIO depends on OF
depends on IIO
depends on THERMAL || !THERMAL_OF depends on THERMAL || !THERMAL_OF
help help
This driver supports NTC thermistors sensor reading and its This driver supports NTC thermistors sensor reading and its
......
...@@ -28,8 +28,7 @@ enum ntc_thermistor_type { ...@@ -28,8 +28,7 @@ enum ntc_thermistor_type {
struct ntc_thermistor_platform_data { struct ntc_thermistor_platform_data {
/* /*
* pullup_uV, pullup_ohm, pulldown_ohm, and connect are required to use * pullup_uV, pullup_ohm, pulldown_ohm, and connect are required.
* read_uV()
* *
* How to setup pullup_ohm, pulldown_ohm, and connect is * How to setup pullup_ohm, pulldown_ohm, and connect is
* described at Documentation/hwmon/ntc_thermistor.rst * described at Documentation/hwmon/ntc_thermistor.rst
...@@ -39,9 +38,7 @@ struct ntc_thermistor_platform_data { ...@@ -39,9 +38,7 @@ struct ntc_thermistor_platform_data {
* chan: iio_channel pointer to communicate with the ADC which the * chan: iio_channel pointer to communicate with the ADC which the
* thermistor is using for conversion of the analog values. * thermistor is using for conversion of the analog values.
*/ */
int (*read_uv)(struct ntc_thermistor_platform_data *);
unsigned int pullup_uv; unsigned int pullup_uv;
unsigned int pullup_ohm; unsigned int pullup_ohm;
unsigned int pulldown_ohm; unsigned int pulldown_ohm;
enum { NTC_CONNECTED_POSITIVE, NTC_CONNECTED_GROUND } connect; enum { NTC_CONNECTED_POSITIVE, NTC_CONNECTED_GROUND } connect;
...@@ -346,7 +343,6 @@ struct ntc_data { ...@@ -346,7 +343,6 @@ struct ntc_data {
int n_comp; int n_comp;
}; };
#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO)
static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata) static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
{ {
struct iio_channel *channel = pdata->chan; struct iio_channel *channel = pdata->chan;
...@@ -451,20 +447,9 @@ ntc_thermistor_parse_dt(struct device *dev) ...@@ -451,20 +447,9 @@ ntc_thermistor_parse_dt(struct device *dev)
pdata->connect = NTC_CONNECTED_GROUND; pdata->connect = NTC_CONNECTED_GROUND;
pdata->chan = chan; pdata->chan = chan;
pdata->read_uv = ntc_adc_iio_read;
return pdata; return pdata;
} }
#else
static struct ntc_thermistor_platform_data *
ntc_thermistor_parse_dt(struct device *dev)
{
return NULL;
}
#define ntc_match NULL
#endif
static inline u64 div64_u64_safe(u64 dividend, u64 divisor) static inline u64 div64_u64_safe(u64 dividend, u64 divisor)
{ {
...@@ -594,13 +579,10 @@ static int ntc_thermistor_get_ohm(struct ntc_data *data) ...@@ -594,13 +579,10 @@ static int ntc_thermistor_get_ohm(struct ntc_data *data)
{ {
int read_uv; int read_uv;
if (data->pdata->read_uv) { read_uv = ntc_adc_iio_read(data->pdata);
read_uv = data->pdata->read_uv(data->pdata); if (read_uv < 0)
if (read_uv < 0) return read_uv;
return read_uv; return get_ohm_of_thermistor(data, read_uv);
return get_ohm_of_thermistor(data, read_uv);
}
return -EINVAL;
} }
static int ntc_read(struct device *dev, enum hwmon_sensor_types type, static int ntc_read(struct device *dev, enum hwmon_sensor_types type,
...@@ -681,19 +663,14 @@ static int ntc_thermistor_probe(struct platform_device *pdev) ...@@ -681,19 +663,14 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
if (!pdata->read_uv) { if (pdata->pullup_uv == 0 ||
dev_err(dev, "read_uv missing\n"); (pdata->pullup_ohm == 0 && pdata->connect ==
return -EINVAL; NTC_CONNECTED_GROUND) ||
} (pdata->pulldown_ohm == 0 && pdata->connect ==
NTC_CONNECTED_POSITIVE) ||
if (pdata->read_uv && (pdata->pullup_uv == 0 || (pdata->connect != NTC_CONNECTED_POSITIVE &&
(pdata->pullup_ohm == 0 && pdata->connect == pdata->connect != NTC_CONNECTED_GROUND)) {
NTC_CONNECTED_GROUND) || dev_err(dev, "Required data to use NTC driver not supplied.\n");
(pdata->pulldown_ohm == 0 && pdata->connect ==
NTC_CONNECTED_POSITIVE) ||
(pdata->connect != NTC_CONNECTED_POSITIVE &&
pdata->connect != NTC_CONNECTED_GROUND))) {
dev_err(dev, "Required data to use read_uv not supplied.\n");
return -EINVAL; return -EINVAL;
} }
......
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