linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Protsenko <semen.protsenko@linaro.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
	Mike Tipton <mdtipton@codeaurora.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>
Cc: linux-clk <linux-clk@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] clk: Add clk_set_parent debugfs node
Date: Tue, 5 Oct 2021 13:11:00 +0300	[thread overview]
Message-ID: <CAPLW+4mhr4pJAUyGNpfWDnxgTsJ7-fj0hw=ehV8YkqRmaBSnag@mail.gmail.com> (raw)
In-Reply-To: <20210914141939.26410-1-semen.protsenko@linaro.org>

On Tue, 14 Sept 2021 at 17:19, Sam Protsenko <semen.protsenko@linaro.org> wrote:
>
> Useful for testing mux clocks. One can write the index of the parent to
> set into clk_set_parent node, starting from 0. Example
>
>     # cat clk_possible_parrents
>       dout_shared0_div4 dout_shared1_div4
>     # cat clk_parent
>       dout_shared0_div4
>     # echo 1 > clk_set_parent
>     # cat clk_parent
>       dout_shared1_div4
>
> Define CLOCK_ALLOW_WRITE_DEBUGFS in drivers/clk/clk.c in order to use
> this feature.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---

+ Adding more folks for review

Guys, can you please review this one?

>  drivers/clk/clk.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 65508eb89ec9..3e5456580db9 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3214,6 +3214,30 @@ static int current_parent_show(struct seq_file *s, void *data)
>  }
>  DEFINE_SHOW_ATTRIBUTE(current_parent);
>
> +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS
> +static int clk_set_parent_set(void *data, u64 val)
> +{
> +       struct clk_core *core = data, *parent;
> +       int ret;
> +
> +       if (val >= core->num_parents)
> +               return -EINVAL;
> +
> +       parent = clk_core_get_parent_by_index(core, val);
> +       if (IS_ERR_OR_NULL(parent))
> +               return PTR_ERR(parent);
> +
> +       clk_prepare_lock();
> +       ret = clk_core_set_parent_nolock(core, parent);
> +       clk_prepare_unlock();
> +
> +       return ret;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(clk_set_parent_fops, NULL, clk_set_parent_set,
> +                        "%llu\n");
> +#endif
> +
>  static int clk_duty_cycle_show(struct seq_file *s, void *data)
>  {
>         struct clk_core *core = s->private;
> @@ -3285,9 +3309,14 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>                 debugfs_create_file("clk_parent", 0444, root, core,
>                                     &current_parent_fops);
>
> -       if (core->num_parents > 1)
> +       if (core->num_parents > 1) {
>                 debugfs_create_file("clk_possible_parents", 0444, root, core,
>                                     &possible_parents_fops);
> +#ifdef CLOCK_ALLOW_WRITE_DEBUGFS
> +               debugfs_create_file("clk_set_parent", 0200, root, core,
> +                                   &clk_set_parent_fops);
> +#endif
> +       }
>
>         if (core->ops->debug_init)
>                 core->ops->debug_init(core->hw, core->dentry);
> --
> 2.30.2
>

  reply	other threads:[~2021-10-05 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 14:19 [PATCH] clk: Add clk_set_parent debugfs node Sam Protsenko
2021-10-05 10:11 ` Sam Protsenko [this message]
2021-10-05 10:43   ` Geert Uytterhoeven
2021-10-07 13:39     ` Sam Protsenko

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='CAPLW+4mhr4pJAUyGNpfWDnxgTsJ7-fj0hw=ehV8YkqRmaBSnag@mail.gmail.com' \
    --to=semen.protsenko@linaro.org \
    --cc=cw00.choi@samsung.com \
    --cc=geert+renesas@glider.be \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdtipton@codeaurora.org \
    --cc=mturquette@baylibre.com \
    --cc=s.nawrocki@samsung.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;
as well as URLs for NNTP newsgroup(s).