diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2010-12-16 14:11:17 +0800 |
---|---|---|
committer | Che-Liang Chiou <clchiou@chromium.org> | 2010-12-16 14:11:17 +0800 |
commit | 5d9509cbdee7b9c8dd91ed47d967569dbb9af83d (patch) | |
tree | 8059f69040daa6b8b07415f60c49e36b158f2ae6 /firmware/stub/tpm_lite_stub.c | |
parent | 9880ca5a03b72019c667b4492214830f9d355778 (diff) | |
download | vboot-5d9509cbdee7b9c8dd91ed47d967569dbb9af83d.tar.gz |
vboot TPM stub functions return error codes
TlclStubInit, TlclCloseDevice, and TlclOpenDevice were void functions but
should return error codes.
BUG=chromium-os:6695
TEST=RUNTESTS=1 make && emerge successfully
Review URL: http://codereview.chromium.org/5796005
Change-Id: I8ddbf8b1f080d98ff6ed42c4a675fbda5b17eef1
Diffstat (limited to 'firmware/stub/tpm_lite_stub.c')
-rw-r--r-- | firmware/stub/tpm_lite_stub.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c index 2695fae3..2351ee47 100644 --- a/firmware/stub/tpm_lite_stub.c +++ b/firmware/stub/tpm_lite_stub.c @@ -99,22 +99,25 @@ POSSIBLY_UNUSED static INLINE int TpmResponseSize(const uint8_t* buffer) { } -void TlclStubInit(void) { - TlclOpenDevice(); +uint32_t TlclStubInit(void) { + return TlclOpenDevice(); } -void TlclCloseDevice(void) { - close(tpm_fd); - tpm_fd = -1; +uint32_t TlclCloseDevice(void) { + if (tpm_fd != -1) { + close(tpm_fd); + tpm_fd = -1; + } + return 0; } -void TlclOpenDevice(void) { +uint32_t TlclOpenDevice(void) { char* device_path; if (tpm_fd >= 0) - return; /* Already open */ + return 0; /* Already open */ device_path = getenv("TPM_DEVICE_PATH"); if (device_path == NULL) { @@ -123,8 +126,12 @@ void TlclOpenDevice(void) { tpm_fd = open(device_path, O_RDWR); if (tpm_fd < 0) { - error("cannot open TPM device %s: %s\n", device_path, strerror(errno)); + VBDEBUG(("TPM: Cannot open TPM device %s: %s\n", device_path, + strerror(errno))); + return TPM_E_IOERROR; } + + return 0; } |