Commit e5181331 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

hwmon/drivers/core: Switch to new of thermal API

The thermal OF code has a new API allowing to migrate the OF
initialization to a simpler approach. The ops are no longer device
tree specific and are the generic ones provided by the core code.

Convert the ops to the thermal_zone_device_ops format and use the new
API to register the thermal zone with these generic ops.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linexp.org>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220804224349.1926752-28-daniel.lezcano@linexp.orgSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 613ed3f6
...@@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida); ...@@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida);
* between hwmon and thermal_sys modules. * between hwmon and thermal_sys modules.
*/ */
#ifdef CONFIG_THERMAL_OF #ifdef CONFIG_THERMAL_OF
static int hwmon_thermal_get_temp(void *data, int *temp) static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
{ {
struct hwmon_thermal_data *tdata = data; struct hwmon_thermal_data *tdata = tz->devdata;
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
int ret; int ret;
long t; long t;
...@@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp) ...@@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp)
return 0; return 0;
} }
static int hwmon_thermal_set_trips(void *data, int low, int high) static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
{ {
struct hwmon_thermal_data *tdata = data; struct hwmon_thermal_data *tdata = tz->devdata;
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
const struct hwmon_chip_info *chip = hwdev->chip; const struct hwmon_chip_info *chip = hwdev->chip;
const struct hwmon_channel_info **info = chip->info; const struct hwmon_channel_info **info = chip->info;
...@@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high) ...@@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high)
return 0; return 0;
} }
static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { static const struct thermal_zone_device_ops hwmon_thermal_ops = {
.get_temp = hwmon_thermal_get_temp, .get_temp = hwmon_thermal_get_temp,
.set_trips = hwmon_thermal_set_trips, .set_trips = hwmon_thermal_set_trips,
}; };
...@@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index) ...@@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index)
tdata->dev = dev; tdata->dev = dev;
tdata->index = index; tdata->index = index;
tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata, tzd = devm_thermal_of_zone_register(dev, index, tdata,
&hwmon_thermal_ops); &hwmon_thermal_ops);
if (IS_ERR(tzd)) { if (IS_ERR(tzd)) {
if (PTR_ERR(tzd) != -ENODEV) if (PTR_ERR(tzd) != -ENODEV)
return PTR_ERR(tzd); return PTR_ERR(tzd);
......
...@@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor) ...@@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
} }
} }
static int scpi_read_temp(void *dev, int *temp) static int scpi_read_temp(struct thermal_zone_device *tz, int *temp)
{ {
struct scpi_thermal_zone *zone = dev; struct scpi_thermal_zone *zone = tz->devdata;
struct scpi_sensors *scpi_sensors = zone->scpi_sensors; struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops; struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id]; struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
...@@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%s\n", sensor->info.name); return sprintf(buf, "%s\n", sensor->info.name);
} }
static const struct thermal_zone_of_device_ops scpi_sensor_ops = { static const struct thermal_zone_device_ops scpi_sensor_ops = {
.get_temp = scpi_read_temp, .get_temp = scpi_read_temp,
}; };
...@@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev) ...@@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
zone->sensor_id = i; zone->sensor_id = i;
zone->scpi_sensors = scpi_sensors; zone->scpi_sensors = scpi_sensors;
z = devm_thermal_zone_of_sensor_register(dev, z = devm_thermal_of_zone_register(dev,
sensor->info.sensor_id, sensor->info.sensor_id,
zone, zone,
&scpi_sensor_ops); &scpi_sensor_ops);
/* /*
* The call to thermal_zone_of_sensor_register returns * The call to thermal_zone_of_sensor_register returns
* an error for sensors that are not associated with * an error for sensors that are not associated with
......
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