[PATCH v5 3/7] clk: tests: Add Kunit testing for of_clk_get_parent_name()

"Miquel Raynal (Schneider Electric)" <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.kernel.vger.linux-clk,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <20260807-schneider-v7-2-rc1-eip201-upstream-v5-3-8785f9531cf0@bootlin.com>
Ensure this helper remains correct before making upcoming changes to it.

Signed-off-by: Miquel Raynal (Schneider Electric) <[email protected]>
Reviewed-by: Brian Masney <[email protected]>
Reviewed-by: Frank Li <[email protected]>
---
 drivers/clk/clk_test.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c
index f47f81b7d72a..4084559e157d 100644
--- a/drivers/clk/clk_test.c
+++ b/drivers/clk/clk_test.c
@@ -3637,9 +3637,23 @@ static void clk_parse_clkspec_with_incorrect_index_and_name(struct kunit *test)
 	KUNIT_EXPECT_TRUE(test, IS_ERR(hw));
 }
 
+/*
+ * Verify that of_clk_get_parent_name() returns the correct clock name when
+ * looking up by index through the consumer's clocks property.
+ */
+static void of_clk_get_parent_name_gets_parent_name(struct kunit *test)
+{
+	struct clk_parse_clkspec_ctx *ctx = test->priv;
+	const char *expected_name = "clk_parse_clkspec_1";
+
+	KUNIT_EXPECT_STREQ(test, expected_name,
+			   of_clk_get_parent_name(ctx->cons_np, 0));
+}
+
 static struct kunit_case clk_parse_clkspec_test_cases[] = {
 	KUNIT_CASE(clk_parse_clkspec_with_correct_index_and_name),
 	KUNIT_CASE(clk_parse_clkspec_with_incorrect_index_and_name),
+	KUNIT_CASE(of_clk_get_parent_name_gets_parent_name),
 	{}
 };
 

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.