Commit 3fd6d6e2 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

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: default avatarDaniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220804224349.1926752-2-daniel.lezcano@linexp.orgSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 8c596324
This diff is collapsed.
...@@ -325,6 +325,16 @@ struct thermal_zone_of_device_ops { ...@@ -325,6 +325,16 @@ struct thermal_zone_of_device_ops {
/* Function declarations */ /* Function declarations */
#ifdef CONFIG_THERMAL_OF #ifdef CONFIG_THERMAL_OF
struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
const struct thermal_zone_device_ops *ops);
struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
const struct thermal_zone_device_ops *ops);
void thermal_of_zone_unregister(struct thermal_zone_device *tz);
void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz);
int thermal_zone_of_get_sensor_id(struct device_node *tz_np, int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
struct device_node *sensor_np, struct device_node *sensor_np,
u32 *id); u32 *id);
...@@ -366,6 +376,14 @@ static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register( ...@@ -366,6 +376,14 @@ static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
static inline void thermal_of_zone_unregister(struct thermal_zone_device *tz)
{
}
static inline void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz)
{
}
static inline static inline
void devm_thermal_zone_of_sensor_unregister(struct device *dev, void devm_thermal_zone_of_sensor_unregister(struct device *dev,
struct thermal_zone_device *tz) struct thermal_zone_device *tz)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment