Re: [PATCH v2 2/5] tpm_crb: refactor check for idle support into TPM into inline function

From: Stuart Yoder
Date: Thu Feb 13 2025 - 17:24:10 EST




On 2/13/25 4:13 PM, Jarkko Sakkinen wrote:
On Wed, Feb 12, 2025 at 04:05:45PM -0600, Stuart Yoder wrote:
Refactor the two checks for whether the TPM supports idle into a single
inline function.

Signed-off-by: Stuart Yoder <stuart.yoder@xxxxxxx>
---
drivers/char/tpm/tpm_crb.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index ea085b14ab7c..87d69e990249 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -115,6 +115,16 @@ struct tpm2_crb_pluton {
u64 reply_addr;
};
+static inline bool does_tpm_support_idle(u32 start_method)
+{
+ if ((start_method == ACPI_TPM2_START_METHOD) ||
+ (start_method == ACPI_TPM2_COMMAND_BUFFER_WITH_START_METHOD) ||
+ (start_method == ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC))
+ return false;
+ else
+ return true;
+}
+

I think we could also prefix tpm_crb stuff with tpm_crb_* for the sake
of easier grepping etc.

So I'd propose this to be called as: tpm_crb_has_idle()

Ack.

Stuart