thermal: core: Make thermal_zone_device_unregister() return after freeing the zone
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 Dec 2023 19:13:44 +0000 (20:13 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 11 Dec 2023 19:49:53 +0000 (20:49 +0100)
commit4649620d9404d3aceb25891c24bab77143e3f21c
tree4ce2e20623c5a1ea244f02ae92aed31bf4c85444
parent18dfb0e4c3c3cd5654182833bcf3dfdcef754e6e
thermal: core: Make thermal_zone_device_unregister() return after freeing the zone

Make thermal_zone_device_unregister() wait until all of the references
to the given thermal zone object have been dropped and free it before
returning.

This guarantees that when thermal_zone_device_unregister() returns,
there is no leftover activity regarding the thermal zone in question
which is required by some of its callers (for instance, modular driver
code that wants to know when it is safe to let the module go away).

Subsequently, this will allow some confusing device_is_registered()
checks to be dropped from the thermal sysfs and core code.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-and-tested-by: Lukasz Luba <lukasz.luba@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_core.c
include/linux/thermal.h