]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: zynq_qspi: Typecast rxbuf properly
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Mon, 31 Jan 2022 05:22:37 +0000 (22:22 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 4 Feb 2022 12:20:10 +0000 (13:20 +0100)
This patch typecasts and accesses rx buf properly as
an unaligned rxbuf, typecasting with u16 and accessing
it causes data abort exception and this patch fixes it.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Link: https://lore.kernel.org/r/20220131052240.23403-2-ashok.reddy.soma@xilinx.com
drivers/spi/zynq_qspi.c

index cf6da5340a77de97e0ebd62af254f1626f6aad6d..34d39d66fb1bfb297278563e6e68ba5743ce5d26 100644 (file)
@@ -230,12 +230,16 @@ static void zynq_qspi_read_data(struct zynq_qspi_priv *priv, u32 data, u8 size)
                        priv->rx_buf += 1;
                        break;
                case 2:
-                       *((u16 *)priv->rx_buf) = data;
-                       priv->rx_buf += 2;
+                       *((u8 *)priv->rx_buf) = data;
+                       priv->rx_buf += 1;
+                       *((u8 *)priv->rx_buf) = (u8)(data >> 8);
+                       priv->rx_buf += 1;
                        break;
                case 3:
-                       *((u16 *)priv->rx_buf) = data;
-                       priv->rx_buf += 2;
+                       *((u8 *)priv->rx_buf) = data;
+                       priv->rx_buf += 1;
+                       *((u8 *)priv->rx_buf) = (u8)(data >> 8);
+                       priv->rx_buf += 1;
                        byte3 = (u8)(data >> 16);
                        *((u8 *)priv->rx_buf) = byte3;
                        priv->rx_buf += 1;