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]>
--- /dev/null
+From patchwork Tue Jul 18 10:17:27 2017
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate
+X-Patchwork-Id: 16776
+To: unlisted-recipients:; (no To-header on input)
+Date: Tue, 18 Jul 2017 12:17:27 +0200
+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: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
+---
+ arch/mips/bcm63xx/clk.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/mips/bcm63xx/clk.c
++++ b/arch/mips/bcm63xx/clk.c
+@@ -345,6 +345,9 @@ EXPORT_SYMBOL(clk_disable);
+
+ unsigned long clk_get_rate(struct clk *clk)
+ {
++ if (!clk)
++ return 0;
++
+ return clk->rate;
+ }
+
}
static struct clk clk_pcie = {
-@@ -386,9 +400,11 @@ struct clk *clk_get(struct device *dev,
+@@ -389,9 +403,11 @@ struct clk *clk_get(struct device *dev,
return &clk_periph;
if ((BCMCPU_IS_3368() || BCMCPU_IS_6358()) && !strcmp(id, "pcm"))
return &clk_pcm;
return &clk_pcie;
return ERR_PTR(-ENOENT);
}
-@@ -411,6 +427,7 @@ static int __init bcm63xx_clk_init(void)
+@@ -414,6 +430,7 @@ static int __init bcm63xx_clk_init(void)
clk_hsspi.rate = HSSPI_PLL_HZ_6328;
break;
case BCM6362_CPU_ID:
mask = CKCTL_6328_HSSPI_EN;
else if (BCMCPU_IS_6362())
mask = CKCTL_6362_HSSPI_EN;
-@@ -417,12 +419,16 @@ void clk_put(struct clk *clk)
+@@ -420,12 +422,16 @@ void clk_put(struct clk *clk)
EXPORT_SYMBOL(clk_put);
}
static struct clk clk_pcie = {
-@@ -405,7 +422,7 @@ struct clk *clk_get(struct device *dev,
+@@ -408,7 +425,7 @@ struct clk *clk_get(struct device *dev,
if ((BCMCPU_IS_6362() || BCMCPU_IS_6368() || BCMCPU_IS_63268()) &&
!strcmp(id, "ipsec"))
return &clk_ipsec;
if (enable)
msleep(100);
-@@ -405,9 +413,9 @@ struct clk *clk_get(struct device *dev,
+@@ -408,9 +416,9 @@ struct clk *clk_get(struct device *dev,
return &clk_enetsw;
if (!strcmp(id, "ephy"))
return &clk_ephy;