diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2018-11-26 15:52:51 +0100 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2018-12-06 09:40:19 +0000 |
commit | 9d67f00670f861335f5dad1b2e03b3871e76545c (patch) | |
tree | 92170b74bea70319b7da9e25aa49fcff680c02d4 /src/flash/nor/stmsmi.c | |
parent | 82dd17e2488ae233d8818901ec6f07525694e55e (diff) |
flash/stmsmi: fix byte order for big-endian host
The original code was written for and tested on little-endian
host only.
Rewrite it to be independent by host endianess.
Not tested on real HW; I don't own anymore a SPEAr device.
Change-Id: I2f427a804693f56cb9dea4936c525eb814c48c28
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4778
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src/flash/nor/stmsmi.c')
-rw-r--r-- | src/flash/nor/stmsmi.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/flash/nor/stmsmi.c b/src/flash/nor/stmsmi.c index 92256100..4d38e949 100644 --- a/src/flash/nor/stmsmi.c +++ b/src/flash/nor/stmsmi.c @@ -269,17 +269,14 @@ static int smi_write_enable(struct flash_bank *bank) static uint32_t erase_command(struct stmsmi_flash_bank *stmsmi_info, uint32_t offset) { - union { - uint32_t command; - uint8_t x[4]; - } cmd; - - cmd.x[0] = stmsmi_info->dev->erase_cmd; - cmd.x[1] = offset >> 16; - cmd.x[2] = offset >> 8; - cmd.x[3] = offset; - - return cmd.command; + uint8_t cmd_bytes[] = { + stmsmi_info->dev->erase_cmd, + offset >> 16, + offset >> 8, + offset + }; + + return le_to_h_u32(cmd_bytes); } static int smi_erase_sector(struct flash_bank *bank, int sector) |