delete calculation-of-NM-rate patch since it is now in Begous branch
This commit is contained in:
parent
592c8bd76b
commit
b2137424a5
@ -1,74 +0,0 @@
|
||||
From 96d78cd2590710fc7e08a4445349a0b4a21df04a Mon Sep 17 00:00:00 2001
|
||||
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Date: Sun, 7 Oct 2018 11:38:39 +0200
|
||||
Subject: [PATCH 086/146] clk: sunxi-ng: Use u64 for calculation of NM rate
|
||||
|
||||
Allwinner H6 SoC has multiplier N range between 1 and 254. Since parent
|
||||
rate is 24MHz, intermediate result when calculating final rate easily
|
||||
overflows 32 bit variable.
|
||||
|
||||
Because of that, introduce function for calculating clock rate which
|
||||
uses 64 bit variable for intermediate result.
|
||||
|
||||
Fixes: 6174a1e24b0d ("clk: sunxi-ng: Add N-M-factor clock support")
|
||||
Fixes: ee28648cb2b4 ("clk: sunxi-ng: Remove the use of rational computations")
|
||||
|
||||
CC: <stable@vger.kernel.org>
|
||||
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
---
|
||||
drivers/clk/sunxi-ng/ccu_nm.c | 18 +++++++++++++++---
|
||||
1 file changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c
|
||||
index 6fe3c14f7b2d..424d8635b053 100644
|
||||
--- a/drivers/clk/sunxi-ng/ccu_nm.c
|
||||
+++ b/drivers/clk/sunxi-ng/ccu_nm.c
|
||||
@@ -19,6 +19,17 @@ struct _ccu_nm {
|
||||
unsigned long m, min_m, max_m;
|
||||
};
|
||||
|
||||
+static unsigned long ccu_nm_calc_rate(unsigned long parent,
|
||||
+ unsigned long n, unsigned long m)
|
||||
+{
|
||||
+ u64 rate = parent;
|
||||
+
|
||||
+ rate *= n;
|
||||
+ do_div(rate, m);
|
||||
+
|
||||
+ return rate;
|
||||
+}
|
||||
+
|
||||
static void ccu_nm_find_best(unsigned long parent, unsigned long rate,
|
||||
struct _ccu_nm *nm)
|
||||
{
|
||||
@@ -28,7 +39,8 @@ static void ccu_nm_find_best(unsigned long parent, unsigned long rate,
|
||||
|
||||
for (_n = nm->min_n; _n <= nm->max_n; _n++) {
|
||||
for (_m = nm->min_m; _m <= nm->max_m; _m++) {
|
||||
- unsigned long tmp_rate = parent * _n / _m;
|
||||
+ unsigned long tmp_rate = ccu_nm_calc_rate(parent,
|
||||
+ _n, _m);
|
||||
|
||||
if (tmp_rate > rate)
|
||||
continue;
|
||||
@@ -100,7 +112,7 @@ static unsigned long ccu_nm_recalc_rate(struct clk_hw *hw,
|
||||
if (ccu_sdm_helper_is_enabled(&nm->common, &nm->sdm))
|
||||
rate = ccu_sdm_helper_read_rate(&nm->common, &nm->sdm, m, n);
|
||||
else
|
||||
- rate = parent_rate * n / m;
|
||||
+ rate = ccu_nm_calc_rate(parent_rate, n, m);
|
||||
|
||||
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
|
||||
rate /= nm->fixed_post_div;
|
||||
@@ -149,7 +161,7 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
|
||||
_nm.max_m = nm->m.max ?: 1 << nm->m.width;
|
||||
|
||||
ccu_nm_find_best(*parent_rate, rate, &_nm);
|
||||
- rate = *parent_rate * _nm.n / _nm.m;
|
||||
+ rate = ccu_nm_calc_rate(*parent_rate, _nm.n, _nm.m);
|
||||
|
||||
if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
|
||||
rate /= nm->fixed_post_div;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user