Messages in this thread | | | Date | Mon, 18 Jul 2022 16:32:28 +0200 | Subject | Re: [PATCH v3 3/4] thermal/core: Build ascending ordered indexes for the trip points | From | Daniel Lezcano <> |
| |
On 18/07/2022 07:28, Zhang Rui wrote: > On Fri, 2022-07-15 at 23:09 +0200, Daniel Lezcano wrote: >> By convention the trips points are declared in the ascending >> temperature order. However, no specification for the device tree, >> ACPI >> or documentation tells the trip points must be ordered this way. >> >> In the other hand, we need those to be ordered to browse them at the >> thermal events. But if we assume they are ordered and change the code >> based on this assumption, any platform with shuffled trip points >> description will be broken (if they exist). >> >> Instead of taking the risk of breaking the existing platforms, use an >> array of temperature ordered trip identifiers and make it available >> for the code needing to browse the trip points in an ordered way. >> >> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
[ ... ]
>> +static void sort_trips_indexes(struct thermal_zone_device *tz) >> +{ >> + int i, j; >> + >> + for (i = 0; i < tz->trips; i++) >> + tz->trips_indexes[i] = i; >> + >> + for (i = 0; i < tz->trips; i++) { >> + for (j = i + 1; j < tz->trips; j++) { >> + int t1, t2; >> + >> + tz->ops->get_trip_temp(tz, tz- >>> trips_indexes[i], &t1); > > This line can be moved to the upper loop. > >> + tz->ops->get_trip_temp(tz, tz- >>> trips_indexes[j], &t2);
Actually, we can not move the line up because of the swap below
>> + if (t1 > t2) >> + swap(tz->trips_indexes[i], tz- >>> trips_indexes[j]); >> + } >> + } >> +}
-- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
| |