thermal: core: Cleanups after bind/unbind changes
cover thermal: core: Cleanups after bind/unbind changes
Hi Everyone,
These are cleanups that can be done on top of
https://lore.kernel.org/linux-pm/[email protected]/
as suggested during patch review.
Please refer to the individual patch changelogs for more information.
Thanks!
PATCH 1/3 thermal: core: Rename cdev-to-thermal-zone bind/unbind functions
From: Rafael J. Wysocki <[email protected]>
Rename thermal_zone_cdev_binding() and thermal_zone_cdev_unbinding() to thermal_zone_cdev_bind() and thermal_zone_cdev_unbind(), respectively, to make the naming more consistent with the rest of the code.
No functional impact.
--- drivers/thermal/thermal_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +8 -8
@@ -937,8 +937,8 @@ void print_bind_err_msg(struct thermal_z cdev->type, thermal_zone_trip_id(tz, trip), ret); } -static void thermal_zone_cdev_binding (struct thermal_zone_device *tz, -struct thermal_cooling_device *cdev) +static void thermal_zone_cdev_bind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) {struct thermal_trip_desc *td;
@@ -1063,7 +1063,7 @@ __thermal_cooling_device_register(struct/* Update binding information for 'this' new cdev */ list_for_each_entry (pos, &thermal_tz_list, node) -thermal_zone_cdev_binding (pos, cdev); +thermal_zone_cdev_bind (pos, cdev);list_for_each_entry (pos, &thermal_tz_list, node)if (atomic_cmpxchg (&pos->need_update,1 ,0 ))
@@ -1264,8 +1264,8 @@ unlock_list: }EXPORT_SYMBOL_GPL (thermal_cooling_device_update); -static void thermal_zone_cdev_unbinding (struct thermal_zone_device *tz, -struct thermal_cooling_device *cdev) +static void thermal_zone_cdev_unbind (struct thermal_zone_device *tz, +struct thermal_cooling_device *cdev) {struct thermal_trip_desc *td;
@@ -1304,7 +1304,7 @@ void thermal_cooling_device_unregister(s/* Unbind all thermal zones associated with 'this' cdev */ list_for_each_entry (tz, &thermal_tz_list, node) -thermal_zone_cdev_unbinding (tz, cdev); +thermal_zone_cdev_unbind (tz, cdev);mutex_unlock (&thermal_list_lock);
@@ -1517,7 +1517,7 @@ thermal_zone_device_register_with_trips(/* Bind cooling devices for this zone */ list_for_each_entry (cdev, &thermal_cdev_list, node) -thermal_zone_cdev_binding (tz, cdev); +thermal_zone_cdev_bind (tz, cdev);mutex_unlock (&thermal_list_lock);
@@ -1611,7 +1611,7 @@ void thermal_zone_device_unregister(stru/* Unbind all cdevs associated with 'this' thermal zone */ list_for_each_entry (cdev, &thermal_cdev_list, node) -thermal_zone_cdev_unbinding (tz, cdev); +thermal_zone_cdev_unbind (tz, cdev);mutex_unlock (&thermal_list_lock);
Re: [PATCH v1 1/3] thermal: core: Rename cdev-to-thermal-zone bind/unbind functions
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Rename
thermal_zone_cdev_binding()andthermal_zone_cdev_unbinding()tothermal_zone_cdev_bind()andthermal_zone_cdev_unbind(), respectively, to make the naming more consistent with the rest of the code.No functional impact.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 2/3 thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Since thermal_bind_cdev_to_trip() is only called by thermal_zone_cdev_binding() under the thermal zone lock and the latter is only called by thermal_zone_device_register_with_trips() and __thermal_cooling_device_register(), under thermal_list_lock in both cases, both lockdep_assert_held() assertions can be dropped from it.
Moreover, in both cases thermal_zone_cdev_binding() is called after both tz and cdev have been added to the global lists of thermal zones and cooling device, respectively, so the check against their list nodes in thermal_bind_cdev_to_trip() is redundant and can be dropped either.
--- drivers/thermal/thermal_core.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/thermal/thermal_core.c +0 -6
@@ -775,12 +775,6 @@ static int thermal_bind_cdev_to_trip(strbool upper_no_limit;int result; -lockdep_assert_held (&thermal_list_lock); -lockdep_assert_held (&tz->lock); - -if (list_empty (&tz->node) ||list_empty (&cdev->node)) -return -EINVAL ; -/* lower default 0, upper default max_state */ if (cool_spec->lower ==THERMAL_NO_LIMIT ) cool_spec->lower =0 ;
Re: [PATCH v1 2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip()
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Since
thermal_bind_cdev_to_trip()is only called bythermal_zone_cdev_binding()under the thermal zone lock and the latter is only called bythermal_zone_device_register_with_trips()and__thermal_cooling_device_register(), underthermal_list_lockin both cases, bothlockdep_assert_held()assertions can be dropped from it.
Quoted 8 lines
Moreover, in both cases
thermal_zone_cdev_binding()is called after both tz and cdev have been added to the global lists of thermal zones and cooling device, respectively, so the check against their list nodes inthermal_bind_cdev_to_trip()is redundant and can be dropped either.Link https://lore.kernel.org/linux-pm/CAJZ5v0jwkc2PB+osSkkYF9vJ1Vpp3MFE=cGQmQ2Xzjb3yjVfJg@mail.gmail.com/ open hereSigned-off-by Rafael J. Wysocki <[email protected]>---
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 3/3 thermal: core: Drop tz field from struct thermal_instance
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
After recent changes, it is only used for printing a debug message in __thermal_cdev_update() which arguably is not worth preserving.
Drop it along with the dev_dbg() statement using it.
--- drivers/thermal/thermal_core.c | 2 +- drivers/thermal/thermal_core.h | 1 - drivers/thermal/thermal_helpers.c | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-)
drivers/thermal/thermal_core.h +0 -1
@@ -213,7 +213,6 @@ int get_tz_trend(struct thermal_zone_devstruct thermal_instance {int id;char name[THERMAL_NAME_LENGTH ]; -struct thermal_zone_device *tz;struct thermal_cooling_device *cdev;const struct thermal_trip *trip;bool initialized;
drivers/thermal/thermal_helpers.c +0 -2
@@ -181,8 +181,6 @@ void __thermal_cdev_update(struct therma/* Make sure cdev enters the deepest cooling state */ list_for_each_entry (instance, &cdev->thermal_instances, cdev_node) { -dev_dbg (&cdev->device,"zone%d->target=%lu\n" , - instance->tz->id, instance->target);if (instance->target ==THERMAL_NO_TARGET )continue ;if (instance->target > target)
drivers/thermal/thermal_core.c +1 -1
@@ -792,7 +792,7 @@ static int thermal_bind_cdev_to_trip(str dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return -ENOMEM ; - dev->tz = tz; + dev->cdev = cdev; dev->trip = trip; dev->upper = cool_spec->upper;
Re: [PATCH v1 3/3] thermal: core: Drop tz field from struct thermal_instance
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
After recent changes, it is only used for printing a debug message in
__thermal_cdev_update()which arguably is not worth preserving.Drop it along with the
dev_dbg()statement using it.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog