From: Eli Billauer Date: Sat, 15 Mar 2014 22:40:29 +0200 Subject: [U-Boot] [PATCH] fpga: zynqpl: Fixed bug in alignment routine Message-ID: <1394916029-12079-1-git-send-email-eli.billauer@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The aligned buffer is always with a higher address, so copying should run from the end of the buffer to the beginning, and not the other way around. Signed-off-by: Eli Billauer --- drivers/fpga/zynqpl.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c index 160abc7..2888131 100644 --- a/drivers/fpga/zynqpl.c +++ b/drivers/fpga/zynqpl.c @@ -173,7 +173,8 @@ int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize) { unsigned long ts; /* Timestamp */ u32 partialbit = 0; - u32 i, control, isr_status, status, swap, diff; + u32 control, isr_status, status, swap, diff; + int i; u32 *buf_start; /* Detect if we are going working with partial or full bitstream */ @@ -206,7 +207,7 @@ int zynq_load(Xilinx_desc *desc, const void *buf, size_t bsize) printf("%s: Align buffer at %x to %x(swap %d)\n", __func__, (u32)buf_start, (u32)new_buf, swap); - for (i = 0; i < (bsize/4); i++) + for (i = (bsize/4)-1; i >= 0 ; i--) new_buf[i] = load_word(&buf_start[i], swap); swap = SWAP_DONE; -- 1.7.2.3