Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: src/tlcl/tlcl.c

Issue 2822042: Add device open/close. (Closed) Base URL: ssh://git@chromiumos-git/tpm_lite.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/tlcl/tlcl.h ('k') | src/tlcl/version.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tlcl/tlcl.c
diff --git a/src/tlcl/tlcl.c b/src/tlcl/tlcl.c
index 631ecb0f13d7ef2d421a09b541b3302848ce65b9..1b22b43896146173ed9e3e3bcf4d3045157d1327 100644
--- a/src/tlcl/tlcl.c
+++ b/src/tlcl/tlcl.c
@@ -39,6 +39,8 @@
#include "tpmemu.h"
#endif
+#define TPM_DEVICE_PATH "/dev/tpm0"
+
/* The file descriptor for the TPM device.
*/
int tpm_fd = -1;
@@ -231,13 +233,24 @@ void TlclLibInit(void) {
#if USE_TPM_EMULATOR
tpmemu_init();
#else
+ TlclOpenDevice();
+#endif /* USE_TPM_EMULATOR */
+}
+
+void TlclCloseDevice(void) {
#if !FIRMWARE
- tpm_fd = open("/dev/tpm0", O_RDWR);
+ close(tpm_fd);
+ tpm_fd = -1;
+#endif /* !FIRMWARE */
+}
+
+void TlclOpenDevice(void) {
+#if !FIRMWARE
+ tpm_fd = open(TPM_DEVICE_PATH, O_RDWR);
if (tpm_fd < 0) {
- error("cannot open TPM device: %s\n", strerror(errno));
+ error("cannot open TPM device %s: %s\n", TPM_DEVICE_PATH, strerror(errno));
}
#endif /* !FIRMWARE */
-#endif /* USE_TPM_EMULATOR */
}
uint32_t TlclStartup(void) {
« no previous file with comments | « src/tlcl/tlcl.h ('k') | src/tlcl/version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698