From 9532373b1dd5b9f4ba0c2c69fd287d436013ad0c Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 6 Aug 2013 12:10:25 +0000 Subject: [PATCH] EmbeddedPkg/MmcDxe: Removed redundant CMD12 calls from MMC Command 12 - Stop transmission (ends read or write). Normally only needed for streaming transfers or after error. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14525 6f19259b-4bc3-4df7-8a09-765794883524 --- EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c index 57fa14e42e..82ec5a7a2d 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c @@ -486,6 +486,22 @@ MmcDetectCard ( } } +EFI_STATUS +MmcStopTransmission ( + EFI_MMC_HOST_PROTOCOL *MmcHost + ) +{ + EFI_STATUS Status; + UINT32 Response[4]; + // Command 12 - Stop transmission (ends read or write) + // Normally only needed for streaming transfers or after error. + Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0); + if (!EFI_ERROR (Status)) { + MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response); + } + return Status; +} + #define MMCI0_BLOCKLEN 512 #define MMCI0_TIMEOUT 10000 @@ -598,6 +614,7 @@ MmcIoBlocks ( Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status)); + MmcStopTransmission (MmcHost); return Status; } Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState); @@ -610,16 +627,11 @@ MmcIoBlocks ( Status = MmcHost->WriteBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status)); + MmcStopTransmission (MmcHost); return Status; } } - // Command 12 - Stop transmission (ends read) - Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0); - if (!EFI_ERROR (Status)) { - MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response); - } - // Command 13 - Read status and wait for programming to complete (return to tran) Timeout = MMCI0_TIMEOUT; CmdArg = MmcHostInstance->CardInfo.RCA << 16;