public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4] Exynos: SPI: Fix reading data from SPI flash
@ 2014-06-18 12:22 Akshay Saraswat
  2014-06-23  8:43 ` Minkyu Kang
  0 siblings, 1 reply; 2+ messages in thread
From: Akshay Saraswat @ 2014-06-18 12:22 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Akshay Saraswat <akshay.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
---
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(-)

diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
index 4d5def2..c92276f 100644
--- a/drivers/spi/exynos_spi.c
+++ b/drivers/spi/exynos_spi.c
@@ -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;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-23  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 12:22 [U-Boot] [PATCH v4] Exynos: SPI: Fix reading data from SPI flash Akshay Saraswat
2014-06-23  8:43 ` Minkyu Kang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox