diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-10-14 16:59:46 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-10-24 14:48:23 +0200 |
commit | a5a98a786e5e31e85a69d30935254e8730734706 (patch) | |
tree | 6654682d011b2466324507b7b3fa1ae824ab44d2 /drivers/thermal/gov_power_allocator.c | |
parent | c597b4e74b124aebf7e3d3f7907e2d4779d870e3 (diff) | |
download | lwn-a5a98a786e5e31e85a69d30935254e8730734706.tar.gz lwn-a5a98a786e5e31e85a69d30935254e8730734706.zip |
thermal: core: Add and use cooling device guard
Add and use a special guard for cooling devices.
This allows quite a few error code paths to be simplified among
other things and brings in code size reduction for a good measure.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5837621.DvuYhMxLoT@rjwysocki.net
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Diffstat (limited to 'drivers/thermal/gov_power_allocator.c')
-rw-r--r-- | drivers/thermal/gov_power_allocator.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index bdae60001b2c..5cb03923fa8f 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -549,18 +549,17 @@ static void allow_maximum_power(struct thermal_zone_device *tz) cdev = instance->cdev; instance->target = 0; - mutex_lock(&cdev->lock); - /* - * Call for updating the cooling devices local stats and avoid - * periods of dozen of seconds when those have not been - * maintained. - */ - cdev->ops->get_requested_power(cdev, &req_power); - - if (params->update_cdevs) - __thermal_cdev_update(cdev); - - mutex_unlock(&cdev->lock); + scoped_guard(cooling_dev, cdev) { + /* + * Call for updating the cooling devices local stats and + * avoid periods of dozen of seconds when those have not + * been maintained. + */ + cdev->ops->get_requested_power(cdev, &req_power); + + if (params->update_cdevs) + __thermal_cdev_update(cdev); + } } } |