Skip to content

Commit

Permalink
thermal: core: Rework and rename __for_each_thermal_trip()
Browse files Browse the repository at this point in the history
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 <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Rafael J. Wysocki committed Aug 17, 2023
1 parent 68b7778 commit 96b8b43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions drivers/thermal/thermal_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *,
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
void *thermal_governor);

int __for_each_thermal_trip(struct thermal_zone_device *,
int (*cb)(struct thermal_trip *, void *),
void *);

struct thermal_zone_device *thermal_zone_get_by_id(int id);

struct thermal_attr {
Expand Down
18 changes: 8 additions & 10 deletions drivers/thermal/thermal_trip.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@
*/
#include "thermal_core.h"

int __for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data)
int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data)
{
int i, ret;
struct thermal_trip trip;

lockdep_assert_held(&tz->lock);

for (i = 0; i < tz->num_trips; i++) {

ret = __thermal_zone_get_trip(tz, i, &trip);
if (ret)
return ret;
if (!tz->trips)
return -ENODATA;

ret = cb(&trip, data);
for (i = 0; i < tz->num_trips; i++) {
ret = cb(&tz->trips[i], data);
if (ret)
return ret;
}

return 0;
}
EXPORT_SYMBOL_GPL(for_each_thermal_trip);

int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
{
Expand Down
3 changes: 3 additions & 0 deletions include/linux/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
const struct thermal_trip *trip);

int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *),
void *data);
int thermal_zone_get_num_trips(struct thermal_zone_device *tz);

int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
Expand Down

0 comments on commit 96b8b43

Please sign in to comment.