[5/5] thermal/core: Avoid unbind for thermal zones without .unbind()
Commit Message
The ops->bind()/unbind() callback is the only way to bind/unbind a
cooling device to/from a thermal zone.
Optimize the code to avoid trying unbind when .unbind() callback doesn't
exist.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/thermal/thermal_core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
@@ -1411,6 +1411,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
}
list_del(&tz->node);
+ if (!tz->ops->unbind)
+ goto unbind_done;
+
/* Unbind all cdevs associated with 'this' thermal zone */
list_for_each_entry(cdev, &thermal_cdev_list, node) {
struct thermal_instance *ti;
@@ -1428,8 +1431,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
continue;
unbind:
- if (tz->ops->unbind)
- tz->ops->unbind(tz, cdev);
+ tz->ops->unbind(tz, cdev);
/*
* The thermal instances for current thermal zone has been
@@ -1441,6 +1443,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
mutex_unlock(&cdev->lock);
}
+unbind_done:
mutex_unlock(&thermal_list_lock);
cancel_delayed_work_sync(&tz->poll_queue);