clk: Add clk_drop_range
authorMaxime Ripard <maxime@cerno.tech>
Fri, 25 Feb 2022 14:35:29 +0000 (15:35 +0100)
committerStephen Boyd <sboyd@kernel.org>
Sat, 12 Mar 2022 03:15:03 +0000 (19:15 -0800)
In order to reset the range on a clock, we need to call
clk_set_rate_range with a minimum of 0 and a maximum of ULONG_MAX. Since
it's fairly inconvenient, let's introduce a clk_drop_range() function
that will do just this.

Suggested-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220225143534.405820-8-maxime@cerno.tech
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/clk_test.c
include/linux/clk.h

index 8924a5ac56d83c2a3439bfe53aefa9bd8214807d..48f95d1784c8918a0d8943b4fbe52f3e397b0a74 100644 (file)
@@ -645,7 +645,7 @@ static void clk_range_test_multiple_set_range_rate_maximized(struct kunit *test)
        KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
 
        KUNIT_ASSERT_EQ(test,
-                       clk_set_rate_range(user2, 0, ULONG_MAX),
+                       clk_drop_range(user2),
                        0);
 
        rate = clk_get_rate(clk);
@@ -762,7 +762,7 @@ static void clk_range_test_multiple_set_range_rate_minimized(struct kunit *test)
        KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
 
        KUNIT_ASSERT_EQ(test,
-                       clk_set_rate_range(user2, 0, ULONG_MAX),
+                       clk_drop_range(user2),
                        0);
 
        rate = clk_get_rate(clk);
index 266e8de3cb515bde034bbd8ac1a08445bee8d991..39faa54efe887902849f30bf894cabda79a4d97d 100644 (file)
@@ -986,6 +986,17 @@ static inline void clk_bulk_disable_unprepare(int num_clks,
        clk_bulk_unprepare(num_clks, clks);
 }
 
+/**
+ * clk_drop_range - Reset any range set on that clock
+ * @clk: clock source
+ *
+ * Returns success (0) or negative errno.
+ */
+static inline int clk_drop_range(struct clk *clk)
+{
+       return clk_set_rate_range(clk, 0, ULONG_MAX);
+}
+
 /**
  * clk_get_optional - lookup and obtain a reference to an optional clock
  *                   producer.