tpm: move TPM_CHIP_FLAG_HAVE_TIMEOUTS check
Subsystems (3)
PATCH 1/1 tpm: move TPM_CHIP_FLAG_HAVE_TIMEOUTS check
Since tpm1_get_timeouts and tpm2_get_timeouts are now called directly by the auto startup code in addition to being called by tpm_get_timeouts, push the flag check down into the individual functions to avoid going through them again if they've already set the TPM_CHIP_FLAG_HAVE_TIMEOUTS flag.
Cc Peter Huewe <[email protected]>
Cc Jarkko Sakkinen <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes d4a317563207 ("tpm: move tpm 1.x selftest code from tpm-interface.c tpm1-cmd.c")
Fixes 9db7fe187c54 ("tpm: factor out tpm_startup function")
Signed-off-by Jerry Snitselaar <[email protected]>
--- drivers/char/tpm/tpm-interface.c | 3 --- drivers/char/tpm/tpm1-cmd.c | 3 +++ drivers/char/tpm/tpm2-cmd.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +0 -3
@@ -237,9 +237,6 @@ EXPORT_SYMBOL_GPL(tpm_transmit_cmd);int tpm_get_timeouts (struct tpm_chip *chip) { -if (chip->flags &TPM_CHIP_FLAG_HAVE_TIMEOUTS ) -return 0 ; -if (chip->flags &TPM_CHIP_FLAG_TPM2 )return tpm2_get_timeouts (chip);else
drivers/char/tpm/tpm1-cmd.c +3 -0
@@ -345,6 +345,9 @@ int tpm1_get_timeouts(struct tpm_chip *chip)unsigned long timeout_old[4 ], timeout_chip[4 ], timeout_eff[4 ];ssize_t rc; +if (chip->flags &TPM_CHIP_FLAG_HAVE_TIMEOUTS ) +return 0 ; + rc =tpm1_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap,NULL ,sizeof (cap.timeout));if (rc ==TPM_ERR_INVALID_POSTINIT ) {
drivers/char/tpm/tpm2-cmd.c +3 -0
@@ -38,6 +38,9 @@ static struct tpm2_hash tpm2_hash_map[] = {int tpm2_get_timeouts (struct tpm_chip *chip) { +if (chip->flags &TPM_CHIP_FLAG_HAVE_TIMEOUTS ) +return 0 ; +/* Fixed timeouts for TPM2 */ chip->timeout_a =msecs_to_jiffies (TPM2_TIMEOUT_A ); chip->timeout_b =msecs_to_jiffies (TPM2_TIMEOUT_B );
Signature · 1 line
2.24.0