UPSTREAM: thermal: core: Rework thermal zone availability check
[ Upstream commit b38aa87f ] In order to avoid running __thermal_zone_device_update() for thermal zones going away, the thermal zone lock is held around device_del() in thermal_zone_device_unregister() and thermal_zone_device_update() passes the given thermal zone device to device_is_registered(). This allows thermal_zone_device_update() to skip the __thermal_zone_device_update() if device_del() has already run for the thermal zone at hand. However, instead of looking at driver core internals, the thermal subsystem may as well rely on its own data structures for this purpose. Namely, if the thermal zone is not present in thermal_tz_list, it can be regarded as unavailable, which in fact is already the case in thermal_zone_device_unregister(). Accordingly, the device_is_registered() check in thermal_zone_device_update() can be replaced with checking whether or not the node list_head in struct thermal_zone_device is empty, in which case it is not there in thermal_tz_list. To make this work, though, it is necessary to initialize tz->node in thermal_zone_device_register_with_trips() before registering the thermal zone device and it needs to be added to thermal_tz_list and deleted from it under its zone lock. After the above modifications, the zone lock does not need to be held around device_del() in thermal_zone_device_unregister() any more. Bug: 382525779 Bug: 384391250 Change-Id: I9f9823eb31dc4dd8a0adae24c645538456faf251 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> Stable-dep-of: 827a0752 ("thermal: core: Free tzp copy along with the thermal zone") Signed-off-by:
Sasha Levin <sashal@kernel.org> (cherry picked from commit 3eb073ab) Signed-off-by:
Sanjeev Yadav <sanjeev.y@mediatek.com> (cherry picked from commit 5ed2c040)
Loading