diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-07-18 11:05:14 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-07-18 18:14:47 -0700 |
commit | 9a8223a8db69b036f783493bb5c96465ce176bbf (patch) | |
tree | 64998c9b7c83bfd9e7b3f303dc8ff11f7f643438 /common | |
parent | 1a76325fa8ec6256946598e0e41e17262d8d9198 (diff) | |
download | chrome-ec-9a8223a8db69b036f783493bb5c96465ce176bbf.tar.gz |
Remove flash_read()
Everything now uses flash_dataptr() to get at flash memory rather than
calling the read function, since the read function adds a needless memcpy().
BUG=chrome-os-partner:11150
TEST=manual
flashwp enable
reboot
flashinfo -> should show ro_at_boot
flashwp disable
reboot
flashinfo -> should no longer show ro_at_boot
Change-Id: I1830e2f036cf6777115c782c1737335ff2eb4ce0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27796
Diffstat (limited to 'common')
-rw-r--r-- | common/flash_common.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/common/flash_common.c b/common/flash_common.c index c011e0ab25..26d017db87 100644 --- a/common/flash_common.c +++ b/common/flash_common.c @@ -68,21 +68,23 @@ static int wp_pin_asserted(void) static int read_pstate(void) { #ifdef CHIP_stm32 - memset(&pstate, 0, sizeof(pstate)); - pstate.version = PERSIST_STATE_VERSION; + memset(&pstate, 0, sizeof(pstate)); + pstate.version = PERSIST_STATE_VERSION; + return EC_SUCCESS; #else - int rv = flash_physical_read(PSTATE_OFFSET, sizeof(pstate), - (char *)&pstate); - if (rv) - return rv; + const char *flash_pstate = flash_physical_dataptr(PSTATE_OFFSET); + + if (flash_pstate) + memcpy(&pstate, flash_pstate, sizeof(pstate)); /* Sanity-check data and initialize if necessary */ - if (pstate.version != PERSIST_STATE_VERSION) { + if (pstate.version != PERSIST_STATE_VERSION || !flash_pstate) { memset(&pstate, 0, sizeof(pstate)); pstate.version = PERSIST_STATE_VERSION; } + + return flash_pstate ? EC_SUCCESS : EC_ERROR_UNKNOWN; #endif /* CHIP_stm32 */ - return EC_SUCCESS; } /* Write persistent state from pstate, erasing if necessary. */ @@ -153,14 +155,6 @@ int flash_dataptr(int offset, int size_req, int align, char **ptrp) return CONFIG_FLASH_SIZE - offset; } -int flash_read(int offset, int size, char *data) -{ - if (flash_dataptr(offset, size, 1, NULL) < 0) - return EC_ERROR_INVAL; /* Invalid range */ - - return flash_physical_read(offset, size, data); -} - int flash_write(int offset, int size, const char *data) { if (flash_dataptr(offset, size, flash_get_write_block_size(), @@ -193,6 +187,8 @@ int flash_enable_protect(int enable) int rv; /* Fail if write protect block is already locked */ + /* TODO: and in the wrong state... if it's asking to enable and we're + * already enabled, we can just succeed... */ if (flash_physical_get_protect(PSTATE_BANK)) return EC_ERROR_UNKNOWN; |