openwrtv4/target/linux/brcm2708/patches-3.10/0182-fix-sign-in-sdhci_bcm2708_raw_writel-wait-calculatio.patch
Florian Fainelli 6918ea2484 brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
Update the 3.10 rasperry patches by rebasing raspberry/rpi-3.10-y
against linux-stable/v3.10.49.

Signed-off-by: Florian Fainelli <florian@openwrt.org>

SVN-Revision: 42678
2014-09-27 19:10:51 +00:00

28 lines
1.9 KiB
Diff

From c62717f4dbf933743d3bcde958062d790587ecef Mon Sep 17 00:00:00 2001
From: Matt Whitlock <raspberrypi@mattwhitlock.name>
Date: Tue, 25 Mar 2014 03:45:21 -0400
Subject: [PATCH 182/196] fix sign in sdhci_bcm2708_raw_writel wait calculation
The ns_wait variable is intended to hold a lower bound on the number of nanoseconds that have elapsed since the last sdhci register write. However, the actual calculation of it was incorrect, as the subtraction was inverted. This commit fixes the calculation.
Note that this correction has no bearing when running with the default cycle_delay of 2 and the default clock rate of 50 MHz, under which conditions ns_2clk is 40 nanoseconds and ns_wait, regardless of whether the subtraction is done correctly or incorrectly, cannot possibly be less than 40 except for during the one-microsecond period just before the tick counter wraps around to meet last_write_hpt (i.e., approximately 4295 seconds after the preceding sdhci register write). The correction in this commit only comes into play if ns_2clk > 1000, which requires a cycle_delay of 51 or greater when using the default clock rate. Under those conditions, sdhci_bcm2708_raw_writel will not wait for the full cycle_delay count if at least 1000 nanoseconds have elapsed since the last register write.
---
drivers/mmc/host/sdhci-bcm2708.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-bcm2708.c b/drivers/mmc/host/sdhci-bcm2708.c
index 2797ae6..9beab6a 100644
--- a/drivers/mmc/host/sdhci-bcm2708.c
+++ b/drivers/mmc/host/sdhci-bcm2708.c
@@ -263,7 +263,7 @@ static void sdhci_bcm2708_raw_writel(struct sdhci_host *host, u32 val, int reg)
{
/* we must have waited at least this many ns: */
unsigned int ns_wait = HPTIME_CLK_NS *
- (last_write_hpt - now - 1);
+ (now - last_write_hpt - 1);
if (ns_wait < ns_2clk)
ndelay(ns_2clk - ns_wait);
}
--
1.9.1