@@ -67,6 +67,16 @@ static struct thermal_zone_device_ops int340x_thermal_zone_ops = {
67
67
.critical = int340x_thermal_critical ,
68
68
};
69
69
70
+ static inline void * int_to_trip_priv (int i )
71
+ {
72
+ return (void * )(long )i ;
73
+ }
74
+
75
+ static inline int trip_priv_to_int (const struct thermal_trip * trip )
76
+ {
77
+ return (long )trip -> priv ;
78
+ }
79
+
70
80
static int int340x_thermal_read_trips (struct acpi_device * zone_adev ,
71
81
struct thermal_trip * zone_trips ,
72
82
int trip_cnt )
@@ -101,6 +111,7 @@ static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
101
111
break ;
102
112
103
113
zone_trips [trip_cnt ].type = THERMAL_TRIP_ACTIVE ;
114
+ zone_trips [trip_cnt ].priv = int_to_trip_priv (i );
104
115
trip_cnt ++ ;
105
116
}
106
117
@@ -212,45 +223,40 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone *int34x_zone)
212
223
}
213
224
EXPORT_SYMBOL_GPL (int340x_thermal_zone_remove );
214
225
215
- void int340x_thermal_update_trips (struct int34x_thermal_zone * int34x_zone )
226
+ static int int340x_update_one_trip (struct thermal_trip * trip , void * arg )
216
227
{
217
- struct acpi_device * zone_adev = int34x_zone -> adev ;
218
- struct thermal_trip * zone_trips = int34x_zone -> trips ;
219
- int trip_cnt = int34x_zone -> zone -> num_trips ;
220
- int act_trip_nr = 0 ;
221
- int i ;
222
-
223
- mutex_lock (& int34x_zone -> zone -> lock );
224
-
225
- for (i = int34x_zone -> aux_trip_nr ; i < trip_cnt ; i ++ ) {
226
- int temp , err ;
227
-
228
- switch (zone_trips [i ].type ) {
229
- case THERMAL_TRIP_CRITICAL :
230
- err = thermal_acpi_critical_trip_temp (zone_adev , & temp );
231
- break ;
232
- case THERMAL_TRIP_HOT :
233
- err = thermal_acpi_hot_trip_temp (zone_adev , & temp );
234
- break ;
235
- case THERMAL_TRIP_PASSIVE :
236
- err = thermal_acpi_passive_trip_temp (zone_adev , & temp );
237
- break ;
238
- case THERMAL_TRIP_ACTIVE :
239
- err = thermal_acpi_active_trip_temp (zone_adev , act_trip_nr ++ ,
240
- & temp );
241
- break ;
242
- default :
243
- err = - ENODEV ;
244
- }
245
- if (err ) {
246
- zone_trips [i ].temperature = THERMAL_TEMP_INVALID ;
247
- continue ;
248
- }
249
-
250
- zone_trips [i ].temperature = temp ;
228
+ struct acpi_device * zone_adev = arg ;
229
+ int temp , err ;
230
+
231
+ switch (trip -> type ) {
232
+ case THERMAL_TRIP_CRITICAL :
233
+ err = thermal_acpi_critical_trip_temp (zone_adev , & temp );
234
+ break ;
235
+ case THERMAL_TRIP_HOT :
236
+ err = thermal_acpi_hot_trip_temp (zone_adev , & temp );
237
+ break ;
238
+ case THERMAL_TRIP_PASSIVE :
239
+ err = thermal_acpi_passive_trip_temp (zone_adev , & temp );
240
+ break ;
241
+ case THERMAL_TRIP_ACTIVE :
242
+ err = thermal_acpi_active_trip_temp (zone_adev ,
243
+ trip_priv_to_int (trip ),
244
+ & temp );
245
+ break ;
246
+ default :
247
+ err = - ENODEV ;
251
248
}
249
+ if (err )
250
+ temp = THERMAL_TEMP_INVALID ;
252
251
253
- mutex_unlock (& int34x_zone -> zone -> lock );
252
+ trip -> temperature = temp ;
253
+ return 0 ;
254
+ }
255
+
256
+ void int340x_thermal_update_trips (struct int34x_thermal_zone * int34x_zone )
257
+ {
258
+ thermal_zone_for_each_trip (int34x_zone -> zone , int340x_update_one_trip ,
259
+ int34x_zone -> adev );
254
260
}
255
261
EXPORT_SYMBOL_GPL (int340x_thermal_update_trips );
256
262
0 commit comments