Skip to content

Commit

Permalink
tpm: add tpm_auto_startup() into tpm-interface.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tomas Winkler authored and Jarkko Sakkinen committed Nov 13, 2018
1 parent 9db7fe1 commit b03c437
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/char/tpm/tpm-chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,9 @@ int tpm_chip_register(struct tpm_chip *chip)
{
int rc;

if (chip->ops->flags & TPM_OPS_AUTO_STARTUP) {
if (chip->flags & TPM_CHIP_FLAG_TPM2)
rc = tpm2_auto_startup(chip);
else
rc = tpm1_auto_startup(chip);
if (rc)
return rc;
}
rc = tpm_auto_startup(chip);
if (rc)
return rc;

tpm_sysfs_add_device(chip);

Expand Down
15 changes: 15 additions & 0 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,21 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
}
EXPORT_SYMBOL_GPL(tpm_send);

int tpm_auto_startup(struct tpm_chip *chip)
{
int rc;

if (!(chip->ops->flags & TPM_OPS_AUTO_STARTUP))
return 0;

if (chip->flags & TPM_CHIP_FLAG_TPM2)
rc = tpm2_auto_startup(chip);
else
rc = tpm1_auto_startup(chip);

return rc;
}

/*
* We are about to suspend. Save the TPM state
* so that it can be restored.
Expand Down
1 change: 1 addition & 0 deletions drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
size_t min_rsp_body_length, unsigned int flags,
const char *desc);
int tpm_get_timeouts(struct tpm_chip *);
int tpm_auto_startup(struct tpm_chip *chip);

int tpm1_pm_suspend(struct tpm_chip *chip, int tpm_suspend_pcr);
int tpm1_auto_startup(struct tpm_chip *chip);
Expand Down

0 comments on commit b03c437

Please sign in to comment.