Skip to content

Commit c974484

Browse files
mripardbebarino
authored andcommitted
clk: Add clk_drop_range
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>
1 parent c80ac50 commit c974484

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/clk/clk_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static void clk_range_test_multiple_set_range_rate_maximized(struct kunit *test)
645645
KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
646646

647647
KUNIT_ASSERT_EQ(test,
648-
clk_set_rate_range(user2, 0, ULONG_MAX),
648+
clk_drop_range(user2),
649649
0);
650650

651651
rate = clk_get_rate(clk);
@@ -762,7 +762,7 @@ static void clk_range_test_multiple_set_range_rate_minimized(struct kunit *test)
762762
KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
763763

764764
KUNIT_ASSERT_EQ(test,
765-
clk_set_rate_range(user2, 0, ULONG_MAX),
765+
clk_drop_range(user2),
766766
0);
767767

768768
rate = clk_get_rate(clk);

include/linux/clk.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,17 @@ static inline void clk_bulk_disable_unprepare(int num_clks,
986986
clk_bulk_unprepare(num_clks, clks);
987987
}
988988

989+
/**
990+
* clk_drop_range - Reset any range set on that clock
991+
* @clk: clock source
992+
*
993+
* Returns success (0) or negative errno.
994+
*/
995+
static inline int clk_drop_range(struct clk *clk)
996+
{
997+
return clk_set_rate_range(clk, 0, ULONG_MAX);
998+
}
999+
9891000
/**
9901001
* clk_get_optional - lookup and obtain a reference to an optional clock
9911002
* producer.

0 commit comments

Comments
 (0)