Commit d4b82e58 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
 "Two clk driver fixes and a unit test fix:

   - Terminate the of_device_id table in the Samsung exynosautov920 clk
     driver so that device matching logic doesn't run off the end of the
     array into other memory and break matching for any kernel with this
     driver loaded

   - Properly limit the max clk ID in the Rockchip clk driver

   - Use clk kunit helpers in the clk tests so that memory isn't leaked
     after the test concludes"

* tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
  clk: test: Fix some memory leaks
  clk: rockchip: fix finding of maximum clock ID
  clk: samsung: Fix out-of-bound access of of_match_node()
parents 6efbea77 6b5cca78
...@@ -473,7 +473,7 @@ clk_multiple_parents_mux_test_init(struct kunit *test) ...@@ -473,7 +473,7 @@ clk_multiple_parents_mux_test_init(struct kunit *test)
&clk_dummy_rate_ops, &clk_dummy_rate_ops,
0); 0);
ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
ret = clk_hw_register(NULL, &ctx->parents_ctx[0].hw); ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[0].hw);
if (ret) if (ret)
return ret; return ret;
...@@ -481,7 +481,7 @@ clk_multiple_parents_mux_test_init(struct kunit *test) ...@@ -481,7 +481,7 @@ clk_multiple_parents_mux_test_init(struct kunit *test)
&clk_dummy_rate_ops, &clk_dummy_rate_ops,
0); 0);
ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw);
if (ret) if (ret)
return ret; return ret;
...@@ -489,23 +489,13 @@ clk_multiple_parents_mux_test_init(struct kunit *test) ...@@ -489,23 +489,13 @@ clk_multiple_parents_mux_test_init(struct kunit *test)
ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents,
&clk_multiple_parents_mux_ops, &clk_multiple_parents_mux_ops,
CLK_SET_RATE_PARENT); CLK_SET_RATE_PARENT);
ret = clk_hw_register(NULL, &ctx->hw); ret = clk_hw_register_kunit(test, NULL, &ctx->hw);
if (ret) if (ret)
return ret; return ret;
return 0; return 0;
} }
static void
clk_multiple_parents_mux_test_exit(struct kunit *test)
{
struct clk_multiple_parent_ctx *ctx = test->priv;
clk_hw_unregister(&ctx->hw);
clk_hw_unregister(&ctx->parents_ctx[0].hw);
clk_hw_unregister(&ctx->parents_ctx[1].hw);
}
/* /*
* Test that for a clock with multiple parents, clk_get_parent() * Test that for a clock with multiple parents, clk_get_parent()
* actually returns the current one. * actually returns the current one.
...@@ -561,18 +551,18 @@ clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test) ...@@ -561,18 +551,18 @@ clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test)
{ {
struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_multiple_parent_ctx *ctx = test->priv;
struct clk_hw *hw = &ctx->hw; struct clk_hw *hw = &ctx->hw;
struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL);
struct clk *parent1, *parent2; struct clk *parent1, *parent2;
unsigned long rate; unsigned long rate;
int ret; int ret;
kunit_skip(test, "This needs to be fixed in the core."); kunit_skip(test, "This needs to be fixed in the core.");
parent1 = clk_hw_get_clk(&ctx->parents_ctx[0].hw, NULL); parent1 = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[0].hw, NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent1);
KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1)); KUNIT_ASSERT_TRUE(test, clk_is_match(clk_get_parent(clk), parent1));
parent2 = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); parent2 = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[1].hw, NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent2);
ret = clk_set_rate(parent1, DUMMY_CLOCK_RATE_1); ret = clk_set_rate(parent1, DUMMY_CLOCK_RATE_1);
...@@ -593,10 +583,6 @@ clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test) ...@@ -593,10 +583,6 @@ clk_test_multiple_parents_mux_set_range_set_parent_get_rate(struct kunit *test)
KUNIT_ASSERT_GT(test, rate, 0); KUNIT_ASSERT_GT(test, rate, 0);
KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000); KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000);
KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000); KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
clk_put(parent2);
clk_put(parent1);
clk_put(clk);
} }
static struct kunit_case clk_multiple_parents_mux_test_cases[] = { static struct kunit_case clk_multiple_parents_mux_test_cases[] = {
...@@ -617,7 +603,6 @@ static struct kunit_suite ...@@ -617,7 +603,6 @@ static struct kunit_suite
clk_multiple_parents_mux_test_suite = { clk_multiple_parents_mux_test_suite = {
.name = "clk-multiple-parents-mux-test", .name = "clk-multiple-parents-mux-test",
.init = clk_multiple_parents_mux_test_init, .init = clk_multiple_parents_mux_test_init,
.exit = clk_multiple_parents_mux_test_exit,
.test_cases = clk_multiple_parents_mux_test_cases, .test_cases = clk_multiple_parents_mux_test_cases,
}; };
...@@ -637,29 +622,20 @@ clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) ...@@ -637,29 +622,20 @@ clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test)
&clk_dummy_rate_ops, &clk_dummy_rate_ops,
0); 0);
ctx->parents_ctx[1].rate = DUMMY_CLOCK_INIT_RATE; ctx->parents_ctx[1].rate = DUMMY_CLOCK_INIT_RATE;
ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw);
if (ret) if (ret)
return ret; return ret;
ctx->hw.init = CLK_HW_INIT_PARENTS("test-orphan-mux", parents, ctx->hw.init = CLK_HW_INIT_PARENTS("test-orphan-mux", parents,
&clk_multiple_parents_mux_ops, &clk_multiple_parents_mux_ops,
CLK_SET_RATE_PARENT); CLK_SET_RATE_PARENT);
ret = clk_hw_register(NULL, &ctx->hw); ret = clk_hw_register_kunit(test, NULL, &ctx->hw);
if (ret) if (ret)
return ret; return ret;
return 0; return 0;
} }
static void
clk_orphan_transparent_multiple_parent_mux_test_exit(struct kunit *test)
{
struct clk_multiple_parent_ctx *ctx = test->priv;
clk_hw_unregister(&ctx->hw);
clk_hw_unregister(&ctx->parents_ctx[1].hw);
}
/* /*
* Test that, for a mux whose current parent hasn't been registered yet and is * Test that, for a mux whose current parent hasn't been registered yet and is
* thus orphan, clk_get_parent() will return NULL. * thus orphan, clk_get_parent() will return NULL.
...@@ -912,7 +888,7 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st ...@@ -912,7 +888,7 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st
{ {
struct clk_multiple_parent_ctx *ctx = test->priv; struct clk_multiple_parent_ctx *ctx = test->priv;
struct clk_hw *hw = &ctx->hw; struct clk_hw *hw = &ctx->hw;
struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL);
struct clk *parent; struct clk *parent;
unsigned long rate; unsigned long rate;
int ret; int ret;
...@@ -921,7 +897,7 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st ...@@ -921,7 +897,7 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st
clk_hw_set_rate_range(hw, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2); clk_hw_set_rate_range(hw, DUMMY_CLOCK_RATE_1, DUMMY_CLOCK_RATE_2);
parent = clk_hw_get_clk(&ctx->parents_ctx[1].hw, NULL); parent = clk_hw_get_clk_kunit(test, &ctx->parents_ctx[1].hw, NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, parent);
ret = clk_set_parent(clk, parent); ret = clk_set_parent(clk, parent);
...@@ -931,9 +907,6 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st ...@@ -931,9 +907,6 @@ clk_test_orphan_transparent_multiple_parent_mux_set_range_set_parent_get_rate(st
KUNIT_ASSERT_GT(test, rate, 0); KUNIT_ASSERT_GT(test, rate, 0);
KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1); KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2); KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
clk_put(parent);
clk_put(clk);
} }
static struct kunit_case clk_orphan_transparent_multiple_parent_mux_test_cases[] = { static struct kunit_case clk_orphan_transparent_multiple_parent_mux_test_cases[] = {
...@@ -961,7 +934,6 @@ static struct kunit_case clk_orphan_transparent_multiple_parent_mux_test_cases[] ...@@ -961,7 +934,6 @@ static struct kunit_case clk_orphan_transparent_multiple_parent_mux_test_cases[]
static struct kunit_suite clk_orphan_transparent_multiple_parent_mux_test_suite = { static struct kunit_suite clk_orphan_transparent_multiple_parent_mux_test_suite = {
.name = "clk-orphan-transparent-multiple-parent-mux-test", .name = "clk-orphan-transparent-multiple-parent-mux-test",
.init = clk_orphan_transparent_multiple_parent_mux_test_init, .init = clk_orphan_transparent_multiple_parent_mux_test_init,
.exit = clk_orphan_transparent_multiple_parent_mux_test_exit,
.test_cases = clk_orphan_transparent_multiple_parent_mux_test_cases, .test_cases = clk_orphan_transparent_multiple_parent_mux_test_cases,
}; };
...@@ -986,7 +958,7 @@ static int clk_single_parent_mux_test_init(struct kunit *test) ...@@ -986,7 +958,7 @@ static int clk_single_parent_mux_test_init(struct kunit *test)
&clk_dummy_rate_ops, &clk_dummy_rate_ops,
0); 0);
ret = clk_hw_register(NULL, &ctx->parent_ctx.hw); ret = clk_hw_register_kunit(test, NULL, &ctx->parent_ctx.hw);
if (ret) if (ret)
return ret; return ret;
...@@ -994,7 +966,7 @@ static int clk_single_parent_mux_test_init(struct kunit *test) ...@@ -994,7 +966,7 @@ static int clk_single_parent_mux_test_init(struct kunit *test)
&clk_dummy_single_parent_ops, &clk_dummy_single_parent_ops,
CLK_SET_RATE_PARENT); CLK_SET_RATE_PARENT);
ret = clk_hw_register(NULL, &ctx->hw); ret = clk_hw_register_kunit(test, NULL, &ctx->hw);
if (ret) if (ret)
return ret; return ret;
...@@ -1060,7 +1032,7 @@ clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test) ...@@ -1060,7 +1032,7 @@ clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test)
{ {
struct clk_single_parent_ctx *ctx = test->priv; struct clk_single_parent_ctx *ctx = test->priv;
struct clk_hw *hw = &ctx->hw; struct clk_hw *hw = &ctx->hw;
struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL);
struct clk *parent; struct clk *parent;
int ret; int ret;
...@@ -1074,8 +1046,6 @@ clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test) ...@@ -1074,8 +1046,6 @@ clk_test_single_parent_mux_set_range_disjoint_child_last(struct kunit *test)
ret = clk_set_rate_range(clk, 3000, 4000); ret = clk_set_rate_range(clk, 3000, 4000);
KUNIT_EXPECT_LT(test, ret, 0); KUNIT_EXPECT_LT(test, ret, 0);
clk_put(clk);
} }
/* /*
...@@ -1092,7 +1062,7 @@ clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test) ...@@ -1092,7 +1062,7 @@ clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test)
{ {
struct clk_single_parent_ctx *ctx = test->priv; struct clk_single_parent_ctx *ctx = test->priv;
struct clk_hw *hw = &ctx->hw; struct clk_hw *hw = &ctx->hw;
struct clk *clk = clk_hw_get_clk(hw, NULL); struct clk *clk = clk_hw_get_clk_kunit(test, hw, NULL);
struct clk *parent; struct clk *parent;
int ret; int ret;
...@@ -1106,8 +1076,6 @@ clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test) ...@@ -1106,8 +1076,6 @@ clk_test_single_parent_mux_set_range_disjoint_parent_last(struct kunit *test)
ret = clk_set_rate_range(parent, 3000, 4000); ret = clk_set_rate_range(parent, 3000, 4000);
KUNIT_EXPECT_LT(test, ret, 0); KUNIT_EXPECT_LT(test, ret, 0);
clk_put(clk);
} }
/* /*
...@@ -1238,7 +1206,6 @@ static struct kunit_suite ...@@ -1238,7 +1206,6 @@ static struct kunit_suite
clk_single_parent_mux_test_suite = { clk_single_parent_mux_test_suite = {
.name = "clk-single-parent-mux-test", .name = "clk-single-parent-mux-test",
.init = clk_single_parent_mux_test_init, .init = clk_single_parent_mux_test_init,
.exit = clk_single_parent_mux_test_exit,
.test_cases = clk_single_parent_mux_test_cases, .test_cases = clk_single_parent_mux_test_cases,
}; };
......
...@@ -439,7 +439,7 @@ unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list, ...@@ -439,7 +439,7 @@ unsigned long rockchip_clk_find_max_clk_id(struct rockchip_clk_branch *list,
if (list->id > max) if (list->id > max)
max = list->id; max = list->id;
if (list->child && list->child->id > max) if (list->child && list->child->id > max)
max = list->id; max = list->child->id;
} }
return max; return max;
......
...@@ -1155,6 +1155,7 @@ static const struct of_device_id exynosautov920_cmu_of_match[] = { ...@@ -1155,6 +1155,7 @@ static const struct of_device_id exynosautov920_cmu_of_match[] = {
.compatible = "samsung,exynosautov920-cmu-peric0", .compatible = "samsung,exynosautov920-cmu-peric0",
.data = &peric0_cmu_info, .data = &peric0_cmu_info,
}, },
{ }
}; };
static struct platform_driver exynosautov920_cmu_driver __refdata = { static struct platform_driver exynosautov920_cmu_driver __refdata = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment