summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2021-07-01 16:36:49 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-03 02:35:18 +0000
commit4af47d62b4af78f951b0f8b29a1a116277b94c10 (patch)
tree60afd4182f21a5fcae24b49e4aead3dacb9a91db /common
parentac22128c48651d330fc1ffdc69afee5ecc79b051 (diff)
downloadchrome-ec-4af47d62b4af78f951b0f8b29a1a116277b94c10.tar.gz
cbi: Add cbi_get_cache_status()
Implement a new API cbi_get_cache_status() for us to probe CBI cache status in unit tests and anywhere else. BRANCH=None BUG=b:186264627 TEST=make buildall -j Signed-off-by: Philip Chen <philipchen@google.com> Change-Id: Ibe3af7df4f04abe2d65b31f2d604dbb6044e5863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3002448 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/cbi.c13
-rw-r--r--common/cbi_eeprom.c1
2 files changed, 9 insertions, 5 deletions
diff --git a/common/cbi.c b/common/cbi.c
index 27deac5c4e..9e6aa2cda1 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -100,6 +100,11 @@ void cbi_invalidate_cache(void)
cache_status = CBI_CACHE_STATUS_INVALID;
}
+int cbi_get_cache_status(void)
+{
+ return cache_status;
+}
+
static int do_cbi_read(void)
{
CPRINTS("Reading board info");
@@ -153,7 +158,7 @@ static int cbi_read(void)
int i;
int rv;
- if (cache_status == CBI_CACHE_STATUS_SYNCED)
+ if (cbi_get_cache_status() == CBI_CACHE_STATUS_SYNCED)
return EC_SUCCESS;
for (i = 0; i < 2; i++) {
@@ -421,8 +426,8 @@ static void dump_cbi(void)
cbi_invalidate_cache();
cbi_read();
- if (cache_status != CBI_CACHE_STATUS_SYNCED) {
- ccprintf("Cannot Read CBI (Error %d)\n", cache_status);
+ if (cbi_get_cache_status() != CBI_CACHE_STATUS_SYNCED) {
+ ccprintf("Cannot Read CBI (Error %d)\n", cbi_get_cache_status());
return;
}
@@ -455,7 +460,7 @@ static int cc_cbi(int argc, char **argv)
if (argc == 1) {
dump_cbi();
- if (cache_status == CBI_CACHE_STATUS_SYNCED)
+ if (cbi_get_cache_status() == CBI_CACHE_STATUS_SYNCED)
hexdump(cbi, CBI_IMAGE_SIZE);
return EC_SUCCESS;
}
diff --git a/common/cbi_eeprom.c b/common/cbi_eeprom.c
index 807b0ebc29..fe52bcd9f3 100644
--- a/common/cbi_eeprom.c
+++ b/common/cbi_eeprom.c
@@ -21,7 +21,6 @@
*/
#define EEPROM_PAGE_WRITE_SIZE 8
#define EEPROM_PAGE_WRITE_MS 5
-#define EC_ERROR_CBI_CACHE_INVALID EC_ERROR_INTERNAL_FIRST
static int eeprom_read(uint8_t offset, uint8_t *data, int len)
{