diff mbox

[1/1] spi-pxa2xx: choose closest lower speed

Message ID 1444304593-14669-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit 3ad48062233f32a8dd2649403f5afc076710f86b
Headers show

Commit Message

Andy Shevchenko Oct. 8, 2015, 11:43 a.m. UTC
As per discussion [1] the best choice is to set closest speed which is not
going over the asked one.

Do the same approach for Intel Quark boards.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mark Brown Oct. 12, 2015, 4:50 p.m. UTC | #1
On Thu, Oct 08, 2015 at 02:43:13PM +0300, Andy Shevchenko wrote:
> As per discussion [1] the best choice is to set closest speed which is not
> going over the asked one.

You've not provided this footnote.
diff mbox

Patch

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index dee5b38..82493c2 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -734,7 +734,7 @@  static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
 	mul = (1 << 24) >> 1;
 
 	/* Calculate initial quot */
-	q1 = DIV_ROUND_CLOSEST(fref1, rate);
+	q1 = DIV_ROUND_UP(fref1, rate);
 
 	/* Scale q1 if it's too big */
 	if (q1 > 256) {
@@ -759,7 +759,7 @@  static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
 
 	/* Case 2 */
 
-	q2 = DIV_ROUND_CLOSEST(fref2, rate);
+	q2 = DIV_ROUND_UP(fref2, rate);
 	r2 = abs(fref2 / q2 - rate);
 
 	/*
@@ -778,13 +778,13 @@  static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
 		mul = (1 << 24) * 2 / 5;
 	}
 
-	/* Check case 3 only If the divisor is big enough */
+	/* Check case 3 only if the divisor is big enough */
 	if (fref / rate >= 80) {
 		u64 fssp;
 		u32 m;
 
 		/* Calculate initial quot */
-		q1 = DIV_ROUND_CLOSEST(fref, rate);
+		q1 = DIV_ROUND_UP(fref, rate);
 		m = (1 << 24) / q1;
 
 		/* Get the remainder */