1 // SPDX-License-Identifier: LGPL-2.1+
6 #include "thermal_nl.h"
8 int for_each_thermal_cdev(struct thermal_cdev *cdev, cb_tc_t cb, void *arg)
15 for (i = 0; cdev[i].id != -1; i++)
16 ret |= cb(&cdev[i], arg);
21 int for_each_thermal_trip(struct thermal_trip *tt, cb_tt_t cb, void *arg)
28 for (i = 0; tt[i].id != -1; i++)
29 ret |= cb(&tt[i], arg);
34 int for_each_thermal_zone(struct thermal_zone *tz, cb_tz_t cb, void *arg)
41 for (i = 0; tz[i].id != -1; i++)
42 ret |= cb(&tz[i], arg);
47 struct thermal_zone *thermal_zone_find_by_name(struct thermal_zone *tz,
55 for (i = 0; tz[i].id != -1; i++) {
56 if (!strcmp(tz[i].name, name))
63 struct thermal_zone *thermal_zone_find_by_id(struct thermal_zone *tz, int id)
70 for (i = 0; tz[i].id != -1; i++) {
78 static int __thermal_zone_discover(struct thermal_zone *tz, void *th)
80 if (thermal_cmd_get_trip(th, tz) < 0)
83 if (thermal_cmd_get_governor(th, tz))
89 struct thermal_zone *thermal_zone_discover(struct thermal_handler *th)
91 struct thermal_zone *tz;
93 if (thermal_cmd_get_tz(th, &tz) < 0)
96 if (for_each_thermal_zone(tz, __thermal_zone_discover, th))
102 void thermal_exit(struct thermal_handler *th)
104 thermal_cmd_exit(th);
105 thermal_events_exit(th);
106 thermal_sampling_exit(th);
111 struct thermal_handler *thermal_init(struct thermal_ops *ops)
113 struct thermal_handler *th;
115 th = malloc(sizeof(*th));
120 if (thermal_events_init(th))
123 if (thermal_sampling_init(th))
126 if (thermal_cmd_init(th))