Re: [PATCH v2 2/9] thermal: core: Add flags to struct thermal_trip

Daniel Lezcano
2024-02-22T15:36:43Z

On 22/02/2024 15:36, Daniel Lezcano wrote:
> On 12/02/2024 19:31, Rafael J. Wysocki wrote:
>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> In order to allow thermal zone creators to specify the writability of
>> trip point temperature and hysteresis on a per-trip basis, add a flags
>> field to struct thermal_trip and define flags to represent the desired
>> trip properties.
>>
>> Also make thermal_zone_device_register_with_trips() set the
>> THERMAL_TRIP_FLAG_RW_TEMP flag for all trips covered by the writable
>> trips mask passed to it and modify the thermal sysfs code to look at
>> the trip flags instead of using the writable trips mask directly or
>> checking the presence of the .set_trip_hyst() zone callback.
>>
>> Additionally, make trip_point_temp_store() and trip_point_hyst_store()
>> fail with an error code if the trip passed to one of them has
>> THERMAL_TRIP_FLAG_RW_TEMP or THERMAL_TRIP_FLAG_RW_HYST,
>> respectively, clear in its flags.
>>
>> No intentional functional impact.
>>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> ---

>> ===================================================================
>> --- linux-pm.orig/drivers/thermal/thermal_core.c
>> +++ linux-pm/drivers/thermal/thermal_core.c
>> @@ -1356,13 +1356,23 @@ thermal_zone_device_register_with_trips(
>>       tz->devdata = devdata;
>>       tz->trips = trips;
>>       tz->num_trips = num_trips;

[ ... ]

>> +    if (num_trips > 0) {
>
> Is this check really necessary? for_each_trip() should exit immediately
> if there is no trip points.

Given that is removed in patch 9/9, please ignore this comment

>> +        struct thermal_trip *trip;
>> +
>> +        for_each_trip(tz, trip) {
>> +            if (mask & 1)
>> +                trip->flags |= THERMAL_TRIP_FLAG_RW_TEMP;
>> +
>> +            mask >>= 1;
>> +        }
>> +    }

[ ... ]

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