m68k: allow NULL clock for clk_get_rate
authorJonas Gorski <jonas.gorski@gmail.com>
Tue, 18 Jul 2017 10:17:25 +0000 (12:17 +0200)
committerGreg Ungerer <gerg@linux-m68k.org>
Mon, 28 Aug 2017 00:40:30 +0000 (10:40 +1000)
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: facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
arch/m68k/coldfire/clk.c

index 1e3c7e9193d14d0a3c0c6821c1f686d6ef35d02d..856069a3196d224d7ee39a980289dcc738b691b8 100644 (file)
@@ -121,6 +121,9 @@ EXPORT_SYMBOL(clk_put);
 
 unsigned long clk_get_rate(struct clk *clk)
 {
+       if (!clk)
+               return 0;
+
        return clk->rate;
 }
 EXPORT_SYMBOL(clk_get_rate);