Browse Source

ramips: add NULL clock fix send upstream

Make the behaviour of clk_get_rate consistent with common clk's
clk_get_rate by accepting NULL clocks as parameter. Some device
drivers rely on this, and will cause an OOPS otherwise.

Fixes: FS#735

Signed-off-by: Mathias Kresin <[email protected]>
Mathias Kresin 8 years ago
parent
commit
0a17d2970a

+ 43 - 0
target/linux/ramips/patches-4.9/0101-MIPS-ralink-allow-NULL-clock-for-clk_get_rate.patch

@@ -0,0 +1,43 @@
+From patchwork Tue Jul 18 10:17:29 2017
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [8/9] MIPS: ralink: allow NULL clock for clk_get_rate
+X-Patchwork-Submitter: Jonas Gorski <[email protected]>
+X-Patchwork-Id: 16778
+Message-Id: <[email protected]>
+To: unlisted-recipients:; (no To-header on input)
+Cc: John Crispin <[email protected]>,
+ Ralf Baechle <[email protected]>, [email protected],
+ [email protected]
+Date: Tue, 18 Jul 2017 12:17:29 +0200
+From: Jonas Gorski <[email protected]>
+List-Id: linux-mips <linux-mips.eddie.linux-mips.org>
+
+Make the behaviour of clk_get_rate consistent with common clk's
+clk_get_rate by accepting NULL clocks as parameter. Some device
+drivers rely on this, and will cause an OOPS otherwise.
+
+Fixes: 3f0a06b0368d ("MIPS: ralink: adds clkdev code")
+Cc: John Crispin <[email protected]>
+Cc: Ralf Baechle <[email protected]>
+Cc: [email protected]
+Cc: [email protected]
+Reported-by: Mathias Kresin <[email protected]>
+Signed-off-by: Jonas Gorski <[email protected]>
+---
+ arch/mips/ralink/clk.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/mips/ralink/clk.c
++++ b/arch/mips/ralink/clk.c
+@@ -52,6 +52,9 @@ EXPORT_SYMBOL_GPL(clk_disable);
+ 
+ unsigned long clk_get_rate(struct clk *clk)
+ {
++	if (!clk)
++		return 0;
++
+ 	return clk->rate;
+ }
+ EXPORT_SYMBOL_GPL(clk_get_rate);