[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <387c126a-0106-2227-4b4a-db284965b6ca@linaro.org>
Date: Mon, 18 Jul 2022 16:32:28 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Zhang Rui <rui.zhang@...el.com>, rafael@...nel.org
Cc: quic_manafm@...cinc.com, amitk@...nel.org, lukasz.luba@....com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/4] thermal/core: Build ascending ordered indexes for
the trip points
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@...aro.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
Powered by blists - more mailing lists