summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi-nor/fsl-flexspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/spi-nor/fsl-flexspi.c')
-rw-r--r--drivers/mtd/spi-nor/fsl-flexspi.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/mtd/spi-nor/fsl-flexspi.c b/drivers/mtd/spi-nor/fsl-flexspi.c
index a6ab4c22c6fe..7828b6b80c2e 100644
--- a/drivers/mtd/spi-nor/fsl-flexspi.c
+++ b/drivers/mtd/spi-nor/fsl-flexspi.c
@@ -1027,6 +1027,7 @@ static ssize_t fsl_flexspi_read(struct spi_nor *nor, loff_t from,
size_t len, u_char *buf)
{
struct fsl_flexspi *flex = nor->priv;
+ int i, j;
/* if necessary,ioremap buffer before AHB read, */
if (!flex->ahb_addr) {
@@ -1059,10 +1060,20 @@ static ssize_t fsl_flexspi_read(struct spi_nor *nor, loff_t from,
}
}
- /* Read out the data directly from the AHB buffer.*/
- memcpy(buf,
- flex->ahb_addr + flex->chip_base_addr + from - flex->memmap_offs,
- len);
+ /* For non-8-byte alignment cases */
+ if (from % 8) {
+ j = 8 - (from & 0x7);
+ for (i = 0; i < j; ++i) {
+ memcpy(buf + i, flex->ahb_addr + flex->chip_base_addr
+ + from - flex->memmap_offs + i, 1);
+ }
+ memcpy(buf + j, flex->ahb_addr + flex->chip_base_addr + from
+ - flex->memmap_offs + j, len - j);
+ } else {
+ /* Read out the data directly from the AHB buffer.*/
+ memcpy(buf, flex->ahb_addr + flex->chip_base_addr + from
+ - flex->memmap_offs, len);
+ }
return len;
}