From: Leonard Crestez <leonard.crestez@nxp.com>
To: Dong Aisheng <aisheng.dong@nxp.com>, <linux-clk@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <kernel@pengutronix.de>,
<broonie@kernel.org>, <yibin.gong@nxp.com>, <rjw@rjwysocki.net>,
<viresh.kumar@linaro.org>, <mturquette@baylibre.com>,
<sboyd@codeaurora.org>, <shawnguo@kernel.org>,
<fabio.estevam@nxp.com>, <anson.huang@nxp.com>,
<ping.bai@nxp.com>, <octavian.purdila@nxp.com>
Subject: Re: [RFC PATCH 3/3] cpufreq: imx6q: refine clk operations
Date: Tue, 11 Apr 2017 20:48:28 +0300 [thread overview]
Message-ID: <1491932908.31718.33.camel@nxp.com> (raw)
In-Reply-To: <1491969809-20154-4-git-send-email-aisheng.dong@nxp.com>
On Wed, 2017-04-12 at 12:03 +0800, Dong Aisheng wrote:
> +static int num_clks;
> +static struct clk_bulk_data clks[] = {
> + { .id = "arm" },
> + { .id = "pll1_sys" },
> + { .id = "step" },
> + { .id = "pll1_sw" },
> + { .id = "pll2_pfd2_396m" },
> + { .id = "pll2_bus" },
> + { .id = "secondary_sel" },
> +};
The .id is only required for initialization, it seems strange to keep
it around runtime data. It might be better for this API to work with an
array of clk* and separate array of names (or clk_bulk_init_data if we
need flags). Variable references would be shorter and it would allow
more data to be const.
> -put_clk:
> - if (!IS_ERR(arm_clk))
> - clk_put(arm_clk);
> - if (!IS_ERR(pll1_sys_clk))
> - clk_put(pll1_sys_clk);
> - if (!IS_ERR(pll1_sw_clk))
> - clk_put(pll1_sw_clk);
> - if (!IS_ERR(step_clk))
> - clk_put(step_clk);
> - if (!IS_ERR(pll2_pfd2_396m_clk))
> - clk_put(pll2_pfd2_396m_clk);
> - if (!IS_ERR(pll2_bus_clk))
> - clk_put(pll2_bus_clk);
> - if (!IS_ERR(secondary_sel_clk))
> - clk_put(secondary_sel_clk);
> +
> + clk_bulk_put(num_clks, clks);
> +put_node:
> of_node_put(np);
> +
> return ret;
> }
My subjective opinion is that a better way to clean this up would be to
have a single imx6q_cpufreq_clean function that takes all resources and
does stuff like:
if (!IS_ERR(clk)) clk_put(clk);
clk = NULL;
That function can be called from both _remove and failed _probe without
having to keep track of which resources have been allocated until then.
Just free and NULL all clocks/regulators and simplify control flow.
--
Regards,
Leonard
WARNING: multiple messages have this Message-ID (diff)
From: leonard.crestez@nxp.com (Leonard Crestez)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/3] cpufreq: imx6q: refine clk operations
Date: Tue, 11 Apr 2017 20:48:28 +0300 [thread overview]
Message-ID: <1491932908.31718.33.camel@nxp.com> (raw)
In-Reply-To: <1491969809-20154-4-git-send-email-aisheng.dong@nxp.com>
On Wed, 2017-04-12 at 12:03 +0800, Dong Aisheng wrote:
> +static int num_clks;
> +static struct clk_bulk_data clks[] = {
> + { .id = "arm" },
> + { .id = "pll1_sys" },
> + { .id = "step" },
> + { .id = "pll1_sw" },
> + { .id = "pll2_pfd2_396m" },
> + { .id = "pll2_bus" },
> + { .id = "secondary_sel" },
> +};
The .id is only required for initialization, it seems strange to keep
it around runtime data. It might be better for this API to work with an
array of clk* and separate array of names (or clk_bulk_init_data if we
need flags). Variable references would be shorter and it would allow
more data to be const.
> -put_clk:
> - if (!IS_ERR(arm_clk))
> - clk_put(arm_clk);
> - if (!IS_ERR(pll1_sys_clk))
> - clk_put(pll1_sys_clk);
> - if (!IS_ERR(pll1_sw_clk))
> - clk_put(pll1_sw_clk);
> - if (!IS_ERR(step_clk))
> - clk_put(step_clk);
> - if (!IS_ERR(pll2_pfd2_396m_clk))
> - clk_put(pll2_pfd2_396m_clk);
> - if (!IS_ERR(pll2_bus_clk))
> - clk_put(pll2_bus_clk);
> - if (!IS_ERR(secondary_sel_clk))
> - clk_put(secondary_sel_clk);
> +
> + clk_bulk_put(num_clks, clks);
> +put_node:
> ? of_node_put(np);
> +
> ? return ret;
> ?}
My subjective opinion is that a better way to clean this up would be to
have a single imx6q_cpufreq_clean function that takes all resources and
does stuff like:
if (!IS_ERR(clk)) clk_put(clk);
clk = NULL;
That function can be called from both _remove and failed _probe without
having to keep track of which resources have been allocated until then.
Just free and NULL all clocks/regulators and simplify control flow.
--
Regards,
Leonard
next prev parent reply other threads:[~2017-04-11 17:48 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 4:03 [RFC PATCH 0/3] clk: introduce clk_bulk_get accessories Dong Aisheng
2017-04-12 4:03 ` Dong Aisheng
2017-04-11 17:01 ` Florian Fainelli
2017-04-11 17:01 ` Florian Fainelli
2017-04-13 13:58 ` Dong Aisheng
2017-04-13 13:58 ` Dong Aisheng
2017-04-12 4:03 ` [RFC PATCH 1/3] clk: add " Dong Aisheng
2017-04-12 4:03 ` Dong Aisheng
2017-04-11 17:19 ` Leonard Crestez
2017-04-11 17:19 ` Leonard Crestez
2017-04-13 14:02 ` Dong Aisheng
2017-04-13 14:02 ` Dong Aisheng
2017-04-13 19:57 ` Geert Uytterhoeven
2017-04-13 19:57 ` Geert Uytterhoeven
2017-04-13 14:25 ` Dong Aisheng
2017-04-13 14:25 ` Dong Aisheng
2017-04-13 19:56 ` Geert Uytterhoeven
2017-04-13 19:56 ` Geert Uytterhoeven
2017-04-14 16:14 ` Dong Aisheng
2017-04-14 16:14 ` Dong Aisheng
2017-04-22 3:16 ` Stephen Boyd
2017-04-22 3:16 ` Stephen Boyd
2017-05-08 11:34 ` Dong Aisheng
2017-05-08 11:34 ` Dong Aisheng
2017-04-12 4:03 ` [RFC PATCH 2/3] clk: add managed version of clk_bulk_get Dong Aisheng
2017-04-12 4:03 ` Dong Aisheng
2017-04-13 14:37 ` Dong Aisheng
2017-04-13 14:37 ` Dong Aisheng
2017-04-22 2:58 ` Stephen Boyd
2017-04-22 2:58 ` Stephen Boyd
2017-05-08 11:41 ` Dong Aisheng
2017-05-08 11:41 ` Dong Aisheng
2017-04-22 2:55 ` Stephen Boyd
2017-04-22 2:55 ` Stephen Boyd
2017-05-08 11:37 ` Dong Aisheng
2017-05-08 11:37 ` Dong Aisheng
2017-04-12 4:03 ` [RFC PATCH 3/3] cpufreq: imx6q: refine clk operations Dong Aisheng
2017-04-12 4:03 ` Dong Aisheng
2017-04-11 17:48 ` Leonard Crestez [this message]
2017-04-11 17:48 ` Leonard Crestez
2017-04-13 14:21 ` Dong Aisheng
2017-04-13 14:21 ` Dong Aisheng
2017-04-22 3:04 ` [RFC PATCH 0/3] clk: introduce clk_bulk_get accessories Stephen Boyd
2017-04-22 3:04 ` Stephen Boyd
2017-05-08 11:07 ` Dong Aisheng
2017-05-08 11:07 ` Dong Aisheng
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=1491932908.31718.33.camel@nxp.com \
--to=leonard.crestez@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=anson.huang@nxp.com \
--cc=broonie@kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=octavian.purdila@nxp.com \
--cc=ping.bai@nxp.com \
--cc=rjw@rjwysocki.net \
--cc=sboyd@codeaurora.org \
--cc=shawnguo@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=yibin.gong@nxp.com \
/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.