Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322222 > unrolled thread

[PATCH] clk: axi-clkgen: Remove sometimes impossible check

Started byStephen Boyd <sboyd@codeaurora.org>
First post2016-01-30 02:20 +0100
Last post2016-01-30 17:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] clk: axi-clkgen: Remove sometimes impossible check Stephen Boyd <sboyd@codeaurora.org> - 2016-01-30 02:20 +0100
    Re: [PATCH] clk: axi-clkgen: Remove sometimes impossible check Lars-Peter Clausen <lars@metafoo.de> - 2016-01-30 17:10 +0100

#1322222 — [PATCH] clk: axi-clkgen: Remove sometimes impossible check

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-01-30 02:20 +0100
Subject[PATCH] clk: axi-clkgen: Remove sometimes impossible check
Message-ID<qWsmK-3ln-9@gated-at.bofh.it>
The size of unsigned long on 64-bit architectures is equal to the
size of u64, so this check is impossible there. This throws off
static checkers:

drivers/clk/clk-axi-clkgen.c:331 axi_clkgen_recalc_rate() warn:
impossible condition '(tmp > (~0)) => (0-u64max > u64max)'

Let's change this code to use min_t() instead so that we
get the same effect on architectures where sizeof(unsigned long)
doesn't equal sizeof(u64).

Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk-axi-clkgen.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 9a0744c9947c..3294db3b4e4e 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -328,10 +328,7 @@ static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
 	tmp = (unsigned long long)(parent_rate / d) * m;
 	do_div(tmp, dout);
 
-	if (tmp > ULONG_MAX)
-		return ULONG_MAX;
-
-	return tmp;
+	return min_t(unsigned long long, tmp, ULONG_MAX);
 }
 
 static int axi_clkgen_enable(struct clk_hw *clk_hw)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [next] | [standalone]


#1322401

FromLars-Peter Clausen <lars@metafoo.de>
Date2016-01-30 17:10 +0100
Message-ID<qWGg2-63q-11@gated-at.bofh.it>
In reply to#1322222
On 01/30/2016 02:13 AM, Stephen Boyd wrote:
> The size of unsigned long on 64-bit architectures is equal to the
> size of u64, so this check is impossible there. This throws off
> static checkers:
> 
> drivers/clk/clk-axi-clkgen.c:331 axi_clkgen_recalc_rate() warn:
> impossible condition '(tmp > (~0)) => (0-u64max > u64max)'
> 
> Let's change this code to use min_t() instead so that we
> get the same effect on architectures where sizeof(unsigned long)
> doesn't equal sizeof(u64).
> 
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Thanks.

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web