Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1248717

Re: [PATCH] clk: Make of_clk_get_parent_name() robust with #clock-cells = 1

From Michael Turquette <mturquette@baylibre.com>
Newsgroups linux.kernel
Subject Re: [PATCH] clk: Make of_clk_get_parent_name() robust with #clock-cells = 1
Date 2015-10-16 15:00 +0200
Message-ID <qkcM2-6LS-11@gated-at.bofh.it> (permalink)
References <qjWQW-880-25@gated-at.bofh.it> <qk08a-4Qv-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Cc'ing Geert.

Quoting Stephen Boyd (2015-10-15 16:19:38)
> If a clock provider has #clock-cells = 1 and we call
> of_clk_get_parent_name() on it we may end up returning the name
> of the provider node if the provider doesn't have a
> clock-output-names property. This doesn't make sense, especially
> when you consider that calling of_clk_get_parent_name() on such a
> node with different indices will return the same name each time.
> 
> Let's try getting the clock from the framework via of_clk_get()
> instead, and only fallback to the node name if we have a provider
> with #clock-cells = 0. This way, we can't hand out the same name
> for different clocks when we don't actually know their names.
> 
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Geert,

Does this approach fix the issues you had removing clock-output-names
from your clock provider DTS?

Regards,
Mike

> ---
>  drivers/clk/clk.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index b005f666e3a1..a0fe9ca1f0af 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3055,6 +3055,7 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
>         u32 pv;
>         int rc;
>         int count;
> +       struct clk *clk;
>  
>         if (index < 0)
>                 return NULL;
> @@ -3080,8 +3081,25 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
>  
>         if (of_property_read_string_index(clkspec.np, "clock-output-names",
>                                           index,
> -                                         &clk_name) < 0)
> -               clk_name = clkspec.np->name;
> +                                         &clk_name) < 0) {
> +               /*
> +                * Best effort to get the name if the clock has been
> +                * registered with the framework. If the clock isn't
> +                * registered, we return the node name as the name of
> +                * the clock as long as #clock-cells = 0.
> +                */
> +               clk = of_clk_get_from_provider(&clkspec);
> +               if (IS_ERR(clk)) {
> +                       if (clkspec.args_count == 0)
> +                               clk_name = clkspec.np->name;
> +                       else
> +                               clk_name = NULL;
> +               } else {
> +                       clk_name = __clk_get_name(clk);
> +                       clk_put(clk);
> +               }
> +       }
> +
>  
>         of_node_put(clkspec.np);
>         return clk_name;
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2015-10-14 17:10 +0200
  Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Stephen Boyd <sboyd@codeaurora.org> - 2015-10-14 20:30 +0200
    Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2015-10-14 22:20 +0200
      Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Stephen Boyd <sboyd@codeaurora.org> - 2015-10-14 23:10 +0200
        Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2015-10-15 10:50 +0200
          Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Stephen Boyd <sboyd@codeaurora.org> - 2015-10-15 20:10 +0200
            Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2015-10-15 22:00 +0200
              [PATCH] clk: Make of_clk_get_parent_name() robust with #clock-cells = 1 Stephen Boyd <sboyd@codeaurora.org> - 2015-10-16 01:30 +0200
                Re: [PATCH] clk: Make of_clk_get_parent_name() robust with #clock-cells = 1 Michael Turquette <mturquette@baylibre.com> - 2015-10-16 15:00 +0200
                Re: [PATCH] clk: Make of_clk_get_parent_name() robust with  #clock-cells = 1 Geert Uytterhoeven <geert@linux-m68k.org> - 2015-10-16 15:10 +0200
    Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2015-10-15 10:30 +0200
      Re: [PATCH 14/26] clk: mvebu: Convert to clk_hw based provider APIs Stephen Boyd <sboyd@codeaurora.org> - 2015-10-15 20:10 +0200

csiph-web