bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0835-clk-Add-clk_drop_range.patch
1 From 6e08e0fa4ba16546fdbb2cdcc4ee6483bd0a6956 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 17 Jan 2022 16:43:52 +0100
4 Subject: [PATCH] clk: Add clk_drop_range
5
6 In order to reset the range on a clock, we need to call
7 clk_set_rate_range with a minimum of 0 and a maximum of ULONG_MAX. Since
8 it's fairly inconvenient, let's introduce a clk_drop_range() function
9 that will do just this.
10
11 Suggested-by: Stephen Boyd <sboyd@kernel.org>
12 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
13 ---
14 drivers/clk/clk_test.c | 4 ++--
15 include/linux/clk.h | 11 +++++++++++
16 2 files changed, 13 insertions(+), 2 deletions(-)
17
18 --- a/drivers/clk/clk_test.c
19 +++ b/drivers/clk/clk_test.c
20 @@ -645,7 +645,7 @@ static void clk_range_test_multiple_set_
21 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
22
23 KUNIT_ASSERT_EQ(test,
24 - clk_set_rate_range(user2, 0, ULONG_MAX),
25 + clk_drop_range(user2),
26 0);
27
28 rate = clk_get_rate(clk);
29 @@ -762,7 +762,7 @@ static void clk_range_test_multiple_set_
30 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
31
32 KUNIT_ASSERT_EQ(test,
33 - clk_set_rate_range(user2, 0, ULONG_MAX),
34 + clk_drop_range(user2),
35 0);
36
37 rate = clk_get_rate(clk);
38 --- a/include/linux/clk.h
39 +++ b/include/linux/clk.h
40 @@ -987,6 +987,17 @@ static inline void clk_bulk_disable_unpr
41 }
42
43 /**
44 + * clk_drop_range - Reset any range set on that clock
45 + * @clk: clock source
46 + *
47 + * Returns success (0) or negative errno.
48 + */
49 +static inline int clk_drop_range(struct clk *clk)
50 +{
51 + return clk_set_rate_range(clk, 0, ULONG_MAX);
52 +}
53 +
54 +/**
55 * clk_get_optional - lookup and obtain a reference to an optional clock
56 * producer.
57 * @dev: device for clock "consumer"