ar7: add NULL clock fix send upstream
authorMathias Kresin <[email protected]>
Fri, 28 Jul 2017 17:05:33 +0000 (19:05 +0200)
committerMathias Kresin <[email protected]>
Sat, 29 Jul 2017 07:24:17 +0000 (09:24 +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.

Signed-off-by: Mathias Kresin <[email protected]>
target/linux/ar7/patches-3.18/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch [new file with mode: 0644]
target/linux/ar7/patches-4.1/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch [new file with mode: 0644]

diff --git a/target/linux/ar7/patches-3.18/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch b/target/linux/ar7/patches-3.18/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch
new file mode 100644 (file)
index 0000000..74ac0d1
--- /dev/null
@@ -0,0 +1,45 @@
+From patchwork Tue Jul 18 10:17:26 2017
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [5/9] MIPS: AR7: allow NULL clock for clk_get_rate
+X-Patchwork-Submitter: Jonas Gorski <[email protected]>
+X-Patchwork-Id: 16775
+Message-Id: <[email protected]>
+To: unlisted-recipients:; (no To-header on input)
+Cc: Ralf Baechle <[email protected]>,
+ Paul Gortmaker <[email protected]>,
+ James Hogan <[email protected]>,
+Date: Tue, 18 Jul 2017 12:17:26 +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: 780019ddf02f ("MIPS: AR7: Implement clock API")
+Cc: Ralf Baechle <[email protected]>
+Cc: Paul Gortmaker <[email protected]>
+Cc: James Hogan <[email protected]>
+Reported-by: Mathias Kresin <[email protected]>
+Signed-off-by: Jonas Gorski <[email protected]>
+---
+ arch/mips/ar7/clock.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/mips/ar7/clock.c
++++ b/arch/mips/ar7/clock.c
+@@ -430,6 +430,9 @@ EXPORT_SYMBOL(clk_disable);
+ unsigned long clk_get_rate(struct clk *clk)
+ {
++      if (!clk)
++              return 0;
++
+       return clk->rate;
+ }
+ EXPORT_SYMBOL(clk_get_rate);
diff --git a/target/linux/ar7/patches-4.1/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch b/target/linux/ar7/patches-4.1/101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch
new file mode 100644 (file)
index 0000000..74ac0d1
--- /dev/null
@@ -0,0 +1,45 @@
+From patchwork Tue Jul 18 10:17:26 2017
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [5/9] MIPS: AR7: allow NULL clock for clk_get_rate
+X-Patchwork-Submitter: Jonas Gorski <[email protected]>
+X-Patchwork-Id: 16775
+Message-Id: <[email protected]>
+To: unlisted-recipients:; (no To-header on input)
+Cc: Ralf Baechle <[email protected]>,
+ Paul Gortmaker <[email protected]>,
+ James Hogan <[email protected]>,
+Date: Tue, 18 Jul 2017 12:17:26 +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: 780019ddf02f ("MIPS: AR7: Implement clock API")
+Cc: Ralf Baechle <[email protected]>
+Cc: Paul Gortmaker <[email protected]>
+Cc: James Hogan <[email protected]>
+Reported-by: Mathias Kresin <[email protected]>
+Signed-off-by: Jonas Gorski <[email protected]>
+---
+ arch/mips/ar7/clock.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/mips/ar7/clock.c
++++ b/arch/mips/ar7/clock.c
+@@ -430,6 +430,9 @@ EXPORT_SYMBOL(clk_disable);
+ unsigned long clk_get_rate(struct clk *clk)
+ {
++      if (!clk)
++              return 0;
++
+       return clk->rate;
+ }
+ EXPORT_SYMBOL(clk_get_rate);