diff mbox series

[v1,2/3] thermal: core: Drop redundant checks from thermal_bind_cdev_to_trip()

Message ID 4607540.LvFx2qVVIh@rjwysocki.net
State New
Headers show
Series thermal: core: Cleanups after bind/unbind changes | expand

Commit Message

Rafael J. Wysocki Aug. 22, 2024, 7:26 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.

Link: https://lore.kernel.org/linux-pm/CAJZ5v0jwkc2PB+osSkkYF9vJ1Vpp3MFE=cGQmQ2Xzjb3yjVfJg@mail.gmail.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_core.c |    6 ------
 1 file changed, 6 deletions(-)

Comments

Daniel Lezcano Aug. 23, 2024, 7:16 a.m. UTC | #1
On 22/08/2024 21:26, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> 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.
> 
> Link: https://lore.kernel.org/linux-pm/CAJZ5v0jwkc2PB+osSkkYF9vJ1Vpp3MFE=cGQmQ2Xzjb3yjVfJg@mail.gmail.com/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff mbox series

Patch

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -775,12 +775,6 @@  static int thermal_bind_cdev_to_trip(str
 	bool 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;