* [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML
@ 2022-01-15 20:52 Sean Anderson
2022-01-15 20:52 ` [PATCH v3 1/1] clk: Add clk_get_by_name_optional Sean Anderson
2022-02-25 6:42 ` [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2022-01-15 20:52 UTC (permalink / raw)
To: u-boot
Cc: Dario Binacchi, Simon Glass, Lukasz Majewski, Sean Anderson,
Michal Simek, Neil Armstrong, u-boot-amlogic
This cleans up the various optional helpers for clocks, and adds a new one.
While we're at it, also convert the existing API docs to our HTML documentation.
The rest of this series has been applied, but the former patch 5 had an error,
so I did not apply it. I have fixed it in this revision.
Changes in v3:
- Fix clk_get_by_name_optional recursing
Changes in v2:
- Rebased onto u-boot/master
Sean Anderson (1):
clk: Add clk_get_by_name_optional
drivers/clk/clk_zynq.c | 5 +++--
drivers/rng/meson-rng.c | 4 ++--
include/clk.h | 24 ++++++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/1] clk: Add clk_get_by_name_optional
2022-01-15 20:52 [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
@ 2022-01-15 20:52 ` Sean Anderson
2022-02-25 6:42 ` [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
1 sibling, 0 replies; 3+ messages in thread
From: Sean Anderson @ 2022-01-15 20:52 UTC (permalink / raw)
To: u-boot
Cc: Dario Binacchi, Simon Glass, Lukasz Majewski, Sean Anderson,
Neil Armstrong, Michal Simek, u-boot-amlogic
This adds a helper function for clk_get_by_name in cases where the clock is
optional. Hopefully this helps point driver writers in the right direction.
Also convert some existing users.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Fix clk_get_by_name_optional recursing
drivers/clk/clk_zynq.c | 5 +++--
drivers/rng/meson-rng.c | 4 ++--
include/clk.h | 24 ++++++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/clk_zynq.c b/drivers/clk/clk_zynq.c
index 18915c3e04..e80500e382 100644
--- a/drivers/clk/clk_zynq.c
+++ b/drivers/clk/clk_zynq.c
@@ -472,8 +472,9 @@ static int zynq_clk_probe(struct udevice *dev)
for (i = 0; i < 2; i++) {
sprintf(name, "gem%d_emio_clk", i);
- ret = clk_get_by_name(dev, name, &priv->gem_emio_clk[i]);
- if (ret < 0 && ret != -ENODATA) {
+ ret = clk_get_by_name_optional(dev, name,
+ &priv->gem_emio_clk[i]);
+ if (ret) {
dev_err(dev, "failed to get %s clock\n", name);
return ret;
}
diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
index 5a4f45ad5a..e0a1e8c7e0 100644
--- a/drivers/rng/meson-rng.c
+++ b/drivers/rng/meson-rng.c
@@ -91,8 +91,8 @@ static int meson_rng_of_to_plat(struct udevice *dev)
return -ENODEV;
/* Get optional "core" clock */
- err = clk_get_by_name(dev, "core", &pdata->clk);
- if (err && err != -ENODATA)
+ err = clk_get_by_name_optional(dev, "core", &pdata->clk);
+ if (err)
return err;
return 0;
diff --git a/include/clk.h b/include/clk.h
index 33f448eb89..c30a5dba97 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -292,6 +292,30 @@ static inline int clk_release_all(struct clk *clk, int count)
}
#endif
+/**
+ * clk_get_by_name_optional() - Get/request a optional clock by name.
+ * @dev: The client device.
+ * @name: The name of the clock to request, within the client's list of
+ * clocks.
+ * @clk: A pointer to a clock struct to initialize.
+ *
+ * Behaves the same as clk_get_by_name(), except when there is no clock
+ * provider. In the latter case, return 0.
+ *
+ * Return: 0 if OK, or a negative error code.
+ */
+static inline int clk_get_by_name_optional(struct udevice *dev,
+ const char *name, struct clk *clk)
+{
+ int ret;
+
+ ret = clk_get_by_name(dev, name, clk);
+ if (ret == -ENODATA)
+ return 0;
+
+ return ret;
+}
+
/**
* clk_get_by_name_nodev_optional - Get/request an optinonal clock by name
* without a device.
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML
2022-01-15 20:52 [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
2022-01-15 20:52 ` [PATCH v3 1/1] clk: Add clk_get_by_name_optional Sean Anderson
@ 2022-02-25 6:42 ` Sean Anderson
1 sibling, 0 replies; 3+ messages in thread
From: Sean Anderson @ 2022-02-25 6:42 UTC (permalink / raw)
To: u-boot, Sean Anderson
Cc: Dario Binacchi, u-boot-amlogic, Neil Armstrong, Simon Glass,
Michal Simek, Lukasz Majewski
On Sat, 15 Jan 2022 15:52:46 -0500, Sean Anderson wrote:
> This cleans up the various optional helpers for clocks, and adds a new one.
> While we're at it, also convert the existing API docs to our HTML documentation.
>
> The rest of this series has been applied, but the former patch 5 had an error,
> so I did not apply it. I have fixed it in this revision.
>
> Changes in v3:
> - Fix clk_get_by_name_optional recursing
>
> [...]
Applied, thanks!
[1/1] clk: Add clk_get_by_name_optional
commit: e96e2132f977aab738994c11162b14695029be6e
Best regards,
--
Sean Anderson <seanga2@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-25 6:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-15 20:52 [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
2022-01-15 20:52 ` [PATCH v3 1/1] clk: Add clk_get_by_name_optional Sean Anderson
2022-02-25 6:42 ` [PATCH v3 0/1] clk: Clean up optional helpers, and add API docs to HTML Sean Anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox