aboutsummaryrefslogtreecommitdiffstats
path: root/src/hw/tpm_drivers.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-02-26 09:12:12 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-02-27 11:29:11 -0500
commitc75d45a9712f9a0b4aa203d780e0bf01375699c9 (patch)
tree0f5b61d21279f15c9140acd17e25f7d039399397 /src/hw/tpm_drivers.c
parent8694c3bc847c12857edfb7dbb4e24e97b1e1861b (diff)
downloadseabios-c75d45a9712f9a0b4aa203d780e0bf01375699c9.tar.gz
tpm: generalize init_timeout()
It seems both TIS & CRB devices share the same timeout. Make initialization function generic now. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Diffstat (limited to 'src/hw/tpm_drivers.c')
-rw-r--r--src/hw/tpm_drivers.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
index a137e62a..0daaef28 100644
--- a/src/hw/tpm_drivers.c
+++ b/src/hw/tpm_drivers.c
@@ -102,26 +102,31 @@ static TPMVersion tis_get_tpm_version(void)
return TPM_VERSION_1_2;
}
-static u32 tis_init(void)
+static void init_timeout(int driver)
{
- if (!CONFIG_TCGBIOS)
- return 1;
-
- writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0);
-
- if (tpm_drivers[TIS_DRIVER_IDX].durations == NULL) {
+ if (tpm_drivers[driver].durations == NULL) {
u32 *durations = tpm_default_dur;
memcpy(durations, tpm_default_durations,
sizeof(tpm_default_durations));
- tpm_drivers[TIS_DRIVER_IDX].durations = durations;
+ tpm_drivers[driver].durations = durations;
}
- if (tpm_drivers[TIS_DRIVER_IDX].timeouts == NULL) {
+ if (tpm_drivers[driver].timeouts == NULL) {
u32 *timeouts = tpm_default_to;
memcpy(timeouts, tis_default_timeouts,
sizeof(tis_default_timeouts));
- tpm_drivers[TIS_DRIVER_IDX].timeouts = timeouts;
+ tpm_drivers[driver].timeouts = timeouts;
}
+}
+
+static u32 tis_init(void)
+{
+ if (!CONFIG_TCGBIOS)
+ return 1;
+
+ writeb(TIS_REG(0, TIS_REG_INT_ENABLE), 0);
+
+ init_timeout(TIS_DRIVER_IDX);
return 1;
}