Skip to content

Commit 14ccb5e

Browse files
Daniel Lezcanodlezcano
authored andcommitted
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 <[email protected]> Cc: Kevin Hilman <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent fae11de commit 14ccb5e

File tree

1 file changed

+16
-37
lines changed

1 file changed

+16
-37
lines changed

drivers/thermal/thermal_of.c

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_device *tz,
118118
*/
119119
int of_thermal_get_ntrips(struct thermal_zone_device *tz)
120120
{
121-
struct __thermal_zone *data = tz->devdata;
122-
123-
if (!data || IS_ERR(data))
124-
return -ENODEV;
125-
126-
return data->ntrips;
121+
return tz->num_trips;
127122
}
128123
EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
129124

@@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips);
139134
*/
140135
bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip)
141136
{
142-
struct __thermal_zone *data = tz->devdata;
143-
144-
if (!data || trip >= data->ntrips || trip < 0)
137+
if (trip >= tz->num_trips || trip < 0)
145138
return false;
146139

147140
return true;
@@ -161,12 +154,7 @@ EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid);
161154
const struct thermal_trip *
162155
of_thermal_get_trip_points(struct thermal_zone_device *tz)
163156
{
164-
struct __thermal_zone *data = tz->devdata;
165-
166-
if (!data)
167-
return NULL;
168-
169-
return data->trips;
157+
return tz->trips;
170158
}
171159
EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
172160

@@ -281,25 +269,21 @@ static int of_thermal_unbind(struct thermal_zone_device *thermal,
281269
static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
282270
enum thermal_trip_type *type)
283271
{
284-
struct __thermal_zone *data = tz->devdata;
285-
286-
if (trip >= data->ntrips || trip < 0)
272+
if (trip >= tz->num_trips || trip < 0)
287273
return -EDOM;
288274

289-
*type = data->trips[trip].type;
275+
*type = tz->trips[trip].type;
290276

291277
return 0;
292278
}
293279

294280
static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
295281
int *temp)
296282
{
297-
struct __thermal_zone *data = tz->devdata;
298-
299-
if (trip >= data->ntrips || trip < 0)
283+
if (trip >= tz->num_trips || trip < 0)
300284
return -EDOM;
301285

302-
*temp = data->trips[trip].temperature;
286+
*temp = tz->trips[trip].temperature;
303287

304288
return 0;
305289
}
@@ -309,7 +293,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
309293
{
310294
struct __thermal_zone *data = tz->devdata;
311295

312-
if (trip >= data->ntrips || trip < 0)
296+
if (trip >= tz->num_trips || trip < 0)
313297
return -EDOM;
314298

315299
if (data->ops && data->ops->set_trip_temp) {
@@ -321,47 +305,42 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
321305
}
322306

323307
/* thermal framework should take care of data->mask & (1 << trip) */
324-
data->trips[trip].temperature = temp;
308+
tz->trips[trip].temperature = temp;
325309

326310
return 0;
327311
}
328312

329313
static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
330314
int *hyst)
331315
{
332-
struct __thermal_zone *data = tz->devdata;
333-
334-
if (trip >= data->ntrips || trip < 0)
316+
if (trip >= tz->num_trips || trip < 0)
335317
return -EDOM;
336318

337-
*hyst = data->trips[trip].hysteresis;
319+
*hyst = tz->trips[trip].hysteresis;
338320

339321
return 0;
340322
}
341323

342324
static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
343325
int hyst)
344326
{
345-
struct __thermal_zone *data = tz->devdata;
346-
347-
if (trip >= data->ntrips || trip < 0)
327+
if (trip >= tz->num_trips || trip < 0)
348328
return -EDOM;
349329

350330
/* thermal framework should take care of data->mask & (1 << trip) */
351-
data->trips[trip].hysteresis = hyst;
331+
tz->trips[trip].hysteresis = hyst;
352332

353333
return 0;
354334
}
355335

356336
static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
357337
int *temp)
358338
{
359-
struct __thermal_zone *data = tz->devdata;
360339
int i;
361340

362-
for (i = 0; i < data->ntrips; i++)
363-
if (data->trips[i].type == THERMAL_TRIP_CRITICAL) {
364-
*temp = data->trips[i].temperature;
341+
for (i = 0; i < tz->num_trips; i++)
342+
if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) {
343+
*temp = tz->trips[i].temperature;
365344
return 0;
366345
}
367346

0 commit comments

Comments
 (0)