diff options
author | Stephen Boyd <sboyd@kernel.org> | 2024-08-22 02:24:28 +0200 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2024-10-10 01:25:32 +0200 |
commit | a82fcb16d977fa8ac52bdf37d5feb240366722ed (patch) | |
tree | 93dffada4305537b18556c55dfdf9deaa0002f5d /drivers/clk/clk_kunit_helpers.c | |
parent | Linux 6.12-rc1 (diff) | |
download | linux-a82fcb16d977fa8ac52bdf37d5feb240366722ed.tar.xz linux-a82fcb16d977fa8ac52bdf37d5feb240366722ed.zip |
clk: test: Add test managed of_clk_add_hw_provider()
Add a test managed version of of_clk_add_hw_provider() that
automatically unregisters the clk_hw provider upon test conclusion.
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Rae Moar <rmoar@google.com>
Cc: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20240822002433.1163814-2-sboyd@kernel.org
Diffstat (limited to 'drivers/clk/clk_kunit_helpers.c')
-rw-r--r-- | drivers/clk/clk_kunit_helpers.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/clk/clk_kunit_helpers.c b/drivers/clk/clk_kunit_helpers.c index 52fd25594c96..68a28e70bb61 100644 --- a/drivers/clk/clk_kunit_helpers.c +++ b/drivers/clk/clk_kunit_helpers.c @@ -203,5 +203,35 @@ int of_clk_hw_register_kunit(struct kunit *test, struct device_node *node, struc } EXPORT_SYMBOL_GPL(of_clk_hw_register_kunit); +KUNIT_DEFINE_ACTION_WRAPPER(of_clk_del_provider_wrapper, + of_clk_del_provider, struct device_node *); + +/** + * of_clk_add_hw_provider_kunit() - Test managed of_clk_add_hw_provider() + * @test: The test context + * @np: Device node pointer associated with clock provider + * @get: Callback for decoding clk_hw + * @data: Context pointer for @get callback. + * + * Just like of_clk_add_hw_provider(), except the clk_hw provider is managed by + * the test case and is automatically unregistered after the test case + * concludes. + * + * Return: 0 on success or a negative errno value on failure. + */ +int of_clk_add_hw_provider_kunit(struct kunit *test, struct device_node *np, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), + void *data) +{ + int ret; + + ret = of_clk_add_hw_provider(np, get, data); + if (ret) + return ret; + + return kunit_add_action_or_reset(test, of_clk_del_provider_wrapper, np); +} +EXPORT_SYMBOL_GPL(of_clk_add_hw_provider_kunit); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("KUnit helpers for clk providers and consumers"); |