summaryrefslogtreecommitdiff
path: root/Platform/Marvell/Drivers
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@semihalf.com>2017-06-26 15:23:26 +0200
committerLeif Lindholm <leif.lindholm@linaro.org>2017-11-07 17:20:21 +0000
commitfedad0018dff31e6581875f9039810cc0319c782 (patch)
tree9079f0081c31b320785d905432034971932d6d38 /Platform/Marvell/Drivers
parent19eae6ed3397f79b5d9ad682e8adf1cac35e3acb (diff)
downloadedk2-platforms-fedad0018dff31e6581875f9039810cc0319c782.tar.xz
Marvell/Applications: SpiTool: Do not override existing slave device
Current usage of sf command requires running 'sf probe' prior to executing any other option. Because it is done in two separate steps, it turned out that SpiMasterProtocol->SetupDevice could easily overwrite valid Slave pointer when performing second operation. Fix the issue by allocating Slave device only once and keep it as global variable in the SpiTool application. This patch also updates FirmwareUpdate command to follow the modified SetupDevice operation. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas <mw@semihalf.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Platform/Marvell/Drivers')
-rwxr-xr-xPlatform/Marvell/Drivers/Spi/MvSpiDxe.c17
-rw-r--r--Platform/Marvell/Drivers/Spi/MvSpiDxe.h1
2 files changed, 10 insertions, 8 deletions
diff --git a/Platform/Marvell/Drivers/Spi/MvSpiDxe.c b/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
index 3b491479ec..a7db5f2a2e 100755
--- a/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
+++ b/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
@@ -296,21 +296,22 @@ SPI_DEVICE *
EFIAPI
MvSpiSetupSlave (
IN MARVELL_SPI_MASTER_PROTOCOL *This,
+ IN SPI_DEVICE *Slave,
IN UINTN Cs,
IN SPI_MODE Mode
)
{
- SPI_DEVICE *Slave;
+ if (!Slave) {
+ Slave = AllocateZeroPool (sizeof(SPI_DEVICE));
+ if (Slave == NULL) {
+ DEBUG((DEBUG_ERROR, "Cannot allocate memory\n"));
+ return NULL;
+ }
- Slave = AllocateZeroPool (sizeof(SPI_DEVICE));
- if (Slave == NULL) {
- DEBUG((DEBUG_ERROR, "Cannot allocate memory\n"));
- return NULL;
+ Slave->Cs = Cs;
+ Slave->Mode = Mode;
}
- Slave->Cs = Cs;
- Slave->Mode = Mode;
-
SpiSetupTransfer (This, Slave);
return Slave;
diff --git a/Platform/Marvell/Drivers/Spi/MvSpiDxe.h b/Platform/Marvell/Drivers/Spi/MvSpiDxe.h
index 1401f6207b..e7e280a799 100644
--- a/Platform/Marvell/Drivers/Spi/MvSpiDxe.h
+++ b/Platform/Marvell/Drivers/Spi/MvSpiDxe.h
@@ -125,6 +125,7 @@ SPI_DEVICE *
EFIAPI
MvSpiSetupSlave (
IN MARVELL_SPI_MASTER_PROTOCOL * This,
+ IN SPI_DEVICE *Slave,
IN UINTN Cs,
IN SPI_MODE Mode
);