mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 01/12] clk: Add clk_name_* functions
Date: Mon, 21 Jun 2021 11:27:51 +0200	[thread overview]
Message-ID: <20210621092802.27275-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20210621092802.27275-1-s.hauer@pengutronix.de>

At some places a clk name may be known without having a struct clk *
directly. Add some convenience functions to handle this situation and
use them in the clk commands.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20210615141641.31577-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/clk.c      | 18 ++----------------
 drivers/clk/clk.c   | 22 ++++++++++++++++++++++
 include/linux/clk.h |  4 ++++
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/commands/clk.c b/commands/clk.c
index 2e21e9df58..4d124807bd 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -54,19 +54,14 @@ BAREBOX_CMD_END
 
 static int do_clk_set_rate(int argc, char *argv[])
 {
-	struct clk *clk;
 	unsigned long rate;
 
 	if (argc != 3)
 		return COMMAND_ERROR_USAGE;
 
-	clk = clk_lookup(argv[1]);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
 	rate = simple_strtoul(argv[2], NULL, 0);
 
-	return clk_set_rate(clk, rate);
+	return clk_name_set_rate(argv[1], rate);
 }
 
 BAREBOX_CMD_HELP_START(clk_set_rate)
@@ -214,19 +209,10 @@ BAREBOX_CMD_END
 
 static int do_clk_set_parent(int argc, char *argv[])
 {
-	struct clk *clk, *parent;
-
 	if (argc != 3)
 		return COMMAND_ERROR_USAGE;
 
-	clk = clk_lookup(argv[1]);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-	parent = clk_lookup(argv[2]);
-	if (IS_ERR(parent))
-		return PTR_ERR(parent);
-
-	return clk_set_parent(clk, parent);
+	return clk_name_set_parent(argv[1], argv[2]);
 }
 
 BAREBOX_CMD_START(clk_set_parent)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ba726c342c..8932cfe54b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -525,6 +525,28 @@ int clk_parent_set_rate(struct clk_hw *hw, unsigned long rate,
 	return clk_set_rate(clk_get_parent(clk), rate);
 }
 
+int clk_name_set_parent(const char *clkname, const char *clkparentname)
+{
+	struct clk *clk = clk_lookup(clkname);
+	struct clk *parent = clk_lookup(clkparentname);
+
+	if (IS_ERR(clk))
+		return -ENOENT;
+	if (IS_ERR(parent))
+		return -ENOENT;
+	return clk_set_parent(clk, parent);
+}
+
+int clk_name_set_rate(const char *clkname, unsigned long rate)
+{
+	struct clk *clk = clk_lookup(clkname);
+
+	if (IS_ERR(clk))
+		return -ENOENT;
+
+	return clk_set_rate(clk, rate);
+}
+
 #if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * struct of_clk_provider - Clock provider registration structure
diff --git a/include/linux/clk.h b/include/linux/clk.h
index e54acdd918..6565429a9b 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -681,6 +681,9 @@ static inline const char *clk_hw_get_name(struct clk_hw *hw)
 	return hw->clk.name;
 }
 
+int clk_name_set_parent(const char *clkname, const char *clkparentname);
+int clk_name_set_rate(const char *clkname, unsigned long rate);
+
 #endif
 
 struct device_node;
@@ -722,6 +725,7 @@ static inline unsigned int clk_get_num_parents(const struct clk *hw)
 {
 	return hw->num_parents;
 }
+
 #else
 
 
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-06-21  9:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21  9:27 [PATCH v2 00/12] Rockchip RK3568 support Sascha Hauer
2021-06-21  9:27 ` Sascha Hauer [this message]
2021-06-21  9:27 ` [PATCH 02/12] clk: rockchip rk3568: Initialize clocks Sascha Hauer
2021-06-21  9:27 ` [PATCH 03/12] filetype: Add Rockchip boot image type Sascha Hauer
2021-06-21  9:27 ` [PATCH 04/12] ARM: Rockchip: Add rkimage tool Sascha Hauer
2021-06-21  9:27 ` [PATCH 05/12] ARM: Add relocate_to_adr_full() Sascha Hauer
2021-06-21  9:27 ` [PATCH 06/12] ARM: Rockchip: Add rk3568 dtsi files Sascha Hauer
2021-06-21  9:27 ` [PATCH 07/12] ARM: Rockchip: Add rk3568 support Sascha Hauer
2021-06-21  9:27 ` [PATCH 08/12] ARM: Add atf common support Sascha Hauer
2021-06-21  9:27 ` [PATCH 09/12] ARM: rockchip: Add bootm handler for RKNS images Sascha Hauer
2021-06-21  9:28 ` [PATCH 10/12] ARM: Rockchip: Add rk3568 evb board support Sascha Hauer
2021-06-21  9:28 ` [PATCH 11/12] Add rockchip_v8_defconfig Sascha Hauer
2021-06-21  9:28 ` [PATCH 12/12] fixup! clk: Rockchip: Add rk3568 clk support Sascha Hauer

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=20210621092802.27275-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox