lkml.org 
[lkml]   [2022]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 3/4] thermal/core: Build ascending ordered indexes for the trip points
From
Date
On Mon, 2022-07-18 at 16:32 +0200, Daniel Lezcano wrote:
> 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

Oh, right.

But I still think that we should check the disabled trips as well as
the .get_trip_temp() return value here, or else, we may comparing some
random trip_temp value here.

thanks,
rui

>
> > > +                       if (t1 > t2)
> > > +                               swap(tz->trips_indexes[i], tz-
> > > > trips_indexes[j]);
> > > +               }
> > > +       }
> > > +}
>
>
>
>

\
 
 \ /
  Last update: 2022-07-19 03:08    [W:1.592 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site