c68969321e5a51faace20a819e3a6701820eec65
[openwrt/staging/ldir.git] /
1 From a6ff3c0021468721b96e84892a8cae24bde8d65f Mon Sep 17 00:00:00 2001
2 From: Daniel Lezcano <daniel.lezcano@linaro.org>
3 Date: Wed, 1 Mar 2023 21:14:29 +0100
4 Subject: [PATCH] thermal/core: Add a thermal zone 'devdata' accessor
5
6 The thermal zone device structure is exposed to the different drivers
7 and obviously they access the internals while that should be
8 restricted to the core thermal code.
9
10 In order to self-encapsulate the thermal core code, we need to prevent
11 the drivers accessing directly the thermal zone structure and provide
12 accessor functions to deal with.
13
14 Provide an accessor to the 'devdata' structure and make use of it in
15 the different drivers.
16
17 No functional changes intended.
18
19 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
20 Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
21 Acked-by: Mark Brown <broonie@kernel.org>
22 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
23 ---
24 drivers/thermal/thermal_core.c | 6 ++++++
25 include/linux/thermal.h | 7 +++++++
26 2 files changed, 13 insertions(+)
27
28 --- a/drivers/thermal/thermal_core.c
29 +++ b/drivers/thermal/thermal_core.c
30 @@ -1346,6 +1346,12 @@ struct thermal_zone_device *thermal_zone
31 }
32 EXPORT_SYMBOL_GPL(thermal_zone_device_register);
33
34 +void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
35 +{
36 + return tzd->devdata;
37 +}
38 +EXPORT_SYMBOL_GPL(thermal_zone_device_priv);
39 +
40 /**
41 * thermal_zone_device_unregister - removes the registered thermal zone device
42 * @tz: the thermal zone device to remove
43 --- a/include/linux/thermal.h
44 +++ b/include/linux/thermal.h
45 @@ -346,6 +346,8 @@ thermal_zone_device_register_with_trips(
46 void *, struct thermal_zone_device_ops *,
47 struct thermal_zone_params *, int, int);
48
49 +void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
50 +
51 int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
52 struct thermal_cooling_device *,
53 unsigned long, unsigned long,
54 @@ -417,6 +419,11 @@ static inline int thermal_zone_get_offse
55 struct thermal_zone_device *tz)
56 { return -ENODEV; }
57
58 +static inline void *thermal_zone_device_priv(struct thermal_zone_device *tz)
59 +{
60 + return NULL;
61 +}
62 +
63 static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
64 { return -ENODEV; }
65