thermal: helpers: Rearrange thermal_cdev_set_cur_state()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 9 Jan 2024 16:42:48 +0000 (17:42 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 12 Jan 2024 14:38:23 +0000 (15:38 +0100)
Change the code layout in thermal_cdev_set_cur_state() so it returns
early on errors which is more consistent with what happens elsewhere.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_helpers.c

index dd72eec..0329f4a 100644 (file)
@@ -155,13 +155,14 @@ static int thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int s
         * registering function checked the ops are correctly set
         */
        ret = cdev->ops->set_cur_state(cdev, state);
-       if (!ret) {
-               thermal_notify_cdev_state_update(cdev, state);
-               thermal_cooling_device_stats_update(cdev, state);
-               thermal_debug_cdev_state_update(cdev, state);
-       }
+       if (ret)
+               return ret;
 
-       return ret;
+       thermal_notify_cdev_state_update(cdev, state);
+       thermal_cooling_device_stats_update(cdev, state);
+       thermal_debug_cdev_state_update(cdev, state);
+
+       return 0;
 }
 
 void __thermal_cdev_update(struct thermal_cooling_device *cdev)