lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240815005520.1192374-3-sboyd@kernel.org>
Date: Wed, 14 Aug 2024 17:55:08 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: Michael Turquette <mturquette@...libre.com>,
	Stephen Boyd <sboyd@...nel.org>
Cc: linux-kernel@...r.kernel.org,
	linux-clk@...r.kernel.org,
	patches@...ts.linux.dev,
	Brendan Higgins <brendan.higgins@...ux.dev>,
	David Gow <davidgow@...gle.com>,
	Rae Moar <rmoar@...gle.com>,
	Nuno Sá <nuno.sa@...log.com>
Subject: [PATCH 02/12] clk: test: Introduce clk_hw_unregister_kunit()

Tests will need to unregister a clk_hw at a specific point during the
test. Add a clk_hw_unregister_kunit() function that releases the kunit
action created in a function like clk_hw_register_kunit() so that code
is kept tidy.

Cc: Brendan Higgins <brendan.higgins@...ux.dev>
Cc: David Gow <davidgow@...gle.com>
Cc: Rae Moar <rmoar@...gle.com>
Cc: Nuno Sá <nuno.sa@...log.com>
Signed-off-by: Stephen Boyd <sboyd@...nel.org>
---

I need to introduce a kunit_release_action_or_fail() API.

 drivers/clk/clk_kunit_helpers.c | 25 +++++++++++++++++++++++++
 include/kunit/clk.h             |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/clk/clk_kunit_helpers.c b/drivers/clk/clk_kunit_helpers.c
index 52fd25594c96..87f97329ae0c 100644
--- a/drivers/clk/clk_kunit_helpers.c
+++ b/drivers/clk/clk_kunit_helpers.c
@@ -203,5 +203,30 @@ int of_clk_hw_register_kunit(struct kunit *test, struct device_node *node, struc
 }
 EXPORT_SYMBOL_GPL(of_clk_hw_register_kunit);
 
+/**
+ * clk_hw_unregister_kunit() - Force a clk_hw to be unregistered that is
+ * managed by {of_}clk_hw_register_kunit()
+ * @test: The test context
+ * @hw: link to hardware-specific clock data passed to {of_}clk_hw_register_kunit()
+ *
+ * Just like clk_hw_unregister(), except that the clk_hw must have been registered by
+ * a KUnit helper like clk_hw_register_kunit(). This removes the deferred KUnit action
+ * made earlier in the test and unregisters the clk immediately.
+ *
+ * Usually a test will use clk_hw_register_kunit() and let the deferred action
+ * unregister the clk automatically after the test case concludes. This
+ * function can be used to unregister the clk_hw immediately.
+ *
+ * Return: 0 on success or a negative errno value on failure to find the deferred action.
+ */
+int clk_hw_unregister_kunit(struct kunit *test, struct clk_hw *hw)
+{
+	kunit_release_action(test, clk_hw_unregister_wrapper, hw);
+	/* TODO: Find the action and fail */
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(clk_hw_unregister_kunit);
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("KUnit helpers for clk providers and consumers");
diff --git a/include/kunit/clk.h b/include/kunit/clk.h
index 73bc99cefe7b..c513fec8099b 100644
--- a/include/kunit/clk.h
+++ b/include/kunit/clk.h
@@ -24,5 +24,6 @@ int clk_prepare_enable_kunit(struct kunit *test, struct clk *clk);
 int clk_hw_register_kunit(struct kunit *test, struct device *dev, struct clk_hw *hw);
 int of_clk_hw_register_kunit(struct kunit *test, struct device_node *node,
 			     struct clk_hw *hw);
+int clk_hw_unregister_kunit(struct kunit *test, struct clk_hw *hw);
 
 #endif
-- 
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ