summaryrefslogtreecommitdiff
path: root/lib/tpm-v1.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-11-23 21:29:32 -0700
committerSimon Glass <sjg@chromium.org>2018-12-05 06:01:34 -0700
commit0a60a0a65fa98f265c79f3928d8628aabcba8a92 (patch)
tree5a7c28336bc8ab523acbff7c67d56478f9aef249 /lib/tpm-v1.c
parent40e9ede1dcd852a97d772b8d592e36195c5d8b80 (diff)
tpm: Remove use of build-time TPM versions
There is only one place in the code which assumes at build-time that we are using either a v1 or a v2 TPM. Fix this up and add a new function to return the version of a TPM. Supported TPM versions (v1 and v2) can be enabled independently and it is possible to use both versions at once. This is useful for sandbox when running tests. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/tpm-v1.c')
-rw-r--r--lib/tpm-v1.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/tpm-v1.c b/lib/tpm-v1.c
index f29e62ff7b..3e89f84544 100644
--- a/lib/tpm-v1.c
+++ b/lib/tpm-v1.c
@@ -79,19 +79,19 @@ u32 tpm_clear_and_reenable(struct udevice *dev)
return ret;
}
-#if IS_ENABLED(CONFIG_TPM_V1)
- ret = tpm_physical_enable(dev);
- if (ret != TPM_SUCCESS) {
- log_err("TPM: Can't set enabled state\n");
- return ret;
- }
+ if (tpm_get_version(dev) == TPM_V1) {
+ ret = tpm_physical_enable(dev);
+ if (ret != TPM_SUCCESS) {
+ log_err("TPM: Can't set enabled state\n");
+ return ret;
+ }
- ret = tpm_physical_set_deactivated(dev, 0);
- if (ret != TPM_SUCCESS) {
- log_err("TPM: Can't set deactivated state\n");
- return ret;
+ ret = tpm_physical_set_deactivated(dev, 0);
+ if (ret != TPM_SUCCESS) {
+ log_err("TPM: Can't set deactivated state\n");
+ return ret;
+ }
}
-#endif
return TPM_SUCCESS;
}