ar7: add NULL clock fix send upstream
[openwrt/openwrt.git] / target / linux / ar7 / patches-3.18 / 101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch
1 From patchwork Tue Jul 18 10:17:26 2017
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: [5/9] MIPS: AR7: allow NULL clock for clk_get_rate
6 X-Patchwork-Submitter: Jonas Gorski <jonas.gorski@gmail.com>
7 X-Patchwork-Id: 16775
8 Message-Id: <20170718101730.2541-6-jonas.gorski@gmail.com>
9 To: unlisted-recipients:; (no To-header on input)
10 Cc: Ralf Baechle <ralf@linux-mips.org>,
11 Paul Gortmaker <paul.gortmaker@windriver.com>,
12 James Hogan <james.hogan@imgtec.com>,
13 linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
14 Date: Tue, 18 Jul 2017 12:17:26 +0200
15 From: Jonas Gorski <jonas.gorski@gmail.com>
16 List-Id: linux-mips <linux-mips.eddie.linux-mips.org>
17
18 Make the behaviour of clk_get_rate consistent with common clk's
19 clk_get_rate by accepting NULL clocks as parameter. Some device
20 drivers rely on this, and will cause an OOPS otherwise.
21
22 Fixes: 780019ddf02f ("MIPS: AR7: Implement clock API")
23 Cc: Ralf Baechle <ralf@linux-mips.org>
24 Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
25 Cc: James Hogan <james.hogan@imgtec.com>
26 Cc: linux-mips@linux-mips.org
27 Cc: linux-kernel@vger.kernel.org
28 Reported-by: Mathias Kresin <dev@kresin.me>
29 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
30 ---
31 arch/mips/ar7/clock.c | 3 +++
32 1 file changed, 3 insertions(+)
33
34 --- a/arch/mips/ar7/clock.c
35 +++ b/arch/mips/ar7/clock.c
36 @@ -430,6 +430,9 @@ EXPORT_SYMBOL(clk_disable);
37
38 unsigned long clk_get_rate(struct clk *clk)
39 {
40 + if (!clk)
41 + return 0;
42 +
43 return clk->rate;
44 }
45 EXPORT_SYMBOL(clk_get_rate);