diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2012-09-24 09:46:37 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-09-24 16:29:03 -0700 |
commit | 210c5ef2d9d060bebf5020da886e2cabd6e05d6d (patch) | |
tree | a61ffb637115ec9dad314a4db22b5f059bb5031e /host | |
parent | be94d55d4f07c5052b04ac3982314e6e588fc361 (diff) | |
download | vboot-210c5ef2d9d060bebf5020da886e2cabd6e05d6d.tar.gz |
crossystem should not grumble about older firmware
Older firmware does not provide nonvolatile-context-storage FDT
property, and crossystem complains about it.
This is harmless; so just make it quiet.
Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
BRANCH=none
BUG=chrome-os-partner:14475
TEST=manual, see blow
Run crossystem and make sure its output does not contain
"Unable to open FDT property nonvolatile-context-storage"
messages.
Check crossystem still works by comparing its output w/ and w/o this
change.
Change-Id: I0b8f40775833457a75d801f185344e931ac08847
Reviewed-on: https://gerrit.chromium.org/gerrit/33896
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'host')
-rw-r--r-- | host/arch/arm/lib/crossystem_arch.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 7120afe4..f0f7ed0a 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -34,6 +34,8 @@ /* Base name for GPIO files */ #define GPIO_BASE_PATH "/sys/class/gpio" #define GPIO_EXPORT_PATH GPIO_BASE_PATH "/export" +/* Name of NvStorage type property */ +#define FDT_NVSTORAGE_TYPE_PROP "nonvolatile-context-storage" /* Errors */ #define E_FAIL -1 #define E_FILEOP -2 @@ -102,6 +104,24 @@ static int ReadFdtInt(const char *property) { return value; } +static void GetFdtPropertyPath(const char *property, char *path, size_t size) { + if (property[0] == '/') + StrCopy(path, property, size); + else + snprintf(path, size, FDT_BASE_PATH "/%s", property); +} + +static int FdtPropertyExist(const char *property) { + char filename[FNAME_SIZE]; + struct stat file_status; + + GetFdtPropertyPath(property, filename, sizeof(filename)); + if (!stat(filename, &file_status)) + return 1; // It exists! + else + return 0; // It does not exist or some error happened. +} + static int ReadFdtBlock(const char *property, void **block, size_t *size) { char filename[FNAME_SIZE]; FILE *file; @@ -111,10 +131,7 @@ static int ReadFdtBlock(const char *property, void **block, size_t *size) { if (!block) return E_FAIL; - if (property[0] == '/') - StrCopy(filename, property, sizeof(filename)); - else - snprintf(filename, sizeof(filename), FDT_BASE_PATH "/%s", property); + GetFdtPropertyPath(property, filename, sizeof(filename)); file = fopen(filename, "rb"); if (!file) { fprintf(stderr, "Unable to open FDT property %s\n", property); @@ -445,9 +462,12 @@ static int VbWriteNvStorage_disk(VbNvContext* vnc) { } int VbReadNvStorage(VbNvContext* vnc) { - char *media = ReadFdtString("nonvolatile-context-storage"); /* Default to disk for older firmware which does not provide storage type */ - if (!media || !strcmp(media, "disk")) + char *media; + if (!FdtPropertyExist(FDT_NVSTORAGE_TYPE_PROP)) + return VbReadNvStorage_disk(vnc); + media = ReadFdtString(FDT_NVSTORAGE_TYPE_PROP); + if (!strcmp(media, "disk")) return VbReadNvStorage_disk(vnc); if (!strcmp(media, "mkbp")) return VbReadNvStorage_mkbp(vnc); @@ -455,9 +475,12 @@ int VbReadNvStorage(VbNvContext* vnc) { } int VbWriteNvStorage(VbNvContext* vnc) { - char *media = ReadFdtString("nonvolatile-context-storage"); /* Default to disk for older firmware which does not provide storage type */ - if (!media || !strcmp(media, "disk")) + char *media; + if (!FdtPropertyExist(FDT_NVSTORAGE_TYPE_PROP)) + return VbWriteNvStorage_disk(vnc); + media = ReadFdtString(FDT_NVSTORAGE_TYPE_PROP); + if (!strcmp(media, "disk")) return VbWriteNvStorage_disk(vnc); if (!strcmp(media, "mkbp")) return VbWriteNvStorage_mkbp(vnc); |