mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/7] clk: add compatibility for prepare/unprepare/is_prepared
@ 2025-04-22  7:56 Ahmad Fatoum
  2025-04-22  7:56 ` [PATCH 2/7] clk: mux: replace width member with mask as in Linux Ahmad Fatoum
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2025-04-22  7:56 UTC (permalink / raw)
  To: barebox

From: Ahmad Fatoum <a.fatoum@barebox.org>

Instead of having to mechanically rename prepare/unprepare operations to
enable/disable, let's just alias them in a union.

This risks code porters missing to merge both operations when they
exist, but this can be fixed via enforcing -Woverride-init as default
warning, which will be added separately.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 include/linux/clk.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index b10af93af429..6bedc5204cca 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -269,12 +269,18 @@ static inline void clk_put(struct clk *clk)
  * @enable:	Prepare and enable the clock atomically. This must not return
  *		until the clock is generating a valid clock signal, usable by
  *		consumer devices.
+ * @prepare:	Alias for @enable. If the Linux driver defines both, they
+ *		must be merged when ported to barebox.
  *
  * @disable:	Unprepare and disable the clock atomically.
+ * @unprepare:	Alias for @disable. If the Linux driver defines both, they
+ *		must be merged when ported to barebox.
  *
  * @is_enabled:	Queries the hardware to determine if the clock is enabled.
  *		Optional, if this op is not set then the enable count will be
  *		used.
+ * @is_prepared Alias for @is_enabled. If the Linux driver defines both, they
+ *		must be merged when ported to barebox.
  *
  * @recalc_rate	Recalculate the rate of this clock, by querying hardware. The
  *		parent rate is an input parameter. If the driver cannot figure
@@ -319,9 +325,18 @@ static inline void clk_put(struct clk *clk)
  */
 struct clk_ops {
 	int 		(*init)(struct clk_hw *hw);
-	int		(*enable)(struct clk_hw *hw);
-	void		(*disable)(struct clk_hw *hw);
-	int		(*is_enabled)(struct clk_hw *hw);
+	union {
+		int		(*enable)(struct clk_hw *hw);
+		int		(*prepare)(struct clk_hw *hw);
+	};
+	union {
+		void		(*disable)(struct clk_hw *hw);
+		void		(*unprepare)(struct clk_hw *hw);
+	};
+	union {
+		int		(*is_enabled)(struct clk_hw *hw);
+		int		(*is_prepared)(struct clk_hw *hw);
+	};
 	unsigned long	(*recalc_rate)(struct clk_hw *hw,
 					unsigned long parent_rate);
 	long		(*round_rate)(struct clk_hw *hw, unsigned long,
-- 
2.39.5




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-04-22 10:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-22  7:56 [PATCH 1/7] clk: add compatibility for prepare/unprepare/is_prepared Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 2/7] clk: mux: replace width member with mask as in Linux Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 3/7] clk: mux: fix mask/width confusion in clk_hw_register_mux Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 4/7] clk: gate: underscore-prefix barebox-specific parent member Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 5/7] clk: gate: add bit_idx member as in Linux Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 6/7] clk: composite: change mux/rate/gate members to clk_hw Ahmad Fatoum
2025-04-22  7:56 ` [PATCH 7/7] clk: move struct clk_composite definition to header Ahmad Fatoum
2025-04-22  9:18 ` [PATCH 1/7] clk: add compatibility for prepare/unprepare/is_prepared Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox