summaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_sysfs.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-22 20:18:01 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-23 20:24:48 +0300
commit698a1eb1f75eb6ac957d2af7721a3b1a94281e5d (patch)
tree7a3445f5315e2ddcae42dc3f0a74253eaac13cc2 /drivers/thermal/thermal_sysfs.c
parentfcbf8780008609380d2e5b407c5bb7950fff018c (diff)
downloadlinux-698a1eb1f75eb6ac957d2af7721a3b1a94281e5d.tar.xz
thermal: core: Store zone ops in struct thermal_zone_device
The current code requires thermal zone creators to pass pointers to writable ops structures to thermal_zone_device_register_with_trips() which needs to modify the target struct thermal_zone_device_ops object if the "critical" operation in it is NULL. Moreover, the callers of thermal_zone_device_register_with_trips() are required to hold on to the struct thermal_zone_device_ops object passed to it until the given thermal zone is unregistered. Both of these requirements are quite inconvenient, so modify struct thermal_zone_device to contain struct thermal_zone_device_ops as field and make thermal_zone_device_register_with_trips() copy the contents of the struct thermal_zone_device_ops passed to it via a pointer (which can be const now) to that field. Also adjust the code using thermal zone ops accordingly and modify thermal_of_zone_register() to use a local ops variable during thermal zone registration so ops do not need to be freed in thermal_of_zone_unregister() any more. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/thermal/thermal_sysfs.c')
-rw-r--r--drivers/thermal/thermal_sysfs.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index d55f9303afb5..2eace6b33b8c 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -123,8 +123,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
trip = &tz->trips[trip_id];
if (temp != trip->temperature) {
- if (tz->ops->set_trip_temp) {
- ret = tz->ops->set_trip_temp(tz, trip_id, temp);
+ if (tz->ops.set_trip_temp) {
+ ret = tz->ops.set_trip_temp(tz, trip_id, temp);
if (ret)
goto unlock;
}
@@ -174,8 +174,8 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
trip = &tz->trips[trip_id];
if (hyst != trip->hysteresis) {
- if (tz->ops->set_trip_hyst) {
- ret = tz->ops->set_trip_hyst(tz, trip_id, hyst);
+ if (tz->ops.set_trip_hyst) {
+ ret = tz->ops.set_trip_hyst(tz, trip_id, hyst);
if (ret)
goto unlock;
}
@@ -250,10 +250,10 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
mutex_lock(&tz->lock);
- if (!tz->ops->set_emul_temp)
+ if (!tz->ops.set_emul_temp)
tz->emul_temperature = temperature;
else
- ret = tz->ops->set_emul_temp(tz, temperature);
+ ret = tz->ops.set_emul_temp(tz, temperature);
if (!ret)
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
@@ -474,7 +474,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
tz->trip_hyst_attrs[indx].name;
tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO;
tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show;
- if (tz->ops->set_trip_hyst) {
+ if (tz->ops.set_trip_hyst) {
tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR;
tz->trip_hyst_attrs[indx].attr.store =
trip_point_hyst_store;