thermal: Don't use 'device' internal thermal zone structure field
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 1 Mar 2023 20:14:37 +0000 (21:14 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 3 Mar 2023 19:45:02 +0000 (20:45 +0100)
Some drivers are directly using the thermal zone's 'device' structure
field.

Use the driver device pointer instead of the thermal zone device when
it is available.

Remove the traces when they are duplicate with the traces in the core
code.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Balsam CHIHI <bchihi@baylibre.com> #Mediatek LVTS
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek LVTS
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/imx_thermal.c
drivers/thermal/mediatek/lvts_thermal.c
drivers/thermal/thermal_hwmon.c
drivers/thermal/ti-soc-thermal/ti-thermal-common.c

index a0b8de269986a5867a3b5fb73dade22f38968813..c3136978adee19be20e8822654a996d71d81bc97 100644 (file)
@@ -285,13 +285,13 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
                if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature &&
                        *temp < trips[IMX_TRIP_PASSIVE].temperature) {
                        imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature);
-                       dev_dbg(&tz->device, "thermal alarm off: T < %d\n",
+                       dev_dbg(data->dev, "thermal alarm off: T < %d\n",
                                data->alarm_temp / 1000);
                }
        }
 
        if (*temp != data->last_temp) {
-               dev_dbg(&tz->device, "millicelsius: %d\n", *temp);
+               dev_dbg(data->dev, "millicelsius: %d\n", *temp);
                data->last_temp = *temp;
        }
 
@@ -367,36 +367,16 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
 static int imx_bind(struct thermal_zone_device *tz,
                    struct thermal_cooling_device *cdev)
 {
-       int ret;
-
-       ret = thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev,
-                                              THERMAL_NO_LIMIT,
-                                              THERMAL_NO_LIMIT,
-                                              THERMAL_WEIGHT_DEFAULT);
-       if (ret) {
-               dev_err(&tz->device,
-                       "binding zone %s with cdev %s failed:%d\n",
-                       tz->type, cdev->type, ret);
-               return ret;
-       }
-
-       return 0;
+       return thermal_zone_bind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev,
+                                               THERMAL_NO_LIMIT,
+                                               THERMAL_NO_LIMIT,
+                                               THERMAL_WEIGHT_DEFAULT);
 }
 
 static int imx_unbind(struct thermal_zone_device *tz,
                      struct thermal_cooling_device *cdev)
 {
-       int ret;
-
-       ret = thermal_zone_unbind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev);
-       if (ret) {
-               dev_err(&tz->device,
-                       "unbinding zone %s with cdev %s failed:%d\n",
-                       tz->type, cdev->type, ret);
-               return ret;
-       }
-
-       return 0;
+       return thermal_zone_unbind_cooling_device(tz, IMX_TRIP_PASSIVE, cdev);
 }
 
 static struct thermal_zone_device_ops imx_tz_ops = {
@@ -558,8 +538,7 @@ static irqreturn_t imx_thermal_alarm_irq_thread(int irq, void *dev)
 {
        struct imx_thermal_data *data = dev;
 
-       dev_dbg(&data->tz->device, "THERMAL ALARM: T > %d\n",
-               data->alarm_temp / 1000);
+       dev_dbg(data->dev, "THERMAL ALARM: T > %d\n", data->alarm_temp / 1000);
 
        thermal_zone_device_update(data->tz, THERMAL_EVENT_UNSPECIFIED);
 
index fb4b1b4db245f8c422f5a688da780a2c41c7b699..beb835d644e2909e32656eb99e2ad08949cc829f 100644 (file)
@@ -305,7 +305,7 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
         * 14-0 : Raw temperature for threshold
         */
        if (low != -INT_MAX) {
-               dev_dbg(&tz->device, "Setting low limit temperature interrupt: %d\n", low);
+               pr_debug("%s: Setting low limit temperature interrupt: %d\n", tz->type, low);
                writel(raw_low, LVTS_H2NTHRE(base));
        }
 
@@ -318,7 +318,7 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
         *
         * 14-0 : Raw temperature for threshold
         */
-       dev_dbg(&tz->device, "Setting high limit temperature interrupt: %d\n", high);
+       pr_debug("%s: Setting high limit temperature interrupt: %d\n", tz->type, high);
        writel(raw_high, LVTS_HTHRE(base));
 
        return 0;
index 964db7941e31068875a8bae525fabea35d58291b..bc02095b314c95a278e23fa840afeb2b009da97e 100644 (file)
@@ -228,14 +228,14 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
        hwmon = thermal_hwmon_lookup_by_type(tz);
        if (unlikely(!hwmon)) {
                /* Should never happen... */
-               dev_dbg(&tz->device, "hwmon device lookup failed!\n");
+               dev_dbg(hwmon->device, "hwmon device lookup failed!\n");
                return;
        }
 
        temp = thermal_hwmon_lookup_temp(hwmon, tz);
        if (unlikely(!temp)) {
                /* Should never happen... */
-               dev_dbg(&tz->device, "temperature input lookup failed!\n");
+               dev_dbg(hwmon->device, "temperature input lookup failed!\n");
                return;
        }
 
index 216b29068b08ea51b4ccdb00af55b1c0eb3d5e92..060f46cea5ffe3771063e4e3c46e6b72d8c419d8 100644 (file)
@@ -43,7 +43,7 @@ static void ti_thermal_work(struct work_struct *work)
 
        thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
 
-       dev_dbg(&data->ti_thermal->device, "updated thermal zone %s\n",
+       dev_dbg(data->bgp->dev, "updated thermal zone %s\n",
                data->ti_thermal->type);
 }