[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220507125443.2766939-14-daniel.lezcano@linexp.org>
Date: Sat, 7 May 2022 14:54:41 +0200
From: Daniel Lezcano <daniel.lezcano@...exp.org>
To: daniel.lezcano@...aro.org, rafael@...nel.org
Cc: khilman@...libre.com, abailon@...libre.com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>
Subject: [PATCH v2 13/14] thermal/of: Use thermal trips stored in the thermal zone
Now that we have the thermal trip stored in the thermal zone in a
generic way, we can rely on them and remove one indirection we found
in the thermal_of code and do one more step forward the removal of the
duplicated structures.
Cc: Alexandre Bailon <abailon@...libre.com>
Cc: Kevin Hilman <khilman@...libre.com>
Cc; Eduardo Valentin <eduval@...zon.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@...exp.org>
---
drivers/thermal/thermal_of.c | 53 +++++++++++-------------------------
1 file changed, 16 insertions(+), 37 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 200d1d784211..64e5b9e92cb1 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -118,12 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_device *tz,
*/
int of_thermal_get_ntrips(struct thermal_zone_device *tz)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (!data || IS_ERR(data))
- return -ENODEV;
-
- return data->ntrips;
+ return tz->ntrips;
}
EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
@@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
*/
bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (!data || trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return false;
return true;
@@ -161,12 +154,7 @@ EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);
const struct thermal_trip *
of_thermal_get_trip_points(struct thermal_zone_device *tz)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (!data)
- return NULL;
-
- return data->trips;
+ return tz->trips;
}
EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
@@ -273,12 +261,10 @@ static int of_thermal_unbind(struct thermal_zone_device *thermal,
static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
enum thermal_trip_type *type)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return -EDOM;
- *type = data->trips[trip].type;
+ *type = tz->trips[trip].type;
return 0;
}
@@ -286,12 +272,10 @@ static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
int *temp)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return -EDOM;
- *temp = data->trips[trip].temperature;
+ *temp = tz->trips[trip].temperature;
return 0;
}
@@ -301,7 +285,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
{
struct __thermal_zone *data = tz->devdata;
- if (trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return -EDOM;
if (data->ops && data->ops->set_trip_temp) {
@@ -313,7 +297,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
}
/* thermal framework should take care of data->mask & (1 << trip) */
- data->trips[trip].temperature = temp;
+ tz->trips[trip].temperature = temp;
return 0;
}
@@ -321,12 +305,10 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
int *hyst)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return -EDOM;
- *hyst = data->trips[trip].hysteresis;
+ *hyst = tz->trips[trip].hysteresis;
return 0;
}
@@ -334,13 +316,11 @@ static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
int hyst)
{
- struct __thermal_zone *data = tz->devdata;
-
- if (trip >= data->ntrips || trip < 0)
+ if (trip >= tz->ntrips || trip < 0)
return -EDOM;
/* thermal framework should take care of data->mask & (1 << trip) */
- data->trips[trip].hysteresis = hyst;
+ tz->trips[trip].hysteresis = hyst;
return 0;
}
@@ -348,12 +328,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
int *temp)
{
- struct __thermal_zone *data = tz->devdata;
int i;
- for (i = 0; i < data->ntrips; i++)
- if (data->trips[i].type == THERMAL_TRIP_CRITICAL) {
- *temp = data->trips[i].temperature;
+ for (i = 0; i < tz->ntrips; i++)
+ if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) {
+ *temp = tz->trips[i].temperature;
return 0;
}
--
2.25.1
Powered by blists - more mailing lists