@@ -361,17 +361,19 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
361361}
362362
363363static void handle_thermal_trip (struct thermal_zone_device * tz ,
364- struct thermal_trip * trip )
364+ struct thermal_trip_desc * td )
365365{
366+ const struct thermal_trip * trip = & td -> trip ;
367+
366368 if (trip -> temperature == THERMAL_TEMP_INVALID )
367369 return ;
368370
369371 if (tz -> last_temperature == THERMAL_TEMP_INVALID ) {
370372 /* Initialization. */
371- trip -> threshold = trip -> temperature ;
372- if (tz -> temperature >= trip -> threshold )
373- trip -> threshold -= trip -> hysteresis ;
374- } else if (tz -> last_temperature < trip -> threshold ) {
373+ td -> threshold = trip -> temperature ;
374+ if (tz -> temperature >= td -> threshold )
375+ td -> threshold -= trip -> hysteresis ;
376+ } else if (tz -> last_temperature < td -> threshold ) {
375377 /*
376378 * The trip threshold is equal to the trip temperature, unless
377379 * the latter has changed in the meantime. In either case,
@@ -382,9 +384,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
382384 if (tz -> temperature >= trip -> temperature ) {
383385 thermal_notify_tz_trip_up (tz , trip );
384386 thermal_debug_tz_trip_up (tz , trip );
385- trip -> threshold = trip -> temperature - trip -> hysteresis ;
387+ td -> threshold = trip -> temperature - trip -> hysteresis ;
386388 } else {
387- trip -> threshold = trip -> temperature ;
389+ td -> threshold = trip -> temperature ;
388390 }
389391 } else {
390392 /*
@@ -400,9 +402,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
400402 if (tz -> temperature < trip -> temperature - trip -> hysteresis ) {
401403 thermal_notify_tz_trip_down (tz , trip );
402404 thermal_debug_tz_trip_down (tz , trip );
403- trip -> threshold = trip -> temperature ;
405+ td -> threshold = trip -> temperature ;
404406 } else {
405- trip -> threshold = trip -> temperature - trip -> hysteresis ;
407+ td -> threshold = trip -> temperature - trip -> hysteresis ;
406408 }
407409 }
408410
@@ -458,7 +460,7 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
458460void __thermal_zone_device_update (struct thermal_zone_device * tz ,
459461 enum thermal_notify_event event )
460462{
461- struct thermal_trip * trip ;
463+ struct thermal_trip_desc * td ;
462464
463465 if (tz -> suspended )
464466 return ;
@@ -472,8 +474,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
472474
473475 tz -> notify_event = event ;
474476
475- for_each_trip (tz , trip )
476- handle_thermal_trip (tz , trip );
477+ for_each_trip_desc (tz , td )
478+ handle_thermal_trip (tz , td );
477479
478480 monitor_thermal_zone (tz );
479481}
@@ -766,7 +768,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
766768 if (trip_index < 0 || trip_index >= tz -> num_trips )
767769 return - EINVAL ;
768770
769- return thermal_bind_cdev_to_trip (tz , & tz -> trips [trip_index ], cdev ,
771+ return thermal_bind_cdev_to_trip (tz , & tz -> trips [trip_index ]. trip , cdev ,
770772 upper , lower , weight );
771773}
772774EXPORT_SYMBOL_GPL (thermal_zone_bind_cooling_device );
@@ -825,7 +827,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
825827 if (trip_index < 0 || trip_index >= tz -> num_trips )
826828 return - EINVAL ;
827829
828- return thermal_unbind_cdev_from_trip (tz , & tz -> trips [trip_index ], cdev );
830+ return thermal_unbind_cdev_from_trip (tz , & tz -> trips [trip_index ]. trip , cdev );
829831}
830832EXPORT_SYMBOL_GPL (thermal_zone_unbind_cooling_device );
831833
@@ -1221,16 +1223,19 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
12211223
12221224int thermal_zone_get_crit_temp (struct thermal_zone_device * tz , int * temp )
12231225{
1224- int i , ret = - EINVAL ;
1226+ const struct thermal_trip_desc * td ;
1227+ int ret = - EINVAL ;
12251228
12261229 if (tz -> ops .get_crit_temp )
12271230 return tz -> ops .get_crit_temp (tz , temp );
12281231
12291232 mutex_lock (& tz -> lock );
12301233
1231- for (i = 0 ; i < tz -> num_trips ; i ++ ) {
1232- if (tz -> trips [i ].type == THERMAL_TRIP_CRITICAL ) {
1233- * temp = tz -> trips [i ].temperature ;
1234+ for_each_trip_desc (tz , td ) {
1235+ const struct thermal_trip * trip = & td -> trip ;
1236+
1237+ if (trip -> type == THERMAL_TRIP_CRITICAL ) {
1238+ * temp = trip -> temperature ;
12341239 ret = 0 ;
12351240 break ;
12361241 }
@@ -1274,7 +1279,9 @@ thermal_zone_device_register_with_trips(const char *type,
12741279 const struct thermal_zone_params * tzp ,
12751280 int passive_delay , int polling_delay )
12761281{
1282+ const struct thermal_trip * trip = trips ;
12771283 struct thermal_zone_device * tz ;
1284+ struct thermal_trip_desc * td ;
12781285 int id ;
12791286 int result ;
12801287 struct thermal_governor * governor ;
@@ -1339,7 +1346,8 @@ thermal_zone_device_register_with_trips(const char *type,
13391346 tz -> device .class = thermal_class ;
13401347 tz -> devdata = devdata ;
13411348 tz -> num_trips = num_trips ;
1342- memcpy (tz -> trips , trips , num_trips * sizeof (* trips ));
1349+ for_each_trip_desc (tz , td )
1350+ td -> trip = * trip ++ ;
13431351
13441352 thermal_set_delay_jiffies (& tz -> passive_delay_jiffies , passive_delay );
13451353 thermal_set_delay_jiffies (& tz -> polling_delay_jiffies , polling_delay );
0 commit comments