Skip to contentSkip to conversation

tpm_crb: ffa_tpm: return errors from interface functions if no ffa-crb driver

PATCH In review Stuart Yoder 2 participants 2 messages Apr 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm_crb: ffa_tpm: return errors from interface functions if no ffa-crb driver

If ACPI advertises an FF-A based TPM but the tpm_crb_ffa driver is not enabled via Kconfig, inline stub versions of the interface functions are used. These functions incorrectly return 0, which indicates success. The result is that the tpm_crb probe function continues execution and eventually detects a timeout at the TPM.

Change the inline functions to return errors, so that probe() sees that tpm_crb_ffa is not present and aborts the probe.

---
 drivers/char/tpm/tpm_crb_ffa.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm_crb_ffa.h +3 -3
index 645c41ede10ed..c006403e2f14b 100644
@@ -14,9 +14,9 @@ int tpm_crb_ffa_init(void);
 int tpm_crb_ffa_get_interface_version(u16 *major, u16 *minor);
 int tpm_crb_ffa_start(int request_type, int locality);
 #else
-static inline int tpm_crb_ffa_init(void) { return 0; }
-static inline int tpm_crb_ffa_get_interface_version(u16 *major, u16 *minor) { return 0; }
-static inline int tpm_crb_ffa_start(int request_type, int locality) { return 0; }
+static inline int tpm_crb_ffa_init(void) { return -ENODEV; }
+static inline int tpm_crb_ffa_get_interface_version(u16 *major, u16 *minor) { return -ENODEV; }
+static inline int tpm_crb_ffa_start(int request_type, int locality) { return -ENODEV; }
 #endif
 
 #define CRB_FFA_START_TYPE_COMMAND 0
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Stuart Yoder

If ACPI advertises an FF-A based TPM but the tpm_crb_ffa driver is not enabled via Kconfig, inline stub versions of the interface functions are used. These functions incorrectly return 0, which indicates success. The result is that the tpm_crb probe function continues execution and eventually detects a timeout at the TPM.

Change the inline functions to return errors, so that probe() sees that tpm_crb_ffa is not present and aborts the probe.

LGTM,

Signature · 2 lines
Regards,
Sudeep