mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: pure.logic@nexus-software.ie
Subject: [PATCH 02/33] clk: core: update divider_round_rate functions to return unsigned long
Date: Sat, 30 Dec 2017 01:12:41 +0000	[thread overview]
Message-ID: <1514596392-22270-3-git-send-email-pure.logic@nexus-software.ie> (raw)
In-Reply-To: <1514596392-22270-1-git-send-email-pure.logic@nexus-software.ie>

Returning a long from round_rate() class functions is rooted in the notion
that we will propagate a negative number on some class of failure to round
a clock rate; however this approach does not scale to 32 bit systems which
legitimately round a clock over LONG_MAX as the returned clock rate is
indistinguishable from an error number.

A better approach is to return zero when we cannot round a clock and
non-zero when we can - thus supporting the full range of the unsigned long
rate input value to round_rate() functions.

Update the signature of divider_round_rate functions to do this now.

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-divider.c    | 10 ++++++----
 include/linux/clk-provider.h | 19 +++++++++++--------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index a26ec7c..e827304 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -332,10 +332,12 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent,
 	return bestdiv;
 }
 
-long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
-			       unsigned long rate, unsigned long *prate,
-			       const struct clk_div_table *table,
-			       u8 width, unsigned long flags)
+unsigned long divider_round_rate_parent(struct clk_hw *hw,
+					struct clk_hw *parent,
+					unsigned long rate,
+					unsigned long *prate,
+					const struct clk_div_table *table,
+					u8 width, unsigned long flags)
 {
 	int div;
 
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 79b1d6e..e763d94 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -413,10 +413,12 @@ extern const struct clk_ops clk_divider_ro_ops;
 unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate,
 		unsigned int val, const struct clk_div_table *table,
 		unsigned long flags);
-long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent,
-			       unsigned long rate, unsigned long *prate,
-			       const struct clk_div_table *table,
-			       u8 width, unsigned long flags);
+unsigned long divider_round_rate_parent(struct clk_hw *hw,
+					struct clk_hw *parent,
+					unsigned long rate,
+					unsigned long *prate,
+					const struct clk_div_table *table,
+					u8 width, unsigned long flags);
 int divider_get_val(unsigned long rate, unsigned long parent_rate,
 		const struct clk_div_table *table, u8 width,
 		unsigned long flags);
@@ -762,10 +764,11 @@ static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src)
 	dst->core = src->core;
 }
 
-static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate,
-				      unsigned long *prate,
-				      const struct clk_div_table *table,
-				      u8 width, unsigned long flags)
+static inline unsigned long divider_round_rate(struct clk_hw *hw,
+					       unsigned long rate,
+					       unsigned long *prate,
+					       const struct clk_div_table *table,
+					       u8 width, unsigned long flags)
 {
 	return divider_round_rate_parent(hw, clk_hw_get_parent(hw),
 					 rate, prate, table, width, flags);
-- 
2.7.4

  parent reply	other threads:[~2017-12-30  1:20 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-30  1:12 [PATCH 00/33] change clk_ops->round_rate to scale past LONG_MAX Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 01/33] clk_ops: change round_rate() to return unsigned long Bryan O'Donoghue
2017-12-30 16:36   ` Mikko Perttunen
2017-12-31 13:40     ` Bryan O'Donoghue
2018-01-02 19:01       ` Stephen Boyd
2018-01-02 20:43         ` Bryan O'Donoghue
2018-01-02 23:28           ` Stephen Boyd
2018-01-01 14:41   ` kbuild test robot
2018-01-01 14:47   ` kbuild test robot
2018-01-01 18:01   ` kbuild test robot
2017-12-30  1:12 ` Bryan O'Donoghue [this message]
2017-12-30  1:12 ` [PATCH 03/33] clk: composite: allow round_rate to scale past LONG_MAX on 32 bit systems Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 04/33] clk: omap2: change omap2_round_to_table_rate return logic Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 05/33] clk: at91: update clk_pll_get_best_div_mul to return unsigned long Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 06/33] clk: at91: change clk_pll_get_best_div_mul() return logic Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 07/33] clk: axs10x: change i2s_pll_round_rate " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 08/33] clk: bcm2835: change bcm2835_pll_rate_from_divisors to return unsigned long Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 09/33] clk: bcm2835: change clk_get_rate() helper return type Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 10/33] clk: bcm: iproc: change iproc_asiu_clk_round_rate() return logic Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 11/33] clk: bcm: iproc: change iproc_pll_round_rate() " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 12/33] clk: cdce925: remove unnecessary long casts on return Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 13/33] clk: si514: change si514_round_rate() return logic Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 14/33] clk: vc5: change vc5_mux_round_rate() " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 15/33] clk: vt8500: change vtwm_pll_round_rate() " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 16/33] clk: vt8500: match temp holder variable to fn return type Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 17/33] clk: mvebu: change dove_round_rate() return logic Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 18/33] clk: mxs: change clk_frac_round_rate() " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 19/33] clk: nxp: change lpc18xx_pll0_round_rate() " Bryan O'Donoghue
2017-12-30  1:12 ` [PATCH 20/33] clk: lpc32xx: change clk_hclk_pll_round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 21/33] clk: qcom: ipq4019: change clk_cpu_div_round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 22/33] clk: sirf: remove unnecessary long cast on return Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 23/33] clk: tegra: change clk_sync_source_round_rate() return logic Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 24/33] clk: tegra: bpmp: change tegra_bpmp_clk_round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 25/33] clk: tegra: pll: change clk_pll_round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 26/33] clk: ti: composite: " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 27/33] clk: ti: fapll: change round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 28/33] clk: zte: change zx_audio_round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 29/33] clk: axs10x: change axs10x_pll_round_rate " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 30/33] clk: at91: change round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 31/33] clk: ARC: change hsdk_pll_round_rate () " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 32/33] clk: lpc32xx: change round_rate() " Bryan O'Donoghue
2017-12-30  1:13 ` [PATCH 33/33] clk: change handling of round_rate() such that only zero is an error Bryan O'Donoghue

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=1514596392-22270-3-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®