Skip to content

Commit 96b8b43

Browse files
committed
thermal: core: Rework and rename __for_each_thermal_trip()
Rework the currently unused __for_each_thermal_trip() to pass original pointers to struct thermal_trip objects to the callback, so it can be used for updating trip data (e.g. temperatures), rename it to for_each_thermal_trip() and make it available to modular drivers. Suggested-by: Daniel Lezcano <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 68b7778 commit 96b8b43

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

drivers/thermal/thermal_core.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *,
5454
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
5555
void *thermal_governor);
5656

57-
int __for_each_thermal_trip(struct thermal_zone_device *,
58-
int (*cb)(struct thermal_trip *, void *),
59-
void *);
60-
6157
struct thermal_zone_device *thermal_zone_get_by_id(int id);
6258

6359
struct thermal_attr {

drivers/thermal/thermal_trip.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@
99
*/
1010
#include "thermal_core.h"
1111

12-
int __for_each_thermal_trip(struct thermal_zone_device *tz,
13-
int (*cb)(struct thermal_trip *, void *),
14-
void *data)
12+
int for_each_thermal_trip(struct thermal_zone_device *tz,
13+
int (*cb)(struct thermal_trip *, void *),
14+
void *data)
1515
{
1616
int i, ret;
17-
struct thermal_trip trip;
1817

1918
lockdep_assert_held(&tz->lock);
2019

21-
for (i = 0; i < tz->num_trips; i++) {
22-
23-
ret = __thermal_zone_get_trip(tz, i, &trip);
24-
if (ret)
25-
return ret;
20+
if (!tz->trips)
21+
return -ENODATA;
2622

27-
ret = cb(&trip, data);
23+
for (i = 0; i < tz->num_trips; i++) {
24+
ret = cb(&tz->trips[i], data);
2825
if (ret)
2926
return ret;
3027
}
3128

3229
return 0;
3330
}
31+
EXPORT_SYMBOL_GPL(for_each_thermal_trip);
3432

3533
int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
3634
{

include/linux/thermal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
289289
int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
290290
const struct thermal_trip *trip);
291291

292+
int for_each_thermal_trip(struct thermal_zone_device *tz,
293+
int (*cb)(struct thermal_trip *, void *),
294+
void *data);
292295
int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
293296

294297
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);

0 commit comments

Comments
 (0)