summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiva Durga Prasad Paladugu <[email protected]>2022-01-30 22:22:38 -0700
committerMichal Simek <[email protected]>2022-02-04 13:20:12 +0100
commita5a387a421105e671ee86a257eccf4d68aa1e7e7 (patch)
treec00ab3bca2b6069e866c91eeed453128ed4c2388
parent255537b5adbdfa9eb0fe750c79ad089e7c0e3990 (diff)
spi: zynq_qspi: Read only one byte at a time from txbuf
Read only one byte at a time from txbuf as txbuf may not be aligned and accessing more than a byte at a time may cause alignment issues. This fixes the issue of data abort exception while writing to flash device. Signed-off-by: Siva Durga Prasad Paladugu <[email protected]> Signed-off-by: Michal Simek <[email protected]> Signed-off-by: Ashok Reddy Soma <[email protected]> Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--drivers/spi/zynq_qspi.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c
index 34d39d66fb1..aa060d7940a 100644
--- a/drivers/spi/zynq_qspi.c
+++ b/drivers/spi/zynq_qspi.c
@@ -276,13 +276,17 @@ static void zynq_qspi_write_data(struct zynq_qspi_priv *priv,
*data |= 0xFFFFFF00;
break;
case 2:
- *data = *((u16 *)priv->tx_buf);
- priv->tx_buf += 2;
+ *data = *((u8 *)priv->tx_buf);
+ priv->tx_buf += 1;
+ *data |= (*((u8 *)priv->tx_buf) << 8);
+ priv->tx_buf += 1;
*data |= 0xFFFF0000;
break;
case 3:
- *data = *((u16 *)priv->tx_buf);
- priv->tx_buf += 2;
+ *data = *((u8 *)priv->tx_buf);
+ priv->tx_buf += 1;
+ *data |= (*((u8 *)priv->tx_buf) << 8);
+ priv->tx_buf += 1;
*data |= (*((u8 *)priv->tx_buf) << 16);
priv->tx_buf += 1;
*data |= 0xFF000000;