101-MIPS-AR7-allow-NULL-clock-for-clk_get_rate.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. Make the behaviour of clk_get_rate consistent with common clk's
  18. clk_get_rate by accepting NULL clocks as parameter. Some device
  19. drivers rely on this, and will cause an OOPS otherwise.
  20. Fixes: 780019ddf02f ("MIPS: AR7: Implement clock API")
  21. Cc: Ralf Baechle <ralf@linux-mips.org>
  22. Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
  23. Cc: James Hogan <james.hogan@imgtec.com>
  24. Cc: linux-mips@linux-mips.org
  25. Cc: linux-kernel@vger.kernel.org
  26. Reported-by: Mathias Kresin <dev@kresin.me>
  27. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
  28. ---
  29. arch/mips/ar7/clock.c | 3 +++
  30. 1 file changed, 3 insertions(+)
  31. --- a/arch/mips/ar7/clock.c
  32. +++ b/arch/mips/ar7/clock.c
  33. @@ -430,6 +430,9 @@ EXPORT_SYMBOL(clk_disable);
  34. unsigned long clk_get_rate(struct clk *clk)
  35. {
  36. + if (!clk)
  37. + return 0;
  38. +
  39. return clk->rate;
  40. }
  41. EXPORT_SYMBOL(clk_get_rate);