linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: imx: use sign_extend32() and abs()
@ 2015-09-29 11:32 Martin Kepplinger
  2015-10-01 23:39 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kepplinger @ 2015-09-29 11:32 UTC (permalink / raw)
  To: shawnguo, kernel, mturquette, sboyd
  Cc: linux-arm-kernel, linux-clk, linux-kernel, Martin Kepplinger

This simplifies the given function by getting rid of the manual
sign extension as well as saving an absolute value in an extra
variable.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
built and run, but please review.

                     martin


 drivers/clk/imx/clk-pllv2.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/imx/clk-pllv2.c b/drivers/clk/imx/clk-pllv2.c
index 20889d5..b18f875 100644
--- a/drivers/clk/imx/clk-pllv2.c
+++ b/drivers/clk/imx/clk-pllv2.c
@@ -77,7 +77,7 @@ struct clk_pllv2 {
 static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate,
 		u32 dp_ctl, u32 dp_op, u32 dp_mfd, u32 dp_mfn)
 {
-	long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+	long mfi, mfn, mfd, pdf, ref_clk;
 	unsigned long dbl;
 	s64 temp;
 
@@ -87,19 +87,15 @@ static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate,
 	mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
 	mfi = (mfi <= 5) ? 5 : mfi;
 	mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
-	mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
-	/* Sign extend to 32-bits */
-	if (mfn >= 0x04000000) {
-		mfn |= 0xFC000000;
-		mfn_abs = -mfn;
-	}
+	mfn = dp_mfn & MXC_PLL_DP_MFN_MASK;
+	mfn = sign_extend32(mfn, 26);
 
 	ref_clk = 2 * parent_rate;
 	if (dbl != 0)
 		ref_clk *= 2;
 
 	ref_clk /= (pdf + 1);
-	temp = (u64) ref_clk * mfn_abs;
+	temp = (u64) ref_clk * abs(mfn);
 	do_div(temp, mfd + 1);
 	if (mfn < 0)
 		temp = -temp;
-- 
2.1.4


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

* Re: [PATCH] clk: imx: use sign_extend32() and abs()
  2015-09-29 11:32 [PATCH] clk: imx: use sign_extend32() and abs() Martin Kepplinger
@ 2015-10-01 23:39 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2015-10-01 23:39 UTC (permalink / raw)
  To: Martin Kepplinger
  Cc: shawnguo, kernel, mturquette, linux-arm-kernel, linux-clk, linux-kernel

On 09/29, Martin Kepplinger wrote:
> This simplifies the given function by getting rid of the manual
> sign extension as well as saving an absolute value in an extra
> variable.
> 
> Signed-off-by: Martin Kepplinger <martink@posteo.de>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2015-10-01 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-29 11:32 [PATCH] clk: imx: use sign_extend32() and abs() Martin Kepplinger
2015-10-01 23:39 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).