Re: [PATCH v4 02/30] thermal/sysfs: Do not make get_trip_hyst optional
From: Zhang Rui
Date: Fri Sep 23 2022 - 10:19:18 EST
On Wed, 2022-09-21 at 11:42 +0200, Daniel Lezcano wrote:
> The get_trip_hyst() ops is optional. It results all around the
> thermal
> framework code a check against the ops pointer and different action
> adding more complexity and making the code less readable and
> understandable.
>
> A zero hysteresis value is perfectly valid, so instead of adding more
> circumvolutions in the code, create unconditionnaly the hysteresis
> and
> use the thermal_zone_get_trip() function which returns a zero
> hysteresis if the get_trip_hyst() is not defined.
I think an alternative way is to use the .is_visible() callback to make
this cleanup transparent to userspace.
With this, we can remove the
if (tz->ops->set_trip_hyst)check in create_trip_attrs() as well.
But you make the cal. :)
thanks,
rui