Skip to content

Commit 419a16d

Browse files
maciejsszmigieroJarkko Sakkinen
authored andcommitted
tpm_tis: fix iTPM probe via probe_itpm() function
probe_itpm() function is supposed to send command without an itpm flag set and if this fails to repeat it, this time with the itpm flag set. However, commit 41a5e1c ("tpm/tpm_tis: Split tpm_tis driver into a core and TCG TIS compliant phy") moved the itpm flag from an "itpm" variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the (now function-local) itpm variable no longer had any effect. Finally, this function-local itpm variable was removed by commit 56af322 ("tpm/tpm_tis: remove unused itpm variable") Tested only on non-iTPM TIS TPM. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent fa2825d commit 419a16d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ static int probe_itpm(struct tpm_chip *chip)
464464
size_t len = sizeof(cmd_getticks);
465465
u16 vendor;
466466

467+
if (priv->flags & TPM_TIS_ITPM_WORKAROUND)
468+
return 0;
469+
467470
rc = tpm_tis_read16(priv, TPM_DID_VID(0), &vendor);
468471
if (rc < 0)
469472
return rc;
@@ -479,12 +482,15 @@ static int probe_itpm(struct tpm_chip *chip)
479482
tpm_tis_ready(chip);
480483
release_locality(chip, priv->locality, 0);
481484

485+
priv->flags |= TPM_TIS_ITPM_WORKAROUND;
486+
482487
rc = tpm_tis_send_data(chip, cmd_getticks, len);
483-
if (rc == 0) {
488+
if (rc == 0)
484489
dev_info(&chip->dev, "Detected an iTPM.\n");
485-
rc = 1;
486-
} else
490+
else {
491+
priv->flags &= ~TPM_TIS_ITPM_WORKAROUND;
487492
rc = -EFAULT;
493+
}
488494

489495
out:
490496
tpm_tis_ready(chip);
@@ -741,15 +747,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
741747
(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
742748
vendor >> 16, rid);
743749

744-
if (!(priv->flags & TPM_TIS_ITPM_WORKAROUND)) {
745-
probe = probe_itpm(chip);
746-
if (probe < 0) {
747-
rc = -ENODEV;
748-
goto out_err;
749-
}
750-
751-
if (!!probe)
752-
priv->flags |= TPM_TIS_ITPM_WORKAROUND;
750+
probe = probe_itpm(chip);
751+
if (probe < 0) {
752+
rc = -ENODEV;
753+
goto out_err;
753754
}
754755

755756
/* Figure out the capabilities */

0 commit comments

Comments
 (0)