lede/target/linux/mediatek/patches-6.1/830-v6.4-09-thermal-core-Add-a-thermal-zone-devdata-accessor.patch
2024-07-02 15:55:07 +08:00

66 lines
2.2 KiB
Diff

From a6ff3c0021468721b96e84892a8cae24bde8d65f Mon Sep 17 00:00:00 2001
From: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Wed, 1 Mar 2023 21:14:29 +0100
Subject: [PATCH] thermal/core: Add a thermal zone 'devdata' accessor
The thermal zone device structure is exposed to the different drivers
and obviously they access the internals while that should be
restricted to the core thermal code.
In order to self-encapsulate the thermal core code, we need to prevent
the drivers accessing directly the thermal zone structure and provide
accessor functions to deal with.
Provide an accessor to the 'devdata' structure and make use of it in
the different drivers.
No functional changes intended.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/thermal/thermal_core.c | 6 ++++++
include/linux/thermal.h | 7 +++++++
2 files changed, 13 insertions(+)
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1346,6 +1346,12 @@ struct thermal_zone_device *thermal_zone
}
EXPORT_SYMBOL_GPL(thermal_zone_device_register);
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
+{
+ return tzd->devdata;
+}
+EXPORT_SYMBOL_GPL(thermal_zone_device_priv);
+
/**
* thermal_zone_device_unregister - removes the registered thermal zone device
* @tz: the thermal zone device to remove
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -346,6 +346,8 @@ thermal_zone_device_register_with_trips(
void *, struct thermal_zone_device_ops *,
struct thermal_zone_params *, int, int);
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
+
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
struct thermal_cooling_device *,
unsigned long, unsigned long,
@@ -417,6 +419,11 @@ static inline int thermal_zone_get_offse
struct thermal_zone_device *tz)
{ return -ENODEV; }
+static inline void *thermal_zone_device_priv(struct thermal_zone_device *tz)
+{
+ return NULL;
+}
+
static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
{ return -ENODEV; }