Commit c43198af authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

thermal: core: Introduce thermal_cooling_device_present()

Introduce a helper function, thermal_cooling_device_present(), for
checking if the given cooling device is in the list of registered
cooling devices to avoid some code duplication in a subsequent
patch.

No expected functional impact.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: default avatarZhang Rui <rui.zhang@intel.com>
Reviewed-by: default avatarZhang Rui <rui.zhang@intel.com>
parent c0e0421a
...@@ -1045,6 +1045,18 @@ devm_thermal_of_cooling_device_register(struct device *dev, ...@@ -1045,6 +1045,18 @@ devm_thermal_of_cooling_device_register(struct device *dev,
} }
EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register); EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
static bool thermal_cooling_device_present(struct thermal_cooling_device *cdev)
{
struct thermal_cooling_device *pos = NULL;
list_for_each_entry(pos, &thermal_cdev_list, node) {
if (pos == cdev)
return true;
}
return false;
}
static void __unbind(struct thermal_zone_device *tz, int mask, static void __unbind(struct thermal_zone_device *tz, int mask,
struct thermal_cooling_device *cdev) struct thermal_cooling_device *cdev)
{ {
...@@ -1067,20 +1079,17 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ...@@ -1067,20 +1079,17 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
int i; int i;
const struct thermal_zone_params *tzp; const struct thermal_zone_params *tzp;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct thermal_cooling_device *pos = NULL;
if (!cdev) if (!cdev)
return; return;
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
list_for_each_entry(pos, &thermal_cdev_list, node)
if (pos == cdev) if (!thermal_cooling_device_present(cdev)) {
break;
if (pos != cdev) {
/* thermal cooling device not found */
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
return; return;
} }
list_del(&cdev->node); list_del(&cdev->node);
/* Unbind all thermal zones associated with 'this' cdev */ /* Unbind all thermal zones associated with 'this' cdev */
......
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