[PATCH v7 1/8] clk: test: export clk_dummy_rate_ops and clk_dummy_context() for other tests

From: Brian Masney

Date: Mon Mar 23 2026 - 13:39:14 EST


Expose clk_dummy_rate_ops and clk_dummy_context() so that they can be
used for other clk kunit tests. These will be used for the clk-divider
tests.

This export will be used by the upcoming clk-divider test suite. For
consistency with clk-fixed-rate_test.c and drivers/clk/clk-gate_test.c,
the divider tests will be setup as it's own separate kernel module.

Link: https://lore.kernel.org/linux-clk/aUSWU7UymULCXOeF@xxxxxxxxxx/
Link: https://lpc.events/event/19/contributions/2152/
Signed-off-by: Brian Masney <bmasney@xxxxxxxxxx>
---
drivers/clk/clk_test.c | 9 +++------
include/kunit/clk.h | 7 +++++++
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
index a268d7b5d4cb28ec1f029f828c31107f8e130556..b286297bb902a0c6c8a0469d0f785009416ba9a5 100644
--- a/drivers/clk/clk_test.c
+++ b/drivers/clk/clk_test.c
@@ -15,6 +15,7 @@
#include <kunit/of.h>
#include <kunit/platform_device.h>
#include <kunit/test.h>
+#include <kunit/visibility.h>

#include "kunit_clk_assigned_rates.h"
#include "clk_parent_data_test.h"
@@ -25,11 +26,6 @@ static const struct clk_ops empty_clk_ops = { };
#define DUMMY_CLOCK_RATE_1 (142 * 1000 * 1000)
#define DUMMY_CLOCK_RATE_2 (242 * 1000 * 1000)

-struct clk_dummy_context {
- struct clk_hw hw;
- unsigned long rate;
-};
-
static unsigned long clk_dummy_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
@@ -96,11 +92,12 @@ static u8 clk_dummy_single_get_parent(struct clk_hw *hw)
return 0;
}

-static const struct clk_ops clk_dummy_rate_ops = {
+const struct clk_ops clk_dummy_rate_ops = {
.recalc_rate = clk_dummy_recalc_rate,
.determine_rate = clk_dummy_determine_rate,
.set_rate = clk_dummy_set_rate,
};
+EXPORT_SYMBOL_IF_KUNIT(clk_dummy_rate_ops);

static const struct clk_ops clk_dummy_maximize_rate_ops = {
.recalc_rate = clk_dummy_recalc_rate,
diff --git a/include/kunit/clk.h b/include/kunit/clk.h
index f226044cc78d11564f7adb4cc2450934aab04ce6..b31d9a9055881ac95d3c69f0e5d0728d9fefed88 100644
--- a/include/kunit/clk.h
+++ b/include/kunit/clk.h
@@ -9,6 +9,13 @@ struct device_node;
struct of_phandle_args;
struct kunit;

+struct clk_dummy_context {
+ struct clk_hw hw;
+ unsigned long rate;
+};
+
+extern const struct clk_ops clk_dummy_rate_ops;
+
struct clk *
clk_get_kunit(struct kunit *test, struct device *dev, const char *con_id);
struct clk *

--
2.53.0