diff options
author | Edward O'Callaghan <eocallaghan@alterapraxis.com> | 2014-05-24 04:09:50 +1000 |
---|---|---|
committer | Edward O'Callaghan <eocallaghan@alterapraxis.com> | 2015-01-06 04:56:14 +0100 |
commit | 9270553fff23462fcb298f154296319bf3639d15 (patch) | |
tree | 2ba8245407efd91d8862cbe7ac333d46cfd4390a /src/include/spi_flash.h | |
parent | 089a51029221ddceb0cf61daecb275971d2b2f22 (diff) |
Re-factor 'to_flash_offset()' into 'spi_flash.h'
Re-factor to_flash_offset() into 'spi_flash.h' header. Motivated by
Clang complaining that the function 'to_flash_offset' is unused.
Change-Id: Ic75fd2fb4edc5e434c199ebd10c7384d197e0c63
Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-on: http://review.coreboot.org/7519
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/include/spi_flash.h')
-rw-r--r-- | src/include/spi_flash.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h index 70ca784c90..1a78b5a904 100644 --- a/src/include/spi_flash.h +++ b/src/include/spi_flash.h @@ -76,4 +76,15 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, return flash->erase(flash, offset, len); } +#if !defined(__PRE_RAM__) +/* convert a pointer to flash area into the offset inside the flash */ +static inline u32 to_flash_offset(struct spi_flash *flash, void *p) { +#if defined(CONFIG_VIRTUAL_ROM_SIZE) + return ((u32)p + CONFIG_VIRTUAL_ROM_SIZE); +#else + return ((u32)p + flash->size); +#endif /* defined(CONFIG_VIRTUAL_ROM_SIZE) */ +} +#endif /* !defined(__PRE_RAM__) */ + #endif /* _SPI_FLASH_H_ */ |