[PATCH v6 05/12] clk: Use clamp instead of open-coding our own
Stephen Boyd
sboyd at kernel.org
Thu Feb 24 22:51:00 UTC 2022
Quoting Maxime Ripard (2022-02-23 02:55:53)
> The code in clk_set_rate_range() will, if the current rate is outside of
> the new range, will force it to the minimum or maximum.
s/will//
>
> Since it's running under the condition that the rate is either lower
> than the minimum, or higher than the maximum, this is equivalent to
> using clamp, while being less readable. Let's switch to using clamp
> instead.
>
> Signed-off-by: Maxime Ripard <maxime at cerno.tech>
> ---
> drivers/clk/clk.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 6c4e10209568..c15ee5070f52 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2388,11 +2388,7 @@ int clk_set_rate_range(struct clk *clk, unsigned long min, unsigned long max)
> * this corner case when determining the rate
> */
>
> - if (rate < min)
> - rate = min;
> - else
> - rate = max;
> -
> + rate = clamp(clk->core->req_rate, min, max);
> ret = clk_core_set_rate_nolock(clk->core, rate);
> if (ret) {
More information about the dri-devel
mailing list