Skip to contentSkip to conversation

mmc: Fix decoding of SCR & function switch data on little-endian machines

PATCH New Yauhen Kharuzhy 3 participants 3 messages May 6, 2009 – Jun 2, 2009 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: Fix decoding of SCR & function switch data on little-endian machines

SCR & switch data are read from card as big-endian words and should be converted to CPU byte order.

---
 drivers/mmc/mmc.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
drivers/mmc/mmc.c +7 -5
index b4814d2..596e052 100644
@@ -487,8 +487,8 @@ retry_scr:
 		return err;
 	}
 
-	mmc->scr[0] = scr[0];
-	mmc->scr[1] = scr[1];
+	mmc->scr[0] = __be32_to_cpu(scr[0]);
+	mmc->scr[1] = __be32_to_cpu(scr[1]);
 
 	switch ((mmc->scr[0] >> 24) & 0xf) {
 		case 0:
@@ -518,7 +518,7 @@ retry_scr:
 			return err;
 
 		/* The high-speed function is busy.  Try again */
-		if (!switch_status[7] & SD_HIGHSPEED_BUSY)
+		if (!(__be32_to_cpu(switch_status[7]) & SD_HIGHSPEED_BUSY))
 			break;
 	}
 
@@ -526,7 +526,7 @@ retry_scr:
 		mmc->card_caps |= MMC_MODE_4BIT;
 
 	/* If high-speed isn't supported, we return */
-	if (!(switch_status[3] & SD_HIGHSPEED_SUPPORTED))
+	if (!(__be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED))
 		return 0;
 
 	err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (u8 *)&switch_status);
@@ -534,8 +534,10 @@ retry_scr:
 	if (err)
 		return err;
 
-	if ((switch_status[4] & 0x0f000000) == 0x01000000)
+	if ((__be32_to_cpu(switch_status[4]) & 0x0f000000) == 0x01000000) {
 		mmc->card_caps |= MMC_MODE_HS;
+		printf("Switched to HS mode\n");
+	}
 
 	return 0;
 }
Signature · 1 line
1.6.2.3
#1 lore raw

PATCH 1/1 mmc: Fix decoding of SCR & function switch data on little-endian machines

drivers/mmc/mmc.c retry_scr: · line 540

Quoted 11 lines · Yauhen Kharuzhy

SCR & switch data are read from card as big-endian words and should be converted to CPU byte order.

---

drivers/mmc/mmc.c +1 -1
-	if ((switch_status[4] & 0x0f000000) == 0x01000000)
+	if ((__be32_to_cpu(switch_status[4]) & 0x0f000000) == 0x01000000) {
		mmc->card_caps |= MMC_MODE_HS;
drivers/mmc/mmc.c +2 -0
+		printf("Switched to HS mode\n");
+	}

You left some debug output there.