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 41a5e1cf1f ("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 56af322156 ("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>
This commit is contained in:
Maciej S. Szmigiero 2017-01-25 22:07:36 +02:00 committed by Jarkko Sakkinen
parent fa2825da6f
commit 419a16d9cd

View File

@ -464,6 +464,9 @@ static int probe_itpm(struct tpm_chip *chip)
size_t len = sizeof(cmd_getticks); size_t len = sizeof(cmd_getticks);
u16 vendor; u16 vendor;
if (priv->flags & TPM_TIS_ITPM_WORKAROUND)
return 0;
rc = tpm_tis_read16(priv, TPM_DID_VID(0), &vendor); rc = tpm_tis_read16(priv, TPM_DID_VID(0), &vendor);
if (rc < 0) if (rc < 0)
return rc; return rc;
@ -479,12 +482,15 @@ static int probe_itpm(struct tpm_chip *chip)
tpm_tis_ready(chip); tpm_tis_ready(chip);
release_locality(chip, priv->locality, 0); release_locality(chip, priv->locality, 0);
priv->flags |= TPM_TIS_ITPM_WORKAROUND;
rc = tpm_tis_send_data(chip, cmd_getticks, len); rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0) { if (rc == 0)
dev_info(&chip->dev, "Detected an iTPM.\n"); dev_info(&chip->dev, "Detected an iTPM.\n");
rc = 1; else {
} else priv->flags &= ~TPM_TIS_ITPM_WORKAROUND;
rc = -EFAULT; rc = -EFAULT;
}
out: out:
tpm_tis_ready(chip); tpm_tis_ready(chip);
@ -741,15 +747,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2", (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
vendor >> 16, rid); vendor >> 16, rid);
if (!(priv->flags & TPM_TIS_ITPM_WORKAROUND)) { probe = probe_itpm(chip);
probe = probe_itpm(chip); if (probe < 0) {
if (probe < 0) { rc = -ENODEV;
rc = -ENODEV; goto out_err;
goto out_err;
}
if (!!probe)
priv->flags |= TPM_TIS_ITPM_WORKAROUND;
} }
/* Figure out the capabilities */ /* Figure out the capabilities */