Re: [PATCH v2 4/8] thermal: gov_power_allocator: Simplify checks for valid power actor

From: Rafael J. Wysocki
Date: Wed Dec 20 2023 - 09:40:26 EST


On Tue, Dec 12, 2023 at 2:48 PM Lukasz Luba <lukasz.luba@xxxxxxx> wrote:
>
> There is a need to check if the cooling device in the thermal zone
> supports IPA callback and is set for control trip point.
> Refactor the code which validates the power actor capabilities and
> make it more consistent in all places.

This really is about reducing code duplication which is worth
mentioning, so I would say

"Add a helper to check if a given cooling device in a thermal zone
supports the IPA callback and is bound to the control trip point and
use it wherever that check is needed to reduce code duplication."

>
> No intentional functional impact.
>
> Signed-off-by: Lukasz Luba <lukasz.luba@xxxxxxx>
> ---
> drivers/thermal/gov_power_allocator.c | 41 +++++++++++----------------
> 1 file changed, 17 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index 3328c3ec71f2..1a605fd9c8c6 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -85,6 +85,13 @@ struct power_allocator_params {
> u32 *weighted_req_power;
> };
>
> +static bool power_actor_is_valid(struct power_allocator_params *params,
> + struct thermal_instance *instance)
> +{
> + return ((instance->trip == params->trip_max) &&

The inner parens are redundant.

> + cdev_is_power_actor(instance->cdev));
> +}

The part below LGTM.