From: Bryan O'Donoghue <pure.logic@nexus-software.ie>
To: mturquette@baylibre.com, sboyd@codeaurora.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org
Cc: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Subject: [PATCH v3 34/34] clk: change handling of round_rate() such that only zero is an error
Date: Mon, 1 Jan 2018 19:43:13 +0000 [thread overview]
Message-ID: <1514835793-1104-35-git-send-email-pure.logic@nexus-software.ie> (raw)
In-Reply-To: <1514835793-1104-1-git-send-email-pure.logic@nexus-software.ie>
Change the handling of clk_ops->round_rate() return values such that only
zero is treated as an error. All implementations of clk_ops->round_rate()
will have previously been updated to match this change.
Using zero as the determinant for an error means its possible to pass an
unsigned long as req->rate to a clk_ops->round_rate() function and return a
rounded clock which is as high as the original req->rate. This allows us on
32 bit systems to return rounded rates of (2^32)-1 Hz or ULONG_MAX Hz -
whereas without this change and the associated clk_ops->round_rate() change
the maximum value that can be returned via clk_ops->round_rate() is
LONG_MAX Hz - after which a higher-frequency clock looks like a negative
error code - due to sign extension.
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/clk/clk.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 8a1860a..6af2ece 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -909,7 +909,6 @@ static int clk_core_round_rate_nolock(struct clk_core *core,
struct clk_rate_request *req)
{
struct clk_core *parent;
- long rate;
lockdep_assert_held(&prepare_lock);
@@ -928,12 +927,8 @@ static int clk_core_round_rate_nolock(struct clk_core *core,
if (core->ops->determine_rate) {
return core->ops->determine_rate(core->hw, req);
} else if (core->ops->round_rate) {
- rate = core->ops->round_rate(core->hw, req->rate,
+ req->rate = core->ops->round_rate(core->hw, req->rate,
&req->best_parent_rate);
- if (rate < 0)
- return rate;
-
- req->rate = rate;
} else if (core->flags & CLK_SET_RATE_PARENT) {
return clk_core_round_rate_nolock(parent, req);
} else {
@@ -1454,12 +1449,8 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core,
new_rate = req.rate;
parent = req.best_parent_hw ? req.best_parent_hw->core : NULL;
} else if (core->ops->round_rate) {
- ret = core->ops->round_rate(core->hw, rate,
- &best_parent_rate);
- if (ret < 0)
- return NULL;
-
- new_rate = ret;
+ new_rate = core->ops->round_rate(core->hw, rate,
+ &best_parent_rate);
if (new_rate < min_rate || new_rate > max_rate)
return NULL;
} else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) {
--
2.7.4
prev parent reply other threads:[~2018-01-01 19:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-01 19:42 [PATCH v3 00/34] change clk_ops->round_rate to scale past LONG_MAX Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 01/34] clk_ops: change round_rate() to return unsigned long Bryan O'Donoghue
2018-01-03 10:07 ` Mauro Carvalho Chehab
2018-01-01 19:42 ` [PATCH v3 02/34] clk: core: update divider_round_rate functions " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 03/34] clk: composite: allow round_rate to scale past LONG_MAX on 32 bit systems Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 04/34] clk: omap2: change omap2_round_to_table_rate return logic Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 05/34] clk: at91: update clk_pll_get_best_div_mul to return unsigned long Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 06/34] clk: at91: change clk_pll_get_best_div_mul() return logic Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 07/34] clk: axs10x: change i2s_pll_round_rate " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 08/34] clk: bcm2835: change bcm2835_pll_rate_from_divisors to return unsigned long Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 09/34] clk: bcm2835: change clk_get_rate() helper return type Bryan O'Donoghue
2018-01-02 22:21 ` Eric Anholt
2018-01-01 19:42 ` [PATCH v3 10/34] clk: bcm: iproc: change iproc_asiu_clk_round_rate() return logic Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 11/34] clk: bcm: iproc: change iproc_pll_round_rate() " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 12/34] clk: cdce925: remove unnecessary long casts on return Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 13/34] clk: si514: change si514_round_rate() return logic Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 14/34] clk: vc5: change vc5_pfd_round_rate() " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 15/34] clk: vc5: change vc5_dbl_round_rate() " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 16/34] clk: vt8500: change vtwm_pll_round_rate() " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 17/34] clk: vt8500: match temp holder variable to fn return type Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 18/34] clk: mvebu: change dove_round_rate() return logic Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 19/34] clk: mxs: change clk_frac_round_rate() " Bryan O'Donoghue
2018-01-01 19:42 ` [PATCH v3 20/34] clk: nxp: change lpc18xx_pll0_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 21/34] clk: lpc32xx: change clk_hclk_pll_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 22/34] clk: qcom: ipq4019: change clk_cpu_div_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 23/34] clk: sirf: remove unnecessary long cast on return Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 24/34] clk: tegra: change clk_sync_source_round_rate() return logic Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 25/34] clk: tegra: bpmp: change tegra_bpmp_clk_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 26/34] clk: tegra: pll: change clk_pll_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 27/34] clk: ti: composite: " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 28/34] clk: ti: fapll: change round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 29/34] clk: zte: change zx_audio_round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 30/34] clk: axs10x: change axs10x_pll_round_rate " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 31/34] clk: at91: change round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 32/34] clk: ARC: change hsdk_pll_round_rate () " Bryan O'Donoghue
2018-01-01 19:43 ` [PATCH v3 33/34] clk: lpc32xx: change round_rate() " Bryan O'Donoghue
2018-01-01 19:43 ` Bryan O'Donoghue [this message]
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=1514835793-1104-35-git-send-email-pure.logic@nexus-software.ie \
--to=pure.logic@nexus-software.ie \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@codeaurora.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
all inboxes | Powered by JetHome®