diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-08-27 09:09:53 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-28 20:12:52 +0000 |
commit | b7f1d5261917c88e734d0e788de74b2bc419c431 (patch) | |
tree | 5d238902410b955e3b58e6217392f6013d75fe35 /common/version.c | |
parent | 9d0bb00192d460ef0a445040bf245a4840d38fbb (diff) | |
download | chrome-ec-b7f1d5261917c88e734d0e788de74b2bc419c431.tar.gz |
zinger: samus_pd: change zinger SW ver to report commit count
Change the zinger software version returned by VDO_CMD_READ_INFO
to report the commit count portion of the version string to make
the software version automatically change. This software version
is important for debugging and is printed to PD console every time
a zinger is attached.
BUG=none
BRANCH=none
TEST=load onto zinger and samus, plug in zinger and see:
Dev:1 SW:2147 RW:0
compare to the version string in zinger binary and we see:
zinger_v1.1.2147-...
Change-Id: Ieafe89b4b16cee076be17bcbc6774bbd7fc24f8e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214428
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/version.c')
-rw-r--r-- | common/version.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/common/version.c b/common/version.c index a2f554e58d..766b4ad56b 100644 --- a/common/version.c +++ b/common/version.c @@ -18,3 +18,34 @@ const struct version_struct version_data const char build_info[] __attribute__((section(".rodata.buildinfo"))) = CROS_EC_VERSION " " DATE " " BUILDER; + +uint32_t ver_get_numcommits(void) +{ + int i; + int numperiods = 0; + uint32_t ret = 0; + + /* + * Version string is formatted like: + * name_major.branch.numcommits-hash[dirty] + * we want to return the numcommits as an int. + */ + for (i = 0; i < 32; i++) { + if (version_data.version[i] == '.') { + numperiods++; + if (numperiods == 2) + break; + } + } + + i++; + for (; i < 32; i++) { + if (version_data.version[i] == '-') + break; + ret *= 10; + ret += version_data.version[i] - '0'; + } + + return (i == 32 ? 0 : ret); +} + |