]> git.sur5r.net Git - u-boot/commitdiff
Exynos: SPI: Fix reading data from SPI flash
authorAkshay Saraswat <akshay.s@samsung.com>
Wed, 18 Jun 2014 12:22:41 +0000 (17:52 +0530)
committerMinkyu Kang <mk7.kang@samsung.com>
Sun, 22 Jun 2014 22:47:05 +0000 (07:47 +0900)
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>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
drivers/spi/exynos_spi.c

index 4d5def2d3190fb5e5f15564362c27ac89ea5068d..c92276fdf7199acf1d42c16840a6b75f2ae22455 100644 (file)
@@ -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;