[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240823154245.1553458-1-daniel.lezcano@linaro.org>
Date: Fri, 23 Aug 2024 17:42:43 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: daniel.lezcano@...aro.org,
rafael@...nel.org
Cc: linux-pm@...r.kernel.org,
Jérémie Garcia <jgarcia@...libre.com>,
Alexandre Bailon <abailon@...libre.com>,
Zhang Rui <rui.zhang@...el.com>,
Lukasz Luba <lukasz.luba@....com>,
linux-kernel@...r.kernel.org (open list)
Subject: [RFC PATCH 1/2] thermal/core: Use thermal_zone_device_param
The function thermal_zone_device_register_*() have now a significant
number of parameters.
Simplify the parameters by extending the thermal_zone_device_param
structure with the parameters usually used when registering the
thermal zone.
With that change we have a simpler function:
thermal_zone_device_register()
which can be reused in the different drivers and replace the
duplicate thermal_zone_device_register_with_trips() and
thermal_zone_device_register_tripless() functions.
Cc: Jérémie Garcia <jgarcia@...libre.com>
Cc: Alexandre Bailon <abailon@...libre.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>
---
drivers/thermal/thermal_core.c | 9 +++++++
include/linux/thermal.h | 43 ++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index e6669aeda1ff..5869562caf9e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1390,6 +1390,15 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
}
EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
+struct thermal_zone_device *thermal_zone_device_register(const char *type,
+ const struct thermal_zone_params *tzp)
+{
+ return thermal_zone_device_register_with_trips(type, tzp->trips, tzp->num_trips,
+ tzp->devdata, tzp->ops,
+ tzp, tzp->passive_delay,
+ tzp->polling_delay);
+}
+
/**
* thermal_zone_device_register_with_trips() - register a new thermal zone device
* @type: the thermal zone device type
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index b86ddca46b9e..1681b9ddd890 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -174,11 +174,45 @@ struct thermal_zone_params {
* Used by thermal zone drivers.
*/
int slope;
+
/*
* @offset: offset of a linear temperature adjustment curve.
* Used by thermal zone drivers (default 0).
*/
int offset;
+
+ /*
+ * @trips: a pointer to an array of thermal trips
+ */
+ const struct thermal_trip *trips;
+
+ /*
+ * @num_trips: the number of trip points the thermal zone support
+ */
+ int num_trips;
+
+ /*
+ * @devdata: private device data
+ */
+ void *devdata;
+
+ /*
+ * @ops: standard thermal zone device callbacks
+ */
+ const struct thermal_zone_device_ops *ops;
+
+ /*
+ * @passive_delay: number of milliseconds to wait between polls when
+ * performing passive cooling
+ */
+ unsigned int passive_delay;
+
+ /*
+ * @polling_delay: number of milliseconds to wait between polls when checking
+ * whether trip points have been crossed (0 for interrupt
+ * driven systems)
+ */
+ unsigned int polling_delay;
};
/* Function declarations */
@@ -218,6 +252,10 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
#ifdef CONFIG_THERMAL
+
+struct thermal_zone_device *thermal_zone_device_register(const char *type,
+ const struct thermal_zone_params *tzp);
+
struct thermal_zone_device *thermal_zone_device_register_with_trips(
const char *type,
const struct thermal_trip *trips,
@@ -281,6 +319,11 @@ int thermal_zone_device_enable(struct thermal_zone_device *tz);
int thermal_zone_device_disable(struct thermal_zone_device *tz);
void thermal_zone_device_critical(struct thermal_zone_device *tz);
#else
+static inline struct thermal_zone_device *thermal_zone_device_register(
+ const char *type,
+ const struct thermal_zone_params *tzp)
+{ return ERR_PTR(-ENODEV); }
+
static inline struct thermal_zone_device *thermal_zone_device_register_with_trips(
const char *type,
const struct thermal_trip *trips,
--
2.43.0
Powered by blists - more mailing lists