mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
8c59632423
commit
3fd6d6e2b4
2 changed files with 468 additions and 10 deletions
|
@ -325,6 +325,16 @@ struct thermal_zone_of_device_ops {
|
|||
|
||||
/* Function declarations */
|
||||
#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,
|
||||
struct device_node *sensor_np,
|
||||
u32 *id);
|
||||
|
@ -366,6 +376,14 @@ static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
|
|||
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
|
||||
void devm_thermal_zone_of_sensor_unregister(struct device *dev,
|
||||
struct thermal_zone_device *tz)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue