linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: axi-clkgen: Remove sometimes impossible check
@ 2016-01-30  1:13 Stephen Boyd
  2016-01-30 14:59 ` Lars-Peter Clausen
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Boyd @ 2016-01-30  1:13 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Lars-Peter Clausen

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: axi-clkgen: Remove sometimes impossible check
  2016-01-30  1:13 [PATCH] clk: axi-clkgen: Remove sometimes impossible check Stephen Boyd
@ 2016-01-30 14:59 ` Lars-Peter Clausen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars-Peter Clausen @ 2016-01-30 14:59 UTC (permalink / raw)
  To: Stephen Boyd, Mike Turquette; +Cc: linux-kernel, linux-clk

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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-30 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30  1:13 [PATCH] clk: axi-clkgen: Remove sometimes impossible check Stephen Boyd
2016-01-30 14:59 ` Lars-Peter Clausen

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).