Skip to content

Commit b03c437

Browse files
Tomas WinklerJarkko Sakkinen
authored andcommitted
tpm: add tpm_auto_startup() into tpm-interface.c
Add wrapper tpm_auto_startup() to tpm-interface.c instead of open coded decision between TPM 1.x and TPM 2.x in tpm-chip.c Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent 9db7fe1 commit b03c437

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎drivers/char/tpm/tpm-chip.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,9 @@ int tpm_chip_register(struct tpm_chip *chip)
451451
{
452452
int rc;
453453

454-
if (chip->ops->flags & TPM_OPS_AUTO_STARTUP) {
455-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
456-
rc = tpm2_auto_startup(chip);
457-
else
458-
rc = tpm1_auto_startup(chip);
459-
if (rc)
460-
return rc;
461-
}
454+
rc = tpm_auto_startup(chip);
455+
if (rc)
456+
return rc;
462457

463458
tpm_sysfs_add_device(chip);
464459

‎drivers/char/tpm/tpm-interface.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,21 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
544544
}
545545
EXPORT_SYMBOL_GPL(tpm_send);
546546

547+
int tpm_auto_startup(struct tpm_chip *chip)
548+
{
549+
int rc;
550+
551+
if (!(chip->ops->flags & TPM_OPS_AUTO_STARTUP))
552+
return 0;
553+
554+
if (chip->flags & TPM_CHIP_FLAG_TPM2)
555+
rc = tpm2_auto_startup(chip);
556+
else
557+
rc = tpm1_auto_startup(chip);
558+
559+
return rc;
560+
}
561+
547562
/*
548563
* We are about to suspend. Save the TPM state
549564
* so that it can be restored.

‎drivers/char/tpm/tpm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
541541
size_t min_rsp_body_length, unsigned int flags,
542542
const char *desc);
543543
int tpm_get_timeouts(struct tpm_chip *);
544+
int tpm_auto_startup(struct tpm_chip *chip);
544545

545546
int tpm1_pm_suspend(struct tpm_chip *chip, int tpm_suspend_pcr);
546547
int tpm1_auto_startup(struct tpm_chip *chip);

0 commit comments

Comments
 (0)