Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1567811 > unrolled thread

[PATCH 13/13] mmc: bcm2835: use bcm2835_read_wait_sdcmd in bcm2835_finish_command

Started byGerd Hoffmann <kraxel@redhat.com>
First post2017-01-27 00:40 +0100
Last post2017-01-27 00:40 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 13/13] mmc: bcm2835: use bcm2835_read_wait_sdcmd in bcm2835_finish_command Gerd Hoffmann <kraxel@redhat.com> - 2017-01-27 00:40 +0100

#1567811 — [PATCH 13/13] mmc: bcm2835: use bcm2835_read_wait_sdcmd in bcm2835_finish_command

FromGerd Hoffmann <kraxel@redhat.com>
Date2017-01-27 00:40 +0100
Subject[PATCH 13/13] mmc: bcm2835: use bcm2835_read_wait_sdcmd in bcm2835_finish_command
Message-ID<t41O2-5cG-19@gated-at.bofh.it>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/mmc/host/bcm2835.c | 56 +---------------------------------------------
 1 file changed, 1 insertion(+), 55 deletions(-)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 82caddc..64a2334 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -152,7 +152,6 @@ struct bcm2835_host {
 	unsigned int		blocks;		/* remaining PIO blocks */
 	int			irq;		/* Device IRQ */
 
-	u32			cmd_quick_poll_retries;
 	u32			ns_per_fifo_word;
 
 	/* cached registers */
@@ -782,62 +781,10 @@ static void bcm2835_finish_command(struct bcm2835_host *host)
 	struct device *dev = &host->pdev->dev;
 	struct mmc_command *cmd = host->cmd;
 	u32 sdcmd;
-	u32 retries;
 
 	dev_dbg(dev, "finish_command(%x)\n", readl(host->ioaddr + SDCMD));
 
-	/* Poll quickly at first */
-
-	retries = host->cmd_quick_poll_retries;
-	if (!retries) {
-		/* Work out how many polls take 1us by timing 10us */
-		struct timeval start, now;
-		int us_diff;
-
-		retries = 1;
-		do {
-			int i;
-
-			retries *= 2;
-
-			do_gettimeofday(&start);
-
-			for (i = 0; i < retries; i++) {
-				cpu_relax();
-				sdcmd = readl(host->ioaddr + SDCMD);
-			}
-
-			do_gettimeofday(&now);
-			us_diff = (now.tv_sec - start.tv_sec) * 1000000 +
-				(now.tv_usec - start.tv_usec);
-		} while (us_diff < 10);
-
-		host->cmd_quick_poll_retries =
-			((retries * us_diff + 9) * CMD_DALLY_US) / 10 + 1;
-		retries = 1; /* We've already waited long enough this time */
-	}
-
-	retries = host->cmd_quick_poll_retries;
-	for (sdcmd = readl(host->ioaddr + SDCMD);
-	     (sdcmd & SDCMD_NEW_FLAG) && !(sdcmd & SDCMD_FAIL_FLAG) && retries;
-	     retries--) {
-		cpu_relax();
-		sdcmd = readl(host->ioaddr + SDCMD);
-	}
-
-	if (!retries) {
-		unsigned long wait_max;
-
-		/* Wait max 100 ms */
-		wait_max = jiffies + msecs_to_jiffies(100);
-		while (time_before(jiffies, wait_max)) {
-			usleep_range(1, 10);
-			sdcmd = readl(host->ioaddr + SDCMD);
-			if (!(sdcmd & SDCMD_NEW_FLAG) ||
-			    (sdcmd & SDCMD_FAIL_FLAG))
-				break;
-		}
-	}
+	sdcmd = bcm2835_read_wait_sdcmd(host, 100, true);
 
 	/* Check for errors */
 	if (sdcmd & SDCMD_NEW_FLAG) {
@@ -1435,7 +1382,6 @@ static int bcm2835_probe(struct platform_device *pdev)
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
 	host->pdev = pdev;
-	host->cmd_quick_poll_retries = 0;
 	host->pio_timeout = msecs_to_jiffies(500);
 	host->pio_limit = 1;
 	host->max_delay = 1; /* Warn if over 1ms */
-- 
1.8.3.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web