From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
patches@lists.linux.dev,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"David Gow" <davidgow@google.com>, "Rae Moar" <rmoar@google.com>,
"Nuno Sá" <nuno.sa@analog.com>
Subject: [PATCH 03/12] clk: test: Introduce clk_put_kunit()
Date: Wed, 14 Aug 2024 17:55:09 -0700 [thread overview]
Message-ID: <20240815005520.1192374-4-sboyd@kernel.org> (raw)
In-Reply-To: <20240815005520.1192374-1-sboyd@kernel.org>
Tests will need to put a clk at a specific point during the test. Add a
clk_put_kunit() function that releases the kunit action created by a
function like clk_get_kunit() so that code is kept tidy.
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Rae Moar <rmoar@google.com>
Cc: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
drivers/clk/clk_kunit_helpers.c | 21 +++++++++++++++++++++
include/kunit/clk.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/drivers/clk/clk_kunit_helpers.c b/drivers/clk/clk_kunit_helpers.c
index 87f97329ae0c..ddb9f2de1083 100644
--- a/drivers/clk/clk_kunit_helpers.c
+++ b/drivers/clk/clk_kunit_helpers.c
@@ -153,6 +153,27 @@ clk_hw_get_clk_prepared_enabled_kunit(struct kunit *test, struct clk_hw *hw,
}
EXPORT_SYMBOL_GPL(clk_hw_get_clk_prepared_enabled_kunit);
+/**
+ * clk_put_kunit() - Force a clk_put() call on a clk managed by the @test
+ * @test: The test context
+ * @clk: Clk consumer to put with clk_put()
+ *
+ * Just like clk_put(), except the clk must be managed by the @test, i.e.
+ * returned from something like clk_get_kunit(). clk_put() will be called
+ * immediately and the deferred action will be removed.
+ *
+ * Return: 0 on success or a negative errno value on failure to find the
+ * deferred action.
+ */
+int clk_put_kunit(struct kunit *test, struct clk *clk)
+{
+ kunit_release_action(test, clk_put_wrapper, clk);
+ /* TODO: Find the action and fail */
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(clk_put_kunit);
+
KUNIT_DEFINE_ACTION_WRAPPER(clk_hw_unregister_wrapper,
clk_hw_unregister, struct clk_hw *);
diff --git a/include/kunit/clk.h b/include/kunit/clk.h
index c513fec8099b..d37fa6b87c2b 100644
--- a/include/kunit/clk.h
+++ b/include/kunit/clk.h
@@ -18,6 +18,7 @@ clk_hw_get_clk_kunit(struct kunit *test, struct clk_hw *hw, const char *con_id);
struct clk *
clk_hw_get_clk_prepared_enabled_kunit(struct kunit *test, struct clk_hw *hw,
const char *con_id);
+int clk_put_kunit(struct kunit *test, struct clk *clk);
int clk_prepare_enable_kunit(struct kunit *test, struct clk *clk);
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
next prev parent reply other threads:[~2024-08-15 0:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 0:55 [PATCH 00/12] clk: Unit test clk unregistration paths Stephen Boyd
2024-08-15 0:55 ` [PATCH 01/12] clk: Fix clk not being unlinked from consumers list Stephen Boyd
2024-08-15 0:55 ` [PATCH 02/12] clk: test: Introduce clk_hw_unregister_kunit() Stephen Boyd
2024-08-15 0:55 ` Stephen Boyd [this message]
2024-08-15 0:55 ` [PATCH 04/12] clk: Add tests for unregistering clk_hw and using consumer APIs Stephen Boyd
2024-08-15 0:55 ` [PATCH 05/12] clk: Fail phase APIs after clk_hw is unregistered Stephen Boyd
2024-08-15 0:55 ` [PATCH 06/12] clk: Test clk_get_phase() behavior " Stephen Boyd
2024-08-15 0:55 ` [PATCH 07/12] clk: Fail duty cycle APIs " Stephen Boyd
2024-08-15 0:55 ` [PATCH 08/12] clk: Test clk_set_duty_cycle() behavior " Stephen Boyd
2024-08-15 0:55 ` [PATCH 09/12] clk: Prevent unregistered clk_hw from being reinserted into clk tree Stephen Boyd
2024-08-15 0:55 ` [PATCH 10/12] clk: Test clk_set_parent() behavior after clk_hw is unregistered Stephen Boyd
2024-08-15 0:55 ` [PATCH 11/12] clk: Test parent/clk flags combos while unregistering a clk_hw Stephen Boyd
2024-08-15 0:55 ` [PATCH 12/12] WIP: clk: Test behavior of children clks after a parent is unregistered Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240815005520.1192374-4-sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=brendan.higgins@linux.dev \
--cc=davidgow@google.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nuno.sa@analog.com \
--cc=patches@lists.linux.dev \
--cc=rmoar@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox