All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Turquette <mturquette@baylibre.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-gpio@vger.kernel.org, Chen-Yu Tsai <wens@csie.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	linux-tegra@vger.kernel.org,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	linux-clk <linux-clk@vger.kernel.org>,
	"Stephen Boyd <sboyd@codeaurora.org>,
	Emilio Lopez <emilio@elopez.com.ar>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-clk <linux-clk@vger.kernel.org>,
	linux-arm-kernel" <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/3] soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of open coding
Date: Sun, 18 Feb 2018 11:09:25 -0800	[thread overview]
Message-ID: <CAEG3pNCioW_FVXj3-j4KC_yO6ZYGXQB_eanHWSb9NUE9kYsWag@mail.gmail.com> (raw)
In-Reply-To: <11171053.oOJPuGlHoK@phil>

Heiko, Geert,

On Sat, Feb 10, 2018 at 8:35 AM, Heiko Stuebner <heiko@sntech.de> wrote:
> Hi Geert,
>
> Am Freitag, 19. Januar 2018, 16:18:20 CET schrieb Geert Uytterhoeven:
>> As of_clk_get_parent_count() returns zero on failure, while
>> of_count_phandle_with_args() might return a negative error code, this
>> also fixes the issue of possibly using a negative number in the
>> allocation below.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>>  drivers/soc/rockchip/pm_domains.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
>> index 5c342167b9db7a16..9936038d38771784 100644
>> --- a/drivers/soc/rockchip/pm_domains.c
>> +++ b/drivers/soc/rockchip/pm_domains.c
>> @@ -16,6 +16,7 @@
>>  #include <linux/of_address.h>
>>  #include <linux/of_platform.h>
>>  #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>
> not wanting to be to nitpicky, but clk-provider.h seems that it should be
> used from drivers exposing clocks to the system, not from clock users.
>
> I just remember that in the past clk maintainers tried to keep their
> layering intact, so I've included them for clarification.
>
> Mike, Stephen: the power-domain driver of Rockchip socs needs
> to toggle all clocks of domain peripherals when turning a domain
> on or off, so has a variable list of clocks in the clocks property in dt.
> Hence the of_count_... call which could be replaced with
> of_clk_get_parent_count to not open-code this.

Moving of_clk_get_parent_count to clk.h seems reasonable to me. It's
more of an of-specific helper than a provider-specific helper.

Anyone up to submit a patch so that this one doesn't need to include
clk-provider.h?

Regards,
Mike

>
>
> Heiko
>
>>  #include <linux/regmap.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <dt-bindings/power/rk3288-power.h>
>> @@ -391,7 +392,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>>               return -EINVAL;
>>       }
>>
>> -     clk_cnt = of_count_phandle_with_args(node, "clocks", "#clock-cells");
>> +     clk_cnt = of_clk_get_parent_count(node);
>>       pd = devm_kzalloc(pmu->dev,
>>                         sizeof(*pd) + clk_cnt * sizeof(pd->clks[0]),
>>                         GFP_KERNEL);
>>
>
>



-- 
Michael Turquette
CEO
BayLibre - At the Heart of Embedded Linux
http://baylibre.com/

WARNING: multiple messages have this Message-ID (diff)
From: Michael Turquette <mturquette@baylibre.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"Stephen Boyd <sboyd@codeaurora.org>,
	Emilio Lopez <emilio@elopez.com.ar>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-clk <linux-clk@vger.kernel.org>,
	linux-arm-kernel" <linux-arm-kernel@lists.infradead.org>,
	linux-gpio@vger.kernel.org,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	linux-tegra@vger.kernel.org,
	linux-clk <linux-clk@vger.kernel.org>
Subject: Re: [PATCH 2/3] soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of open coding
Date: Sun, 18 Feb 2018 11:09:25 -0800	[thread overview]
Message-ID: <CAEG3pNCioW_FVXj3-j4KC_yO6ZYGXQB_eanHWSb9NUE9kYsWag@mail.gmail.com> (raw)
In-Reply-To: <11171053.oOJPuGlHoK@phil>

Heiko, Geert,

On Sat, Feb 10, 2018 at 8:35 AM, Heiko Stuebner <heiko@sntech.de> wrote:
> Hi Geert,
>
> Am Freitag, 19. Januar 2018, 16:18:20 CET schrieb Geert Uytterhoeven:
>> As of_clk_get_parent_count() returns zero on failure, while
>> of_count_phandle_with_args() might return a negative error code, this
>> also fixes the issue of possibly using a negative number in the
>> allocation below.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>>  drivers/soc/rockchip/pm_domains.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
>> index 5c342167b9db7a16..9936038d38771784 100644
>> --- a/drivers/soc/rockchip/pm_domains.c
>> +++ b/drivers/soc/rockchip/pm_domains.c
>> @@ -16,6 +16,7 @@
>>  #include <linux/of_address.h>
>>  #include <linux/of_platform.h>
>>  #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>
> not wanting to be to nitpicky, but clk-provider.h seems that it should be
> used from drivers exposing clocks to the system, not from clock users.
>
> I just remember that in the past clk maintainers tried to keep their
> layering intact, so I've included them for clarification.
>
> Mike, Stephen: the power-domain driver of Rockchip socs needs
> to toggle all clocks of domain peripherals when turning a domain
> on or off, so has a variable list of clocks in the clocks property in dt.
> Hence the of_count_... call which could be replaced with
> of_clk_get_parent_count to not open-code this.

Moving of_clk_get_parent_count to clk.h seems reasonable to me. It's
more of an of-specific helper than a provider-specific helper.

Anyone up to submit a patch so that this one doesn't need to include
clk-provider.h?

Regards,
Mike

>
>
> Heiko
>
>>  #include <linux/regmap.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <dt-bindings/power/rk3288-power.h>
>> @@ -391,7 +392,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>>               return -EINVAL;
>>       }
>>
>> -     clk_cnt = of_count_phandle_with_args(node, "clocks", "#clock-cells");
>> +     clk_cnt = of_clk_get_parent_count(node);
>>       pd = devm_kzalloc(pmu->dev,
>>                         sizeof(*pd) + clk_cnt * sizeof(pd->clks[0]),
>>                         GFP_KERNEL);
>>
>
>



-- 
Michael Turquette
CEO
BayLibre - At the Heart of Embedded Linux
http://baylibre.com/

WARNING: multiple messages have this Message-ID (diff)
From: mturquette@baylibre.com (Michael Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] soc: rockchip: power-domain: Use of_clk_get_parent_count() instead of open coding
Date: Sun, 18 Feb 2018 11:09:25 -0800	[thread overview]
Message-ID: <CAEG3pNCioW_FVXj3-j4KC_yO6ZYGXQB_eanHWSb9NUE9kYsWag@mail.gmail.com> (raw)
In-Reply-To: <11171053.oOJPuGlHoK@phil>

Heiko, Geert,

On Sat, Feb 10, 2018 at 8:35 AM, Heiko Stuebner <heiko@sntech.de> wrote:
> Hi Geert,
>
> Am Freitag, 19. Januar 2018, 16:18:20 CET schrieb Geert Uytterhoeven:
>> As of_clk_get_parent_count() returns zero on failure, while
>> of_count_phandle_with_args() might return a negative error code, this
>> also fixes the issue of possibly using a negative number in the
>> allocation below.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>>  drivers/soc/rockchip/pm_domains.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
>> index 5c342167b9db7a16..9936038d38771784 100644
>> --- a/drivers/soc/rockchip/pm_domains.c
>> +++ b/drivers/soc/rockchip/pm_domains.c
>> @@ -16,6 +16,7 @@
>>  #include <linux/of_address.h>
>>  #include <linux/of_platform.h>
>>  #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>
> not wanting to be to nitpicky, but clk-provider.h seems that it should be
> used from drivers exposing clocks to the system, not from clock users.
>
> I just remember that in the past clk maintainers tried to keep their
> layering intact, so I've included them for clarification.
>
> Mike, Stephen: the power-domain driver of Rockchip socs needs
> to toggle all clocks of domain peripherals when turning a domain
> on or off, so has a variable list of clocks in the clocks property in dt.
> Hence the of_count_... call which could be replaced with
> of_clk_get_parent_count to not open-code this.

Moving of_clk_get_parent_count to clk.h seems reasonable to me. It's
more of an of-specific helper than a provider-specific helper.

Anyone up to submit a patch so that this one doesn't need to include
clk-provider.h?

Regards,
Mike

>
>
> Heiko
>
>>  #include <linux/regmap.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <dt-bindings/power/rk3288-power.h>
>> @@ -391,7 +392,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>>               return -EINVAL;
>>       }
>>
>> -     clk_cnt = of_count_phandle_with_args(node, "clocks", "#clock-cells");
>> +     clk_cnt = of_clk_get_parent_count(node);
>>       pd = devm_kzalloc(pmu->dev,
>>                         sizeof(*pd) + clk_cnt * sizeof(pd->clks[0]),
>>                         GFP_KERNEL);
>>
>
>



-- 
Michael Turquette
CEO
BayLibre - At the Heart of Embedded Linux
http://baylibre.com/

  reply	other threads:[~2018-02-18 19:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 15:18 [PATCH 0/3] Use of_clk_get_parent_count() instead of open coding Geert Uytterhoeven
2018-01-19 15:18 ` [PATCH 2/3] soc: rockchip: power-domain: " Geert Uytterhoeven
2018-01-19 15:18   ` Geert Uytterhoeven
2018-02-10 16:35   ` Heiko Stuebner
2018-02-10 16:35     ` Heiko Stuebner
2018-02-18 19:09     ` Michael Turquette [this message]
2018-02-18 19:09       ` Michael Turquette
2018-02-18 19:09       ` Michael Turquette
2018-03-02 13:15       ` Geert Uytterhoeven
2018-03-02 13:15         ` Geert Uytterhoeven
2018-03-02 13:15         ` Geert Uytterhoeven
2018-03-12 22:32         ` Stephen Boyd
2018-03-12 22:32           ` Stephen Boyd
2018-03-12 22:32           ` Stephen Boyd
     [not found] ` <1516375101-29836-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2018-01-19 15:18   ` [PATCH 1/3] pinctrl: sunxi: " Geert Uytterhoeven
2018-01-19 15:18     ` Geert Uytterhoeven
2018-01-22  8:55     ` Linus Walleij
2018-01-22  8:55       ` Linus Walleij
2018-01-19 15:18   ` [PATCH 3/3] soc/tegra: pmc: " Geert Uytterhoeven
2018-01-19 15:18     ` Geert Uytterhoeven
2018-01-19 15:18     ` Geert Uytterhoeven

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=CAEG3pNCioW_FVXj3-j4KC_yO6ZYGXQB_eanHWSb9NUE9kYsWag@mail.gmail.com \
    --to=mturquette@baylibre.com \
    --cc=geert+renesas@glider.be \
    --cc=heiko@sntech.de \
    --cc=jonathanh@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=sboyd@codeaurora.org \
    --cc=thierry.reding@gmail.com \
    --cc=wens@csie.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.