From: Jerry Van Baren Date: Wed, 12 Dec 2007 08:23:00 -0500 Subject: [U-Boot-Users] [PATCH 2/4] cfi_flash: Introduce read and write accessors In-Reply-To: <1197464966-19943-3-git-send-email-hskinnemoen@atmel.com> References: <1197464966-19943-1-git-send-email-hskinnemoen@atmel.com> <1197464966-19943-2-git-send-email-hskinnemoen@atmel.com> <1197464966-19943-3-git-send-email-hskinnemoen@atmel.com> Message-ID: <475FE0B4.9000401@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Haavard Skinnemoen wrote: > Introduce flash_read{8,16,32,64) and flash_write{8,16,32,64} and use > them to access the flash memory. This makes it clearer when the flash > is actually being accessed; merely dereferencing a volatile pointer > looks just like any other kind of access. > > Signed-off-by: Haavard Skinnemoen > --- > drivers/mtd/cfi_flash.c | 205 +++++++++++++++++++++++++++++------------------ > 1 files changed, 127 insertions(+), 78 deletions(-) > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c > index a89fcae..d33725d 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -149,13 +149,6 @@ typedef union { > unsigned long long ll; > } cfiword_t; > > -typedef union { > - volatile unsigned char *cp; > - volatile unsigned short *wp; > - volatile unsigned long *lp; > - volatile unsigned long long *llp; > -} cfiptr_t; > - > #define NUM_ERASE_REGIONS 4 /* max. number of erase regions */ > > static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT }; > @@ -178,6 +171,48 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* FLASH chips info */ > > typedef unsigned long flash_sect_t; > > +static void flash_write8(u8 value, void *addr) > +{ > + __raw_writeb(value, addr); > +} Hi Haavard, Should you make the flash_write*() functions inline? gvb