summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nor
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-19 11:14:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-22 09:27:59 +0200
commit6be93f2fcee7282c7c484e89e6cafd09e0fa515c (patch)
tree9668ed9916bc7cc954ccd3bd342db5b05a0d040a /drivers/mtd/nor
parent9c48ac000b795e0d5fe3ca000d0786b9552b167e (diff)
downloadbarebox-6be93f2fcee7282c7c484e89e6cafd09e0fa515c.tar.gz
barebox-6be93f2fcee7282c7c484e89e6cafd09e0fa515c.tar.xz
mtd: cfi-flash: use unaligned accessor functions
Some members in struct cfi_qry are unaligned. Use get_unaligned_* to access them. Fixes unaligned aborts on busses which don't support unaligned accesses. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/nor')
-rw-r--r--drivers/mtd/nor/cfi_flash.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index eb167493cc..021f3b9f90 100644
--- a/drivers/mtd/nor/cfi_flash.c
+++ b/drivers/mtd/nor/cfi_flash.c
@@ -40,6 +40,7 @@
#include <errno.h>
#include <progress.h>
#include <linux/err.h>
+#include <asm/unaligned.h>
#include "cfi_flash.h"
/*
@@ -257,8 +258,8 @@ static int flash_detect_width(struct flash_info *info, struct cfi_qry *qry)
found:
flash_read_cfi(info, qry, FLASH_OFFSET_CFI_RESP,
sizeof(struct cfi_qry));
- info->interface = le16_to_cpu(qry->interface_desc);
- info->cfi_offset=flash_offset_cfi[cfi_offset];
+ info->interface = get_unaligned_le16(&qry->interface_desc);
+ info->cfi_offset = flash_offset_cfi[cfi_offset];
dev_dbg(info->dev, "device interface is %d\n", info->interface);
dev_dbg(info->dev, "found port %d chip %d chip_lsb %d ",
info->portwidth, info->chipwidth, info->chip_lsb);
@@ -317,8 +318,8 @@ static int flash_detect_size(struct flash_info *info)
if (ret)
return ret;
- info->vendor = le16_to_cpu(qry.p_id);
- info->ext_addr = le16_to_cpu(qry.p_adr);
+ info->vendor = get_unaligned_le16(&qry.p_id);
+ info->ext_addr = get_unaligned_le16(&qry.p_adr);
num_erase_regions = qry.num_erase_regions;
if (info->ext_addr) {
@@ -386,7 +387,7 @@ static int flash_detect_size(struct flash_info *info)
break;
}
- tmp = le32_to_cpu(qry.erase_region_info[i]);
+ tmp = get_unaligned_le32(&qry.erase_region_info[i]);
dev_dbg(info->dev, "erase region %u: 0x%08lx\n", i, tmp);
erase_region_count = (tmp & 0xffff) + 1;
@@ -431,7 +432,7 @@ static int flash_detect_size(struct flash_info *info)
info->sector_count = sect_cnt;
/* multiply the size by the number of chips */
info->size = (1 << qry.dev_size) * size_ratio;
- info->buffer_size = (1 << le16_to_cpu(qry.max_buf_write_size));
+ info->buffer_size = (1 << get_unaligned_le16(&qry.max_buf_write_size));
info->erase_blk_tout = 1 << (qry.block_erase_timeout_typ +
qry.block_erase_timeout_max);
info->buffer_write_tout = 1 << (qry.buf_write_timeout_typ +