]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spi: xilinx_spi: Increment tx and rx pointers only if they are valid
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Fri, 4 May 2018 11:53:50 +0000 (17:23 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 9 May 2018 10:08:25 +0000 (12:08 +0200)
This patch increments tx and rx buf pointers only if they are valid,
otherwise, they dont need to be incremented and its of no use.
Moreover, this patch fixes the issue of inconsistent processor
hang on AC701 while performing operations to spi flash due to these
incorrect operations on rxbuf when it is null.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/spi/xilinx_spi.c

index 1f00866692e33e07d409a296fdcaa390354ad0d6..558b8ad65bb2c1e7ffa38c813ee3fcd70cb5d24d 100644 (file)
@@ -268,7 +268,8 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen,
                reg = readl(&regs->spicr) & ~SPICR_MASTER_INHIBIT;
                writel(reg, &regs->spicr);
                txbytes -= count;
-               txp += count;
+               if (txp)
+                       txp += count;
 
                timeout = 10000000;
                do {
@@ -283,7 +284,8 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen,
                debug("txbytes:0x%x,txp:0x%p\n", txbytes, txp);
                count = xilinx_spi_read_rxfifo(bus, rxp, rxbytes);
                rxbytes -= count;
-               rxp += count;
+               if (rxp)
+                       rxp += count;
                debug("rxbytes:0x%x rxp:0x%p\n", rxbytes, rxp);
        }