summaryrefslogtreecommitdiff
path: root/firmware/stub/tpm_lite_stub.c
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2010-12-16 14:11:17 +0800
committerChe-Liang Chiou <clchiou@chromium.org>2010-12-16 14:11:17 +0800
commit5d9509cbdee7b9c8dd91ed47d967569dbb9af83d (patch)
tree8059f69040daa6b8b07415f60c49e36b158f2ae6 /firmware/stub/tpm_lite_stub.c
parent9880ca5a03b72019c667b4492214830f9d355778 (diff)
downloadvboot-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.c23
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;
}