MIPS: ralink: allow NULL clock for clk_get_rate
authorJonas Gorski <jonas.gorski@gmail.com>
Tue, 18 Jul 2017 10:17:29 +0000 (12:17 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 6 Sep 2017 10:37:45 +0000 (12:37 +0200)
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")
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Cc: John Crispin <john@phrozen.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/16778/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/ralink/clk.c

index eb1c619..1b7df11 100644 (file)
@@ -53,6 +53,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);