thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
Make __thermal_zone_set_trips() use for_each_trip() instead of an open- coded loop over trip indices. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
This commit is contained in:
parent
b6515a88ba
commit
0c0c4740c9
@ -63,25 +63,21 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
|
|||||||
*/
|
*/
|
||||||
void __thermal_zone_set_trips(struct thermal_zone_device *tz)
|
void __thermal_zone_set_trips(struct thermal_zone_device *tz)
|
||||||
{
|
{
|
||||||
struct thermal_trip trip;
|
const struct thermal_trip *trip;
|
||||||
int low = -INT_MAX, high = INT_MAX;
|
int low = -INT_MAX, high = INT_MAX;
|
||||||
bool same_trip = false;
|
bool same_trip = false;
|
||||||
int i, ret;
|
int ret;
|
||||||
|
|
||||||
lockdep_assert_held(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
if (!tz->ops->set_trips)
|
if (!tz->ops->set_trips)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < tz->num_trips; i++) {
|
for_each_trip(tz, trip) {
|
||||||
bool low_set = false;
|
bool low_set = false;
|
||||||
int trip_low;
|
int trip_low;
|
||||||
|
|
||||||
ret = __thermal_zone_get_trip(tz, i , &trip);
|
trip_low = trip->temperature - trip->hysteresis;
|
||||||
if (ret)
|
|
||||||
return;
|
|
||||||
|
|
||||||
trip_low = trip.temperature - trip.hysteresis;
|
|
||||||
|
|
||||||
if (trip_low < tz->temperature && trip_low > low) {
|
if (trip_low < tz->temperature && trip_low > low) {
|
||||||
low = trip_low;
|
low = trip_low;
|
||||||
@ -89,9 +85,9 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
|
|||||||
same_trip = false;
|
same_trip = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trip.temperature > tz->temperature &&
|
if (trip->temperature > tz->temperature &&
|
||||||
trip.temperature < high) {
|
trip->temperature < high) {
|
||||||
high = trip.temperature;
|
high = trip->temperature;
|
||||||
same_trip = low_set;
|
same_trip = low_set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user