From d66f74cc6af5631e054e9e5c45b3ab719c39bf80 Mon Sep 17 00:00:00 2001 From: Siva Durga Prasad Paladugu Date: Fri, 4 May 2018 17:23:50 +0530 Subject: [PATCH] spi: xilinx_spi: Increment tx and rx pointers only if they are valid 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 Signed-off-by: Michal Simek --- drivers/spi/xilinx_spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c index 1f00866692e..558b8ad65bb 100644 --- a/drivers/spi/xilinx_spi.c +++ b/drivers/spi/xilinx_spi.c @@ -268,7 +268,8 @@ static int xilinx_spi_xfer(struct udevice *dev, unsigned int bitlen, reg = readl(®s->spicr) & ~SPICR_MASTER_INHIBIT; writel(reg, ®s->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); } -- 2.47.3