[PATCH v3 7/7] tpm: open code tpm2_create_null_primary()

Jarkko Sakkinen posted 7 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH v3 7/7] tpm: open code tpm2_create_null_primary()
Posted by Jarkko Sakkinen 2 months, 1 week ago
As tpm2_sessions_init() has been shrunk only as a single and only call
site for tpm2_create_null_primary(), open code it to the call site.

Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
v3:
- A new patch.
---
 drivers/char/tpm/tpm2-sessions.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c
index d240039d0849..72c83eb3f665 100644
--- a/drivers/char/tpm/tpm2-sessions.c
+++ b/drivers/char/tpm/tpm2-sessions.c
@@ -1281,7 +1281,13 @@ static int tpm2_create_primary(struct tpm_chip *chip, u32 hierarchy,
 	return rc;
 }
 
-static int tpm2_create_null_primary(struct tpm_chip *chip)
+/**
+ * tpm2_sessions_init() - Initialize the null keypair for authenticated sessions
+ * @chip: a &tpm_chip instance
+ *
+ * Return: 0 on success and -ENODEV on failure.
+ */
+int tpm2_sessions_init(struct tpm_chip *chip)
 {
 	u32 null_key;
 	int rc;
@@ -1308,23 +1314,5 @@ static int tpm2_create_null_primary(struct tpm_chip *chip)
 	/* Map all errors to -ENODEV: */
 	return rc ? -ENODEV : rc;
 }
-
-/**
- * tpm2_sessions_init() - start of day initialization for the sessions code
- * @chip: TPM chip
- *
- * Derive and context save the null primary and allocate memory in the
- * struct tpm_chip for the authorizations.
- */
-int tpm2_sessions_init(struct tpm_chip *chip)
-{
-	int rc;
-
-	rc = tpm2_create_null_primary(chip);
-	if (rc)
-		return rc;
-
-	return rc;
-}
 EXPORT_SYMBOL(tpm2_sessions_init);
 #endif /* CONFIG_TCG_TPM2_HMAC */
-- 
2.46.0