All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	linux-clk@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1] clk: Move struct clk_core to use struct fwnode_handle
Date: Tue,  9 Feb 2021 19:09:52 +0200	[thread overview]
Message-ID: <20210209170952.49794-1-andriy.shevchenko@linux.intel.com> (raw)

fwnode is an abstraction on the different types of firmware nodes.
In order to allow clocks to be linked with any type of such node,
start a conversion to the struct fwnode_handle instead of being
stuck with struct device_node.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/clk/clk.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 3d751ae5bc70..dd8e11e4312d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -19,6 +19,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/sched.h>
 #include <linux/clkdev.h>
 
@@ -59,7 +60,7 @@ struct clk_core {
 	struct clk_hw		*hw;
 	struct module		*owner;
 	struct device		*dev;
-	struct device_node	*of_node;
+	struct fwnode_handle	*fwnode;
 	struct clk_core		*parent;
 	struct clk_parent_map	*parents;
 	u8			num_parents;
@@ -396,7 +397,7 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index)
 	struct clk_hw *hw = ERR_PTR(-ENOENT);
 	struct device *dev = core->dev;
 	const char *dev_id = dev ? dev_name(dev) : NULL;
-	struct device_node *np = core->of_node;
+	struct device_node *np = to_of_node(core->fwnode);
 	struct of_phandle_args clkspec;
 
 	if (np && (name || index >= 0) &&
@@ -3189,7 +3190,7 @@ static void possible_parent_show(struct seq_file *s, struct clk_core *core,
 		seq_printf(s, "<%s>(fw)", core->parents[i].fw_name);
 	else if (core->parents[i].index >= 0)
 		seq_puts(s,
-			 of_clk_get_parent_name(core->of_node,
+			 of_clk_get_parent_name(to_of_node(core->fwnode),
 						core->parents[i].index));
 	else
 		seq_puts(s, "(missing)");
@@ -3814,7 +3815,7 @@ static void clk_core_free_parent_map(struct clk_core *core)
 }
 
 static struct clk *
-__clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
+__clk_register(struct device *dev, struct fwnode_handle *fwnode, struct clk_hw *hw)
 {
 	int ret;
 	struct clk_core *core;
@@ -3848,7 +3849,7 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
 	if (dev && pm_runtime_enabled(dev))
 		core->rpm_enabled = true;
 	core->dev = dev;
-	core->of_node = np;
+	core->fwnode = fwnode;
 	if (dev && dev->driver)
 		core->owner = dev->driver->owner;
 	core->hw = hw;
@@ -3906,18 +3907,18 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
  * @dev->parent if dev doesn't have a device node, or NULL if neither
  * @dev or @dev->parent have a device node.
  */
-static struct device_node *dev_or_parent_of_node(struct device *dev)
+static struct fwnode_handle *dev_or_parent_fwnode(struct device *dev)
 {
-	struct device_node *np;
+	struct fwnode_handle *fwnode;
 
 	if (!dev)
 		return NULL;
 
-	np = dev_of_node(dev);
-	if (!np)
-		np = dev_of_node(dev->parent);
+	fwnode = dev_fwnode(dev);
+	if (!fwnode)
+		fwnode = dev_fwnode(dev->parent);
 
-	return np;
+	return fwnode;
 }
 
 /**
@@ -3935,7 +3936,7 @@ static struct device_node *dev_or_parent_of_node(struct device *dev)
  */
 struct clk *clk_register(struct device *dev, struct clk_hw *hw)
 {
-	return __clk_register(dev, dev_or_parent_of_node(dev), hw);
+	return __clk_register(dev, dev_or_parent_fwnode(dev), hw);
 }
 EXPORT_SYMBOL_GPL(clk_register);
 
@@ -3951,8 +3952,7 @@ EXPORT_SYMBOL_GPL(clk_register);
  */
 int clk_hw_register(struct device *dev, struct clk_hw *hw)
 {
-	return PTR_ERR_OR_ZERO(__clk_register(dev, dev_or_parent_of_node(dev),
-			       hw));
+	return PTR_ERR_OR_ZERO(__clk_register(dev, dev_or_parent_fwnode(dev), hw));
 }
 EXPORT_SYMBOL_GPL(clk_hw_register);
 
@@ -3969,7 +3969,7 @@ EXPORT_SYMBOL_GPL(clk_hw_register);
  */
 int of_clk_hw_register(struct device_node *node, struct clk_hw *hw)
 {
-	return PTR_ERR_OR_ZERO(__clk_register(NULL, node, hw));
+	return PTR_ERR_OR_ZERO(__clk_register(NULL, of_fwnode_handle(node), hw));
 }
 EXPORT_SYMBOL_GPL(of_clk_hw_register);
 
-- 
2.30.0


             reply	other threads:[~2021-02-09 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 17:09 Andy Shevchenko [this message]
2021-02-09 23:59 ` [PATCH v1] clk: Move struct clk_core to use struct fwnode_handle Stephen Boyd
2021-02-10 11:01   ` Andy Shevchenko
2021-02-11  2:25     ` Stephen Boyd
2021-02-11 10:37       ` Andy Shevchenko
2021-02-11 19:09         ` 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=20210209170952.49794-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.