]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
tpm: generalize init_timeout()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 26 Feb 2018 14:12:12 +0000 (09:12 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 27 Feb 2018 16:29:11 +0000 (11:29 -0500)
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>
src/hw/tpm_drivers.c

index a137e62a11107f8f97e46ef85d8f7887fe7b8a15..0daaef281098c87e02735ed3a9e18ef6339d832f 100644 (file)
@@ -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;
 }