lkml.org 
[lkml]   [2023]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v1 2/4] thermal: core: Introduce thermal_cooling_device_present()
    Date
    From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

    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: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    ---
    drivers/thermal/thermal_core.c | 21 +++++++++++++++------
    1 file changed, 15 insertions(+), 6 deletions(-)

    Index: linux-pm/drivers/thermal/thermal_core.c
    ===================================================================
    --- linux-pm.orig/drivers/thermal/thermal_core.c
    +++ linux-pm/drivers/thermal/thermal_core.c
    @@ -1045,6 +1045,18 @@ 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;
    +
    + 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,
    struct thermal_cooling_device *cdev)
    {
    @@ -1067,20 +1079,17 @@ void thermal_cooling_device_unregister(s
    int i;
    const struct thermal_zone_params *tzp;
    struct thermal_zone_device *tz;
    - struct thermal_cooling_device *pos = NULL;

    if (!cdev)
    return;

    mutex_lock(&thermal_list_lock);
    - list_for_each_entry(pos, &thermal_cdev_list, node)
    - if (pos == cdev)
    - break;
    - if (pos != cdev) {
    - /* thermal cooling device not found */
    +
    + if (!thermal_cooling_device_present(cdev)) {
    mutex_unlock(&thermal_list_lock);
    return;
    }
    +
    list_del(&cdev->node);

    /* Unbind all thermal zones associated with 'this' cdev */


    \
     
     \ /
      Last update: 2023-03-27 00:43    [W:3.000 / U:0.328 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site