@@ -2159,6 +2159,7 @@ struct clk_leaf_mux_ctx {
2159
2159
struct clk_hw hw ;
2160
2160
struct clk_hw parent ;
2161
2161
struct clk_rate_request * req ;
2162
+ int (* determine_rate_func )(struct clk_hw * hw , struct clk_rate_request * req );
2162
2163
};
2163
2164
2164
2165
static 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
2168
2169
struct clk_rate_request * parent_req = ctx -> req ;
2169
2170
2170
2171
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 );
2172
2173
if (ret )
2173
2174
return ret ;
2174
2175
@@ -2246,20 +2247,83 @@ static void clk_leaf_mux_set_rate_parent_test_exit(struct kunit *test)
2246
2247
clk_hw_unregister (& ctx -> mux_ctx .parents_ctx [1 ].hw );
2247
2248
}
2248
2249
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
+
2249
2309
/*
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.
2255
2315
*/
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 )
2257
2317
{
2258
2318
struct clk_leaf_mux_ctx * ctx = test -> priv ;
2259
2319
struct clk_hw * hw = & ctx -> hw ;
2260
2320
struct clk * clk = clk_hw_get_clk (hw , NULL );
2261
2321
struct clk_rate_request req ;
2262
2322
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 ;
2263
2327
2264
2328
ctx -> req = & req ;
2265
2329
rate = clk_get_rate (clk );
@@ -2274,7 +2338,8 @@ static void clk_leaf_mux_set_rate_parent__clk_determine_rate_proper_parent(struc
2274
2338
}
2275
2339
2276
2340
static 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 ),
2278
2343
{}
2279
2344
};
2280
2345
0 commit comments