* [PATCH] clk: scpi: fix return type of __scpi_dvfs_round_rate
@ 2017-05-18 16:19 Sudeep Holla
2017-06-01 9:13 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Sudeep Holla @ 2017-05-18 16:19 UTC (permalink / raw)
To: linux-clk, Stephen Boyd, Michael Turquette; +Cc: Sudeep Holla, linux-kernel
The frequencies above the maximum value of signed integer(i.e. 2^31 -1)
will overflow with the current code.
This patch fixes the return type of __scpi_dvfs_round_rate from 'int'
to 'unsigned long'.
Fixes: cd52c2a4b5c4 ("clk: add support for clocks provided by SCP(System Control Processor)")
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/clk/clk-scpi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Hi,
Sorry for the stupid bug, just noticed the issue running on software
models with the frequency of 2.4 GHz. Not noticed so far as never ran
this on a system above 1.2 GHz so far :(
Regards,
Sudeep
diff --git a/drivers/clk/clk-scpi.c b/drivers/clk/clk-scpi.c
index 96d37175d0ad..8ad458b5ad6e 100644
--- a/drivers/clk/clk-scpi.c
+++ b/drivers/clk/clk-scpi.c
@@ -71,15 +71,15 @@ static const struct clk_ops scpi_clk_ops = {
};
/* find closest match to given frequency in OPP table */
-static int __scpi_dvfs_round_rate(struct scpi_clk *clk, unsigned long rate)
+static long __scpi_dvfs_round_rate(struct scpi_clk *clk, unsigned long rate)
{
int idx;
- u32 fmin = 0, fmax = ~0, ftmp;
+ unsigned long fmin = 0, fmax = ~0, ftmp;
const struct scpi_opp *opp = clk->info->opps;
for (idx = 0; idx < clk->info->count; idx++, opp++) {
ftmp = opp->freq;
- if (ftmp >= (u32)rate) {
+ if (ftmp >= rate) {
if (ftmp <= fmax)
fmax = ftmp;
break;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: scpi: fix return type of __scpi_dvfs_round_rate
2017-05-18 16:19 [PATCH] clk: scpi: fix return type of __scpi_dvfs_round_rate Sudeep Holla
@ 2017-06-01 9:13 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2017-06-01 9:13 UTC (permalink / raw)
To: Sudeep Holla; +Cc: linux-clk, Michael Turquette, linux-kernel
On 05/18, Sudeep Holla wrote:
> The frequencies above the maximum value of signed integer(i.e. 2^31 -1)
> will overflow with the current code.
>
> This patch fixes the return type of __scpi_dvfs_round_rate from 'int'
> to 'unsigned long'.
>
> Fixes: cd52c2a4b5c4 ("clk: add support for clocks provided by SCP(System Control Processor)")
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-01 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18 16:19 [PATCH] clk: scpi: fix return type of __scpi_dvfs_round_rate Sudeep Holla
2017-06-01 9:13 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).