From 385bcd4986bb40ab2fa27e842e2a34e823d9d70e Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 19 Apr 2012 14:44:21 +0530 Subject: [PATCH] --- yaml --- r: 299750 b: refs/heads/master c: 5eb806a3a68920a9f373f18b03fa14852047e62b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/spi/spi-pl022.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 4d1a07b64a86..034793fc77fa 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: eb798c641a34ae9cee9fcacfbe5dd40bd7777607 +refs/heads/master: 5eb806a3a68920a9f373f18b03fa14852047e62b diff --git a/trunk/drivers/spi/spi-pl022.c b/trunk/drivers/spi/spi-pl022.c index 1ead49dbebce..8aa44e7adaef 100644 --- a/trunk/drivers/spi/spi-pl022.c +++ b/trunk/drivers/spi/spi-pl022.c @@ -1681,26 +1681,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct while (scr <= SCR_MAX) { tmp = spi_rate(rate, cpsdvsr, scr); - if (tmp > freq) + if (tmp > freq) { + /* we need lower freq */ scr++; + continue; + } + /* - * If found exact value, update and break. - * If found more closer value, update and continue. + * If found exact value, mark found and break. + * If found more closer value, update and break. */ - else if ((tmp == freq) || (tmp > best_freq)) { + if (tmp > best_freq) { best_freq = tmp; best_cpsdvsr = cpsdvsr; best_scr = scr; if (tmp == freq) - break; + found = 1; } - scr++; + /* + * increased scr will give lower rates, which are not + * required + */ + break; } cpsdvsr += 2; scr = SCR_MIN; } + WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n", + freq); + clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF); clk_freq->scr = (u8) (best_scr & 0xFF); dev_dbg(&pl022->adev->dev,