mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V2] clk: qcom: clk-alpha-pll: Simplify the zonda_pll_adjust_l_val()
@ 2024-08-14 10:20 Satya Priya Kakitapalli
  2024-08-15 21:30 ` Bjorn Andersson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Satya Priya Kakitapalli @ 2024-08-14 10:20 UTC (permalink / raw)
  To: Bjorn Andersson, Michael Turquette, Stephen Boyd
  Cc: linux-arm-msm, linux-clk, linux-kernel, Ajit Pandey, Imran Shaik,
	Taniya Das, Jagadeesh Kona, Satya Priya Kakitapalli,
	kernel test robot, Dan Carpenter, Vladimir Zapolskiy

In zonda_pll_adjust_l_val() replace the divide operator with comparison
operator since comparisons are faster than divisions. Also, simplify the
logic and remove the unnecessary 'quotient' local variable.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202408110724.8pqbpDiD-lkp@intel.com/
Signed-off-by: Satya Priya Kakitapalli <quic_skakitap@quicinc.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
Changes in V2:
 - Simplify the logic and remove unnecessary quotient variable.
 - Remove Fixes tag as this is just a simplification.

 drivers/clk/qcom/clk-alpha-pll.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c
index 2f620ccb41cb..4ce3347beb39 100644
--- a/drivers/clk/qcom/clk-alpha-pll.c
+++ b/drivers/clk/qcom/clk-alpha-pll.c
@@ -2120,14 +2120,11 @@ static void clk_zonda_pll_disable(struct clk_hw *hw)
 
 static void zonda_pll_adjust_l_val(unsigned long rate, unsigned long prate, u32 *l)
 {
-	u64 remainder, quotient;
+	u64 remainder;
 
-	quotient = rate;
-	remainder = do_div(quotient, prate);
-	*l = quotient;
+	remainder = do_div(rate, prate);
 
-	if ((remainder * 2) / prate)
-		*l = *l + 1;
+	*l = rate + (u32)(remainder * 2 >= prate);
 }
 
 static int clk_zonda_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-30  5:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-14 10:20 [PATCH V2] clk: qcom: clk-alpha-pll: Simplify the zonda_pll_adjust_l_val() Satya Priya Kakitapalli
2024-08-15 21:30 ` Bjorn Andersson
2024-08-30  5:33   ` Satya Priya Kakitapalli
2024-08-17 11:46 ` kernel test robot
2024-08-17 12:27 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®