Re: [PATCH v1] thermal: trip: Rework thermal_zone_set_trip() and its callers

From: Rafael J. Wysocki
Date: Tue Nov 28 2023 - 07:58:05 EST


On Tue, Nov 28, 2023 at 1:53 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>
> Hi Lukasz,
>
> On Tue, Nov 28, 2023 at 9:16 AM Lukasz Luba <lukasz.luba@xxxxxxx> wrote:
> >
> > Hi Rafael,
> >
> > On 11/27/23 19:59, Rafael J. Wysocki wrote:
> > > From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> > >

[cut]

> > > Index: linux-pm/drivers/thermal/thermal_trip.c
> > > ===================================================================
> > > --- linux-pm.orig/drivers/thermal/thermal_trip.c
> > > +++ linux-pm/drivers/thermal/thermal_trip.c
> > > @@ -148,42 +148,61 @@ int thermal_zone_get_trip(struct thermal
> > > EXPORT_SYMBOL_GPL(thermal_zone_get_trip);
> > >
> > > int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
> > > - const struct thermal_trip *trip)
> > > + enum thermal_set_trip_target what, const char *buf)
> > > {
> > > - struct thermal_trip t;
> > > - int ret;
> > > + struct thermal_trip *trip;
> > > + int val, ret = 0;
> > >
> > > - if (!tz->ops->set_trip_temp && !tz->ops->set_trip_hyst && !tz->trips)
> > > - return -EINVAL;
> >
> > Here we could bail out when there are no callbacks.
>
> Not really, because the trip is updated regardless.

Actually, the condition above is always false after recent changes,
because tz->trips[] is always present, so the if () statement is
redundant.