Re: [PATCH v4 02/30] thermal/sysfs: Do not make get_trip_hyst optional

From: Daniel Lezcano
Date: Mon Sep 26 2022 - 10:37:17 EST


On 23/09/2022 16:19, Zhang Rui wrote:
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.

This would apply for the group not per trip point file, no?


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




--
<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