Skip to contentSkip to conversation

Exynos: SPI: Fix reading data from SPI flash

PATCH New Akshay Saraswat 2 participants 2 messages Jun 18, 2014 – Jun 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Exynos: SPI: Fix reading data from SPI flash

SPI recieve and transfer code in exynos_spi driver has a logical bug. We read data in a variable which can hold an integer. Then we assign this integer 32 bit value to another variable which has data type uchar. Latter represents a unit of our recieve buffer. Everytime when we write a value to our recieve buffer we step ahead by 4 units when actually we wrote to one unit. This results in the loss of 3 bytes out of every 4 bytes recieved. This patch intends to fix this bug.

---
Changes since v3:
- Rebased to top of Tree.
Changes since v2:
- Added "Acked-by" & "Tested-by".
- Changed assignment for *rxp.
Changes since v1:
- Added check for step.

 drivers/spi/exynos_spi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/exynos_spi.c +4 -1
index 4d5def2..c92276f 100644
@@ -302,7 +302,10 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo,
 					}
 				} else {
 					if (rxp || stopping) {
-						*rxp = temp;
+						if (step == 4)
+							*(uint32_t *)rxp = temp;
+						else
+							*rxp = temp;
 						rxp += step;
 					}
 					in_bytes -= step;
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH v4 1/1 Exynos: SPI: Fix reading data from SPI flash

Quoted 20 lines · Akshay Saraswat

SPI recieve and transfer code in exynos_spi driver has a logical bug. We read data in a variable which can hold an integer. Then we assign this integer 32 bit value to another variable which has data type uchar. Latter represents a unit of our recieve buffer. Everytime when we write a value to our recieve buffer we step ahead by 4 units when actually we wrote to one unit. This results in the loss of 3 bytes out of every 4 bytes recieved. This patch intends to fix this bug.

---
Changes since v3:
- Rebased to top of Tree.
Changes since v2:
- Added "Acked-by" & "Tested-by".
- Changed assignment for *rxp.
Changes since v1:
- Added check for step.

Quoted 3 lines
 drivers/spi/exynos_spi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

applied to u-boot-samsung.

Thanks,
Minkyu Kang.