Skip to content

Commit 0c54133

Browse files
author
Jarkko Sakkinen
committed
tpm: use tpm_pcr_read_dev() in tpm_do_selftest()
Instead of a ad-hoc protocol message construction it is better to call tpm_pcr_read_dev(). Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
1 parent ae7e190 commit 0c54133

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/char/tpm/tpm-interface.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
782782
unsigned int loops;
783783
unsigned int delay_msec = 100;
784784
unsigned long duration;
785-
struct tpm_cmd_t cmd;
785+
u8 dummy[TPM_DIGEST_SIZE];
786786

787787
duration = tpm_calc_ordinal_duration(chip, TPM_ORD_CONTINUE_SELFTEST);
788788

@@ -797,9 +797,8 @@ int tpm_do_selftest(struct tpm_chip *chip)
797797

798798
do {
799799
/* Attempt to read a PCR value */
800-
cmd.header.in = pcrread_header;
801-
cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0);
802-
rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE, 0);
800+
rc = tpm_pcr_read_dev(chip, 0, dummy);
801+
803802
/* Some buggy TPMs will not respond to tpm_tis_ready() for
804803
* around 300ms while the self test is ongoing, keep trying
805804
* until the self test duration expires. */
@@ -814,7 +813,6 @@ int tpm_do_selftest(struct tpm_chip *chip)
814813
if (rc < TPM_HEADER_SIZE)
815814
return -EFAULT;
816815

817-
rc = be32_to_cpu(cmd.header.out.return_code);
818816
if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
819817
dev_info(&chip->dev,
820818
"TPM is disabled/deactivated (0x%X)\n", rc);

0 commit comments

Comments
 (0)