All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.ibm.com>
To: openbmc@lists.ozlabs.org
Subject: [PATCH linux dev-5.15 2/7] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"
Date: Wed,  8 Dec 2021 13:17:53 -0600	[thread overview]
Message-ID: <20211208191758.20517-3-eajames@linux.ibm.com> (raw)
In-Reply-To: <20211208191758.20517-1-eajames@linux.ibm.com>

From: Amir Mizinski <amirmizi6@gmail.com>

tpm_tis_req_canceled() function is used to check if the caller requested
to abort the current operation. It was found that in some cases
tpm_tis_req_canceled() wrongly returned true.
Since a cancel request sets the TPM_STS.commandReady field to TRUE, the
tpm_tis_req_canceled() function should check only the TPM_STS.commandReady
field value.
The case for TPM_VID_WINBOND is wrong and was therefore removed.

Also, the default comparison is wrong. Only cmdReady bit needs to be
compared instead of the full lower status register byte.

Signed-off-by: Amir Mizinski <amirmizi6@gmail.com>
---
 drivers/char/tpm/tpm_tis_core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index adb086b6df7c..7d6d07625600 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -662,13 +662,10 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
 	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
 
 	switch (priv->manufacturer_id) {
-	case TPM_VID_WINBOND:
-		return ((status == TPM_STS_VALID) ||
-			(status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
 	case TPM_VID_STM:
 		return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
 	default:
-		return (status == TPM_STS_COMMAND_READY);
+		return (status & TPM_STS_COMMAND_READY) == TPM_STS_COMMAND_READY;
 	}
 }
 
-- 
2.27.0


  parent reply	other threads:[~2021-12-08 19:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 19:17 [PATCH linux dev-5.15 0/7] Add tpm i2c ptp driver Eddie James
2021-12-08 19:17 ` [PATCH linux dev-5.15 1/7] tpm_tis: Fix expected bit handling Eddie James
2021-12-08 19:17 ` Eddie James [this message]
2021-12-08 19:17 ` [PATCH linux dev-5.15 3/7] tpm: tpm_tis: Verify TPM_STS register is valid after locality request Eddie James
2021-12-08 19:17 ` [PATCH linux dev-5.15 4/7] tpm: tpm_tis: Add tpm_tis_i2c driver Eddie James
2021-12-08 19:17 ` [PATCH linux dev-5.15 5/7] tpm: Add YAML schema for TPM TIS I2C options Eddie James
2021-12-08 19:17 ` [PATCH linux dev-5.15 6/7] ARM: dts: aspeed: Rainier: Add TPM device Eddie James
2021-12-08 19:17 ` [PATCH linux dev-5.15 7/7] ARM: dts: aspeed: Everest: " Eddie James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211208191758.20517-3-eajames@linux.ibm.com \
    --to=eajames@linux.ibm.com \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.