@@ -2159,6 +2159,7 @@ struct clk_leaf_mux_ctx {
21592159 struct clk_hw hw ;
21602160 struct clk_hw parent ;
21612161 struct clk_rate_request * req ;
2162+ int (* determine_rate_func )(struct clk_hw * hw , struct clk_rate_request * req );
21622163};
21632164
21642165static int clk_leaf_mux_determine_rate (struct clk_hw * hw , struct clk_rate_request * req )
@@ -2168,7 +2169,7 @@ static int clk_leaf_mux_determine_rate(struct clk_hw *hw, struct clk_rate_reques
21682169 struct clk_rate_request * parent_req = ctx -> req ;
21692170
21702171 clk_hw_forward_rate_request (hw , req , req -> best_parent_hw , parent_req , req -> rate );
2171- ret = __clk_determine_rate (req -> best_parent_hw , parent_req );
2172+ ret = ctx -> determine_rate_func (req -> best_parent_hw , parent_req );
21722173 if (ret )
21732174 return ret ;
21742175
@@ -2246,20 +2247,83 @@ static void clk_leaf_mux_set_rate_parent_test_exit(struct kunit *test)
22462247 clk_hw_unregister (& ctx -> mux_ctx .parents_ctx [1 ].hw );
22472248}
22482249
2250+ struct clk_leaf_mux_set_rate_parent_determine_rate_test_case {
2251+ const char * desc ;
2252+ int (* determine_rate_func )(struct clk_hw * hw , struct clk_rate_request * req );
2253+ };
2254+
2255+ static void
2256+ clk_leaf_mux_set_rate_parent_determine_rate_test_case_to_desc (
2257+ const struct clk_leaf_mux_set_rate_parent_determine_rate_test_case * t , char * desc )
2258+ {
2259+ strcpy (desc , t -> desc );
2260+ }
2261+
2262+ static const struct clk_leaf_mux_set_rate_parent_determine_rate_test_case
2263+ clk_leaf_mux_set_rate_parent_determine_rate_test_cases [] = {
2264+ {
2265+ /*
2266+ * Test that __clk_determine_rate() on the parent that can't
2267+ * change rate doesn't return a clk_rate_request structure with
2268+ * the best_parent_hw pointer pointing to the parent.
2269+ */
2270+ .desc = "clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent" ,
2271+ .determine_rate_func = __clk_determine_rate ,
2272+ },
2273+ {
2274+ /*
2275+ * Test that __clk_mux_determine_rate() on the parent that
2276+ * can't change rate doesn't return a clk_rate_request
2277+ * structure with the best_parent_hw pointer pointing to
2278+ * the parent.
2279+ */
2280+ .desc = "clk_leaf_mux_set_rate_parent__clk_mux_determine_rate_proper_parent" ,
2281+ .determine_rate_func = __clk_mux_determine_rate ,
2282+ },
2283+ {
2284+ /*
2285+ * Test that __clk_mux_determine_rate_closest() on the parent
2286+ * that can't change rate doesn't return a clk_rate_request
2287+ * structure with the best_parent_hw pointer pointing to
2288+ * the parent.
2289+ */
2290+ .desc = "clk_leaf_mux_set_rate_parent__clk_mux_determine_rate_closest_proper_parent" ,
2291+ .determine_rate_func = __clk_mux_determine_rate_closest ,
2292+ },
2293+ {
2294+ /*
2295+ * Test that clk_hw_determine_rate_no_reparent() on the parent
2296+ * that can't change rate doesn't return a clk_rate_request
2297+ * structure with the best_parent_hw pointer pointing to
2298+ * the parent.
2299+ */
2300+ .desc = "clk_leaf_mux_set_rate_parent_clk_hw_determine_rate_no_reparent_proper_parent" ,
2301+ .determine_rate_func = clk_hw_determine_rate_no_reparent ,
2302+ },
2303+ };
2304+
2305+ KUNIT_ARRAY_PARAM (clk_leaf_mux_set_rate_parent_determine_rate_test ,
2306+ clk_leaf_mux_set_rate_parent_determine_rate_test_cases ,
2307+ clk_leaf_mux_set_rate_parent_determine_rate_test_case_to_desc )
2308+
22492309/*
2250- * Test that, for a clock that will forward any rate request to its parent, the
2251- * rate request structure returned by __clk_determine_rate() is sane and
2252- * doesn't have the clk_rate_request's best_parent_hw pointer point to the
2253- * clk_hw passed into __clk_determine_rate() . See commit 262ca38f4b6e ("clk:
2254- * Stop forwarding clk_rate_requests to the parent") for more background.
2310+ * Test that when a clk that can't change rate itself calls a function like
2311+ * __clk_determine_rate() on its parent it doesn't get back a clk_rate_request
2312+ * structure that has the best_parent_hw pointer point to the clk_hw passed
2313+ * into the determine rate function . See commit 262ca38f4b6e ("clk: Stop
2314+ * forwarding clk_rate_requests to the parent") for more background.
22552315 */
2256- static void clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent (struct kunit * test )
2316+ static void clk_leaf_mux_set_rate_parent_determine_rate_test (struct kunit * test )
22572317{
22582318 struct clk_leaf_mux_ctx * ctx = test -> priv ;
22592319 struct clk_hw * hw = & ctx -> hw ;
22602320 struct clk * clk = clk_hw_get_clk (hw , NULL );
22612321 struct clk_rate_request req ;
22622322 unsigned long rate ;
2323+ const struct clk_leaf_mux_set_rate_parent_determine_rate_test_case * test_param ;
2324+
2325+ test_param = test -> param_value ;
2326+ ctx -> determine_rate_func = test_param -> determine_rate_func ;
22632327
22642328 ctx -> req = & req ;
22652329 rate = clk_get_rate (clk );
@@ -2274,7 +2338,8 @@ static void clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent(struc
22742338}
22752339
22762340static struct kunit_case clk_leaf_mux_set_rate_parent_test_cases [] = {
2277- KUNIT_CASE (clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent ),
2341+ KUNIT_CASE_PARAM (clk_leaf_mux_set_rate_parent_determine_rate_test ,
2342+ clk_leaf_mux_set_rate_parent_determine_rate_test_gen_params ),
22782343 {}
22792344};
22802345
0 commit comments