diff options
author | Yuval Peress <peress@chromium.org> | 2021-01-14 01:29:08 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-15 04:07:55 +0000 |
commit | 9e422c3c05fdd324565049b09be27c446f9dc0ca (patch) | |
tree | b4694ca5abc8c1be1000a1efe7a7bd8a02ddd856 /common/flash.c | |
parent | 6aa3d78608b681e6374f30747a7f6ab80938bde6 (diff) | |
download | chrome-ec-9e422c3c05fdd324565049b09be27c446f9dc0ca.tar.gz |
Refactor CONFIG_FLASH_SIZE to CONFIG_FLASH_SIZE_BYTES
In Zephyr CONFIG_FLASH_SIZE is a Kconfig value that is used
throughout. The issue is that the units don't match. In
Zephyr the value is in KiB instead of bytes. This refactor
simply renames CONFIG_FLASH_SIZE in platform/ec to include
the unit (via _BYTES).
BRANCH=none
BUG=b:174873770
TEST=make buildall
be generated by the build instead of per board
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I44bf3c7a20fcf62aaa9ae15715be78db4210f384
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2627638
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/flash.c')
-rw-r--r-- | common/flash.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/common/flash.c b/common/flash.c index 235121f51e..ab3cd23df0 100644 --- a/common/flash.c +++ b/common/flash.c @@ -218,9 +218,9 @@ int flash_bank_start_offset(int bank) static int flash_range_ok(int offset, int size_req, int align) { if (offset < 0 || size_req < 0 || - offset > CONFIG_FLASH_SIZE || - size_req > CONFIG_FLASH_SIZE || - offset + size_req > CONFIG_FLASH_SIZE || + offset > CONFIG_FLASH_SIZE_BYTES || + size_req > CONFIG_FLASH_SIZE_BYTES || + offset + size_req > CONFIG_FLASH_SIZE_BYTES || (offset | size_req) & (align - 1)) return 0; /* Invalid range */ @@ -251,7 +251,7 @@ int flash_dataptr(int offset, int size_req, int align, const char **ptrp) if (ptrp) *ptrp = flash_physical_dataptr(offset); - return CONFIG_FLASH_SIZE - offset; + return CONFIG_FLASH_SIZE_BYTES - offset; } #endif @@ -979,7 +979,7 @@ static int command_flash_info(int argc, char **argv) { int i, flags; - ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE / 1024); + ccprintf("Usable: %4d KB\n", CONFIG_FLASH_SIZE_BYTES / 1024); ccprintf("Write: %4d B (ideal %d B)\n", CONFIG_FLASH_WRITE_SIZE, CONFIG_FLASH_WRITE_IDEAL_SIZE); #ifdef CONFIG_FLASH_MULTIPLE_REGION @@ -1234,7 +1234,7 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) #error "Flash: Bank size expected bigger or equal to erase size." #endif struct ec_flash_bank single_bank = { - .count = CONFIG_FLASH_SIZE / CONFIG_FLASH_BANK_SIZE, + .count = CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE, .size_exp = __fls(CONFIG_FLASH_BANK_SIZE), .write_size_exp = __fls(CONFIG_FLASH_WRITE_SIZE), .erase_size_exp = __fls(CONFIG_FLASH_ERASE_SIZE), @@ -1265,7 +1265,8 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) if (args->version >= 2) { args->response_size = sizeof(struct ec_response_flash_info_2); - r_2->flash_size = CONFIG_FLASH_SIZE - EC_FLASH_REGION_START; + r_2->flash_size = + CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START; #if (CONFIG_FLASH_ERASED_VALUE32 == 0) r_2->flags = EC_FLASH_INFO_ERASE_TO_0; #else @@ -1285,7 +1286,7 @@ static enum ec_status flash_command_get_info(struct host_cmd_handler_args *args) #ifdef CONFIG_FLASH_MULTIPLE_REGION return EC_RES_INVALID_PARAM; #else - r_1->flash_size = CONFIG_FLASH_SIZE - EC_FLASH_REGION_START; + r_1->flash_size = CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START; r_1->flags = 0; r_1->write_block_size = CONFIG_FLASH_WRITE_SIZE; r_1->erase_block_size = CONFIG_FLASH_ERASE_SIZE; |