LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate()
@ 2015-02-04 12:27 Geert Uytterhoeven
  2015-02-04 13:31 ` Sergei Shtylyov
  2015-02-04 17:32 ` Wolfram Sang
  0 siblings, 2 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2015-02-04 12:27 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd
  Cc: Laurent Pinchart, Ulrich Hecht, Wolfram Sang, linux-sh,
	linux-kernel, Geert Uytterhoeven

Anyone may call clk_round_rate() with a zero rate value, so we have to
protect against that.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This was triggered by the bad version of "clk: Add rate constraints to
clocks", but can happen regardless, cfr.
https://lkml.org/lkml/2015/1/29/560

 drivers/clk/shmobile/clk-div6.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c
index efbaf6c81b7530b8..036a692c72195db9 100644
--- a/drivers/clk/shmobile/clk-div6.c
+++ b/drivers/clk/shmobile/clk-div6.c
@@ -90,6 +90,9 @@ static unsigned int cpg_div6_clock_calc_div(unsigned long rate,
 {
 	unsigned int div;
 
+	if (!rate)
+		rate = 1;
+
 	div = DIV_ROUND_CLOSEST(parent_rate, rate);
 	return clamp_t(unsigned int, div, 1, 64);
 }
-- 
1.9.1


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

end of thread, other threads:[~2015-02-06 11:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 12:27 [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate() Geert Uytterhoeven
2015-02-04 13:31 ` Sergei Shtylyov
2015-02-04 13:50   ` Laurent Pinchart
2015-02-04 17:32 ` Wolfram Sang
2015-02-04 17:45   ` Sergei Shtylyov
2015-02-04 22:01     ` Mike Turquette
2015-02-04 22:04       ` Sergei Shtylyov
2015-02-04 22:14         ` Sergei Shtylyov
2015-02-05 17:19           ` Laurent Pinchart
2015-02-05 17:46             ` Mike Turquette
2015-02-06 11:12             ` Sergei Shtylyov
2015-02-04 22:05   ` Mike Turquette

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