[PATCH 1/2] clk: move clk_get_ops() to a common header

Yang Xiwen via B4 Relay devnull+forbidden405.outlook.com at kernel.org
Sun Jul 23 23:16:54 CEST 2023


From: Yang Xiwen <forbidden405 at outlook.com>

This allows it to be used by other source files.

Signed-off-by: Yang Xiwen <forbidden405 at outlook.com>
---
 drivers/clk/clk-uclass.c |  5 -----
 include/clk.h            | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index dc3e9d6a26..5cc80e5e39 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -25,11 +25,6 @@
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 
-static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
-{
-	return (const struct clk_ops *)dev->driver->ops;
-}
-
 struct clk *dev_get_clk_ptr(struct udevice *dev)
 {
 	return (struct clk *)dev_get_uclass_priv(dev);
diff --git a/include/clk.h b/include/clk.h
index d91285235f..bd3617e1e0 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -8,6 +8,7 @@
 #ifndef _CLK_H_
 #define _CLK_H_
 
+#include <dm/device.h>
 #include <dm/ofnode.h>
 #include <linux/err.h>
 #include <linux/errno.h>
@@ -258,6 +259,17 @@ int clk_release_all(struct clk *clk, int count);
  */
 void devm_clk_put(struct udevice *dev, struct clk *clk);
 
+/**
+ * clk_dev_ops - get ops of a clock
+ * @dev: clock device
+ *
+ * Return: ops of the clk
+ */
+static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
+{
+	return (const struct clk_ops *)dev->driver->ops;
+}
+
 #else
 
 static inline int clk_get_by_phandle(struct udevice *dev, const
@@ -315,6 +327,11 @@ static inline int clk_release_all(struct clk *clk, int count)
 static inline void devm_clk_put(struct udevice *dev, struct clk *clk)
 {
 }
+
+static inline const struct clk_ops *clk_dev_ops(struct udevice *dev)
+{
+	return ERR_PTR(-ENOSYS);
+}
 #endif
 
 /**

-- 
2.34.1



More information about the U-Boot mailing list