bcm27xx: add support for linux v5.15
[openwrt/staging/ldir.git] / target / linux / bcm27xx / patches-5.15 / 950-0833-clk-Use-clamp-instead-of-open-coding-our-own.patch
1 From dbd88e6fdd547cf8f6765b8dade9f89cf5c0ead9 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 17 Jan 2022 16:38:10 +0100
4 Subject: [PATCH] clk: Use clamp instead of open-coding our own
5
6 The code in clk_set_rate_range() will, if the current rate is outside of
7 the new range, force it to the minimum or maximum.
8
9 Since it's running under the condition that the rate is either lower
10 than the minimum, or higher than the maximum, this is equivalent to
11 using clamp, while being less readable. Let's switch to using clamp
12 instead.
13
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 drivers/clk/clk.c | 6 +-----
17 1 file changed, 1 insertion(+), 5 deletions(-)
18
19 --- a/drivers/clk/clk.c
20 +++ b/drivers/clk/clk.c
21 @@ -2387,11 +2387,7 @@ int clk_set_rate_range(struct clk *clk,
22 * this corner case when determining the rate
23 */
24
25 - if (rate < min)
26 - rate = min;
27 - else
28 - rate = max;
29 -
30 + rate = clamp(clk->core->req_rate, min, max);
31 ret = clk_core_set_rate_nolock(clk->core, rate);
32 if (ret) {
33 /* rollback the changes */