Commit 5ed2c040 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Treehugger Robot
Browse files

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
Change-Id: I9f9823eb31dc4dd8a0adae24c645538456faf251
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-and-tested-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Stable-dep-of: 827a0752 ("thermal: core: Free tzp copy along with the thermal zone")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 3eb073ab)
Signed-off-by: default avatarSanjeev Yadav <sanjeev.y@mediatek.com>
parent daaec503
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment