Revert "Re-factor 'to_flash_offset()' into 'spi_flash.h'"

This reverts commit 9270553fff.

Change-Id: I195f721ce7a18aac6c1aa6f4e0f9284455d531b0
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/8138
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
This commit is contained in:
Kyösti Mälkki
2015-01-06 07:08:46 +01:00
committed by Edward O'Callaghan
parent 6355cbff51
commit 9b29aad526
6 changed files with 42 additions and 19 deletions

View File

@@ -46,6 +46,12 @@ static int nvm_init(void)
return 0;
}
/* Convert memory mapped pointer to flash offset. */
static inline uint32_t to_flash_offset(void *p)
{
return CONFIG_ROM_SIZE + (uintptr_t)p;
}
int nvm_is_erased(const void *start, size_t size)
{
const uint8_t *cur = start;
@@ -64,7 +70,7 @@ int nvm_erase(void *start, size_t size)
{
if (nvm_init() < 0)
return -1;
return flash->erase(flash, to_flash_offset(flash, start), size);
return flash->erase(flash, to_flash_offset(start), size);
}
/* Write data to NVM. Returns 0 on success < 0 on error. */
@@ -72,5 +78,5 @@ int nvm_write(void *start, const void *data, size_t size)
{
if (nvm_init() < 0)
return -1;
return flash->write(flash, to_flash_offset(flash, start), size, data);
return flash->write(flash, to_flash_offset(start), size, data);
}