[U-Boot] [PATCH 1/4] Exynos: SPI: Fix reading data from SPI flash
Simon Glass
sjg at chromium.org
Mon Jun 2 17:45:32 CEST 2014
Hi Akshay,
On 30 May 2014 07:45, Akshay Saraswat <akshay.s at samsung.com> wrote:
> 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 at samsung.com>
> ---
> drivers/spi/exynos_spi.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
> index 4d5def2..b9fd618 100644
> --- a/drivers/spi/exynos_spi.c
> +++ b/drivers/spi/exynos_spi.c
> @@ -302,6 +302,9 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo,
> }
> } else {
> if (rxp || stopping) {
> + *(rxp + 3) = (temp >> 24);
> + *(rxp + 2) = (temp >> 16);
> + *(rxp + 1) = (temp >> 8);
> *rxp = temp;
> rxp += step;
Here step is either 1 (bytes) or 4 (words). So I think you are making
an assumption here. If you look up a bit you can see what it does for
txp (two cases for step being 1 or 4) and I think you should do the
same here.
Regards,
Simon
More information about the U-Boot
mailing list