From 7e04b31e65a319de710515231df4d734d3ec6b15 Mon Sep 17 00:00:00 2001 From: Ingo Donasch Date: Sat, 3 Jan 2015 10:01:13 +1300 Subject: [PATCH] pif: fix flash address range. --- drivers/pif.c | 8 ++------ drivers/pif.h | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pif.c b/drivers/pif.c index 02f53ad..202ffa3 100644 --- a/drivers/pif.c +++ b/drivers/pif.c @@ -106,9 +106,7 @@ static int write_byte( struct jtdev *p, read_words(p, aligned, 2, data); data[addr & 1] = value; - if ( (addr >= 0x1000 && addr <= 0x10ff) - || - addr >= 0x4000) { + if ( ADDR_IN_FLASH(addr) ) { /* program in FLASH */ write_flash_block(p, aligned, 2, data); } else { @@ -212,9 +210,7 @@ static int pif_writemem( device_t dev_base, /* Write aligned blocks */ while (len >= 2) { - if ( (addr >= 0x1000 && addr <= 0x10ff) - || - addr >= 0x4000) { + if ( ADDR_IN_FLASH(addr) ) { if (write_flash_block(&dev->jtag, addr, len & ~1, mem) < 0) return -1; addr += len & ~1; diff --git a/drivers/pif.h b/drivers/pif.h index a39c8ac..b9151de 100644 --- a/drivers/pif.h +++ b/drivers/pif.h @@ -28,6 +28,8 @@ #include "device.h" +#define ADDR_IN_FLASH(a) ( (a) >= 0x1000 ) + /* pif implementation */ extern const struct device_class device_pif;