From: Jerome Brunet <jbrunet@baylibre.com>
To: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] clk: add a clk_hw helpers to get the clock device or device_node
Date: Mon, 05 May 2025 11:33:44 +0200 [thread overview]
Message-ID: <1jbjs7mmfb.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20250417-clk-hw-get-helpers-v1-1-7743e509612a@baylibre.com> (Jerome Brunet's message of "Thu, 17 Apr 2025 15:44:22 +0200")
On Thu 17 Apr 2025 at 15:44, Jerome Brunet <jbrunet@baylibre.com> wrote:
> Add helpers to get the device or device_node associated with clk_hw.
>
> This can be used by clock drivers to access various device related
> functionality such as devres, dev_ prints, etc ...
>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
Hello Stephen,
If possible, could you take that change in so can move on with rework
I'm trying do in amlogic clocks, while we refine the test part ? (if
another round is needed for that)
Cheers
> drivers/clk/clk.c | 12 ++++++++++++
> include/linux/clk-provider.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 0565c87656cf5c557d8259c71b5d2971a7ac87e8..b821b2cdb155331c85fafbd2fac8ab3703a08e4d 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -365,6 +365,18 @@ const char *clk_hw_get_name(const struct clk_hw *hw)
> }
> EXPORT_SYMBOL_GPL(clk_hw_get_name);
>
> +struct device *clk_hw_get_dev(const struct clk_hw *hw)
> +{
> + return hw->core->dev;
> +}
> +EXPORT_SYMBOL_GPL(clk_hw_get_dev);
> +
> +struct device_node *clk_hw_get_of_node(const struct clk_hw *hw)
> +{
> + return hw->core->of_node;
> +}
> +EXPORT_SYMBOL_GPL(clk_hw_get_of_node);
> +
> struct clk_hw *__clk_get_hw(struct clk *clk)
> {
> return !clk ? NULL : clk->core->hw;
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index 2e6e603b749342931c0d0693c3e72b62c000791b..630705a47129453c241f1b1755f2c2f2a7ed8f77 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -1360,6 +1360,32 @@ void clk_hw_unregister(struct clk_hw *hw);
> /* helper functions */
> const char *__clk_get_name(const struct clk *clk);
> const char *clk_hw_get_name(const struct clk_hw *hw);
> +
> +/**
> + * clk_hw_get_dev() - get device from an hardware clock.
> + * @hw: the clk_hw pointer to get the struct device from
> + *
> + * This is a helper to get the struct device associated with a hardware
> + * clock. Some clock controllers, such as the one registered with
> + * CLK_OF_DECLARE(), may have not provided a device pointer while
> + * registering the clock.
> + *
> + * Return: the struct device associated with the clock, or NULL if there
> + * is none.
> + */
> +struct device *clk_hw_get_dev(const struct clk_hw *hw);
> +
> +/**
> + * clk_hw_get_of_node() - get device_node from a hardware clock.
> + * @hw: the clk_hw pointer to get the struct device_node from
> + *
> + * This is a helper to get the struct device_node associated with a
> + * hardware clock.
> + *
> + * Return: the struct device_node associated with the clock, or NULL
> + * if there is none.
> + */
> +struct device_node *clk_hw_get_of_node(const struct clk_hw *hw);
> #ifdef CONFIG_COMMON_CLK
> struct clk_hw *__clk_get_hw(struct clk *clk);
> #else
--
Jerome
next prev parent reply other threads:[~2025-05-05 9:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 13:44 [PATCH 0/2] clk: add a clk_hw helpers to get the clock device or device_node Jerome Brunet
2025-04-17 13:44 ` [PATCH 1/2] " Jerome Brunet
2025-05-05 9:33 ` Jerome Brunet [this message]
2025-06-02 16:42 ` Brian Masney
2025-06-20 7:18 ` Stephen Boyd
2025-04-17 13:44 ` [PATCH 2/2] clk: tests: add clk_hw_get_dev() and clk_hw_get_of_node() tests Jerome Brunet
2025-06-02 17:06 ` Brian Masney
2025-06-20 7:18 ` Stephen Boyd
2025-06-02 11:59 ` [PATCH 0/2] clk: add a clk_hw helpers to get the clock device or device_node Jerome Brunet
2025-06-20 7:20 ` Stephen Boyd
2025-06-23 8:34 ` Jerome Brunet
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=1jbjs7mmfb.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox