Subject: [PATCH 1/4] mmc: mmci: Bugfix in pio read for small packets

From: [email-masked] (Stefan Nilsson XK)
Date: Fri, 14 Oct 2011 09:38:05 +0200

On 10/07/2011 09:11 PM, Russell King - ARM Linux wrote:
> But first, you need to fix your code so you're only reading 32-bit
> quantities from the FIFO register.

Hi Russel, what to you think of doing it this way instead:

		/*
		 * SDIO especially may want to send something that is
		 * not divisible by 4 (as opposed to card sectors
		 * etc), and the FIFO only accept full 32-bit reads.
		 */
		if (count < 4) {
			unsigned char buf[4];
			readsl(base + MMCIFIFO, buf, 1);
			memcpy(ptr, buf, count);
		}
		else
			readsl(base + MMCIFIFO, ptr, count >> 2);

This makes sure we only access the FIFO in a 32 bit way, and the only 
overhead for the "standard" case (count >= 4) is the "if" clause. I have 
verified this to work with our WLAN driver.

Best Regards

Stefan Nilsson