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: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20211125020841.3616359-4-linus.walleij@linaro.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
76f240ff95
commit
209218efd6
|
@ -1414,8 +1414,9 @@ config SENSORS_PC87427
|
|||
will be called pc87427.
|
||||
|
||||
config SENSORS_NTC_THERMISTOR
|
||||
tristate "NTC thermistor support from Murata"
|
||||
depends on !OF || IIO=n || IIO
|
||||
tristate "NTC thermistor support"
|
||||
depends on OF
|
||||
depends on IIO
|
||||
depends on THERMAL || !THERMAL_OF
|
||||
help
|
||||
This driver supports NTC thermistors sensor reading and its
|
||||
|
|
|
@ -28,8 +28,7 @@ enum ntc_thermistor_type {
|
|||
|
||||
struct ntc_thermistor_platform_data {
|
||||
/*
|
||||
* pullup_uV, pullup_ohm, pulldown_ohm, and connect are required to use
|
||||
* read_uV()
|
||||
* pullup_uV, pullup_ohm, pulldown_ohm, and connect are required.
|
||||
*
|
||||
* How to setup pullup_ohm, pulldown_ohm, and connect is
|
||||
* described at Documentation/hwmon/ntc_thermistor.rst
|
||||
|
@ -39,9 +38,7 @@ struct ntc_thermistor_platform_data {
|
|||
* chan: iio_channel pointer to communicate with the ADC which the
|
||||
* thermistor is using for conversion of the analog values.
|
||||
*/
|
||||
int (*read_uv)(struct ntc_thermistor_platform_data *);
|
||||
unsigned int pullup_uv;
|
||||
|
||||
unsigned int pullup_ohm;
|
||||
unsigned int pulldown_ohm;
|
||||
enum { NTC_CONNECTED_POSITIVE, NTC_CONNECTED_GROUND } connect;
|
||||
|
@ -346,7 +343,6 @@ struct ntc_data {
|
|||
int n_comp;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO)
|
||||
static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
|
||||
{
|
||||
struct iio_channel *channel = pdata->chan;
|
||||
|
@ -451,20 +447,9 @@ ntc_thermistor_parse_dt(struct device *dev)
|
|||
pdata->connect = NTC_CONNECTED_GROUND;
|
||||
|
||||
pdata->chan = chan;
|
||||
pdata->read_uv = ntc_adc_iio_read;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -594,13 +579,10 @@ static int ntc_thermistor_get_ohm(struct ntc_data *data)
|
|||
{
|
||||
int read_uv;
|
||||
|
||||
if (data->pdata->read_uv) {
|
||||
read_uv = data->pdata->read_uv(data->pdata);
|
||||
read_uv = ntc_adc_iio_read(data->pdata);
|
||||
if (read_uv < 0)
|
||||
return read_uv;
|
||||
return get_ohm_of_thermistor(data, read_uv);
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (!pdata->read_uv) {
|
||||
dev_err(dev, "read_uv missing\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (pdata->read_uv && (pdata->pullup_uv == 0 ||
|
||||
if (pdata->pullup_uv == 0 ||
|
||||
(pdata->pullup_ohm == 0 && pdata->connect ==
|
||||
NTC_CONNECTED_GROUND) ||
|
||||
(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");
|
||||
pdata->connect != NTC_CONNECTED_GROUND)) {
|
||||
dev_err(dev, "Required data to use NTC driver not supplied.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue