OSDN Git Service

thermal/of: Rework the thermal device tree initialization
authorDaniel Lezcano <daniel.lezcano@linexp.org>
Thu, 4 Aug 2022 22:43:17 +0000 (00:43 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 17 Aug 2022 12:09:37 +0000 (14:09 +0200)
commit3fd6d6e2b4e80fe45bfd1c8f01dff7d30a0f9b53
tree070eaf2d8a8a38174f0d32d739471ac9e64b74f1
parent8c596324232d22e19f8df59ba03410b9b5b0f3d7
thermal/of: Rework the thermal device tree initialization

The following changes are reworking entirely the thermal device tree
initialization. The old version is kept until the different drivers
using it are converted to the new API.

The old approach creates the different actors independently. This
approach is the source of the code duplication in the thermal OF
because a thermal zone is created but a sensor is registered
after. The thermal zones are created unconditionnaly with a fake
sensor at init time, thus forcing to provide fake ops and store all
the thermal zone related information in duplicated structures. Then
the sensor is initialized and the code looks up the thermal zone name
using the device tree. Then the sensor is associated to the thermal
zone, and the sensor specific ops are called with a second level of
indirection from the thermal zone ops.

When a sensor is removed (with a module unload), the thermal zone
stays there with the fake sensor.

The cooling device associated with a thermal zone and a trip point is
stored in a list, again duplicating information, using the node name
of the device tree to match afterwards the cooling devices.

The new approach is simpler, it creates a thermal zone when the sensor
is registered and destroys it when the sensor is removed. All the
matching between the cooling device, trip points and thermal zones are
done using the device tree, as well as bindings. The ops are no longer
specific but uses the generic ones provided by the thermal framework.

When the old code won't have any users, it can be removed and the
remaining thermal OF code will be much simpler.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-2-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_of.c
include/linux/thermal.h