0002-clk-sunxi-ng-mp-Avoid-computing-the-rate-twice.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 74492b9ecd874496578693d9985649665b560308 Mon Sep 17 00:00:00 2001
  2. From: Samuel Holland <[email protected]>
  3. Date: Sun, 7 Aug 2022 20:08:49 -0500
  4. Subject: [PATCH 002/117] clk: sunxi-ng: mp: Avoid computing the rate twice
  5. ccu_mp_find_best() already computes a best_rate at the same time as the
  6. best m and p factors. Return it so the caller does not need to duplicate
  7. the division.
  8. Series-to: Chen-Yu Tsai <[email protected]>
  9. Series-to: Jernej Skrabec <[email protected]>
  10. Signed-off-by: Samuel Holland <[email protected]>
  11. ---
  12. drivers/clk/sunxi-ng/ccu_mp.c | 11 ++++++-----
  13. 1 file changed, 6 insertions(+), 5 deletions(-)
  14. --- a/drivers/clk/sunxi-ng/ccu_mp.c
  15. +++ b/drivers/clk/sunxi-ng/ccu_mp.c
  16. @@ -10,9 +10,9 @@
  17. #include "ccu_gate.h"
  18. #include "ccu_mp.h"
  19. -static void ccu_mp_find_best(unsigned long parent, unsigned long rate,
  20. - unsigned int max_m, unsigned int max_p,
  21. - unsigned int *m, unsigned int *p)
  22. +static unsigned long ccu_mp_find_best(unsigned long parent, unsigned long rate,
  23. + unsigned int max_m, unsigned int max_p,
  24. + unsigned int *m, unsigned int *p)
  25. {
  26. unsigned long best_rate = 0;
  27. unsigned int best_m = 0, best_p = 0;
  28. @@ -35,6 +35,8 @@ static void ccu_mp_find_best(unsigned lo
  29. *m = best_m;
  30. *p = best_p;
  31. +
  32. + return best_rate;
  33. }
  34. static unsigned long ccu_mp_find_best_with_parent_adj(struct clk_hw *hw,
  35. @@ -109,8 +111,7 @@ static unsigned long ccu_mp_round_rate(s
  36. max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
  37. if (!clk_hw_can_set_rate_parent(&cmp->common.hw)) {
  38. - ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
  39. - rate = *parent_rate / p / m;
  40. + rate = ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p);
  41. } else {
  42. rate = ccu_mp_find_best_with_parent_adj(hw, parent_rate, rate,
  43. max_m, max_p);