util: Add a new utility 'vpd_get_value' that speeds up value reading.

There may be more and more upstart jobs (or scripts) need to fetch
VPD values. In comparison to the huge dump_vpd_log, which was solely
designed for creating the cache (and full-report), many scripts simply
want to read one single value and needs an optimized version of utility
helping to read from VPD, no matter if it's from /sys (available on
recent devices) or legacy cache.

This script tries to optimize and hide all logic so it should be the
fastest way to read one single VPD entry.

BRANCH=none
BUG=chromium:650897
TEST=time vpd_get_value serial_number # on Link, real = 0.005s
     time (dump_vpd_log --full --stdout | grep 'serial_number') # 0.085s

Change-Id: Ie231cb539f9da8fd03c1dc31e54994f461c1c916
Reviewed-on: https://chromium-review.googlesource.com/417461
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
(cherry picked from commit 7445e10f95657dddc71271014a359c0b39eac600)
Reviewed-on: https://chromium-review.googlesource.com/440889
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
(cherry picked from commit ff7d70f2361c9c440fdb09d0702c3580e23b3cf2)
Reviewed-on: https://chromium-review.googlesource.com/c/1263024
Reviewed-by: Philip Chen <philipchen@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Trybot-Ready: Philip Chen <philipchen@chromium.org>
1 file changed
tree: b63cf97cc645d4bcf272ce793143dc2db2774737
  1. include/
  2. init/
  3. lib/
  4. tests/
  5. util/
  6. LICENSE
  7. Makefile
  8. OWNERS
  9. README
  10. vpd.c