[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b83d6630bb133b2c02b4a4e5e7777ad27f8fe159.camel@intel.com>
Date: Tue, 19 Jul 2022 09:07:01 +0800
From: Zhang Rui <rui.zhang@...el.com>
To: Daniel Lezcano <daniel.lezcano@...aro.org>, 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 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@...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
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]);
> > > + }
> > > + }
> > > +}
>
>
>
>
Powered by blists - more mailing lists