]> www.infradead.org Git - users/hch/block.git/commitdiff
tpm: Remove tpm_send()
authorJarkko Sakkinen <jarkko@kernel.org>
Mon, 29 Apr 2024 20:27:51 +0000 (16:27 -0400)
committerJarkko Sakkinen <jarkko@kernel.org>
Thu, 9 May 2024 19:30:50 +0000 (22:30 +0300)
Open code the last remaining call site for tpm_send().

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm-interface.c
include/linux/tpm.h
security/keys/trusted-keys/trusted_tpm1.c

index 757336324c904cf98451898d0f0ef37b33c7df80..f940045a014e8b2a5572c3ac4761a4976642c27f 100644 (file)
@@ -342,31 +342,6 @@ out:
 }
 EXPORT_SYMBOL_GPL(tpm_pcr_extend);
 
-/**
- * tpm_send - send a TPM command
- * @chip:      a &struct tpm_chip instance, %NULL for the default chip
- * @cmd:       a TPM command buffer
- * @buflen:    the length of the TPM command buffer
- *
- * Return: same as with tpm_transmit_cmd()
- */
-int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
-{
-       struct tpm_buf buf;
-       int rc;
-
-       chip = tpm_find_get_ops(chip);
-       if (!chip)
-               return -ENODEV;
-
-       buf.data = cmd;
-       rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
-
-       tpm_put_ops(chip);
-       return rc;
-}
-EXPORT_SYMBOL_GPL(tpm_send);
-
 int tpm_auto_startup(struct tpm_chip *chip)
 {
        int rc;
index 6588ca87cf9339b4cd332ce8c533e8249d551236..d9d645e9c52c06f09eefcc383446b8caa7c1a9e3 100644 (file)
@@ -422,7 +422,6 @@ extern int tpm_pcr_read(struct tpm_chip *chip, u32 pcr_idx,
                        struct tpm_digest *digest);
 extern int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
                          struct tpm_digest *digests);
-extern int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen);
 extern int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t max);
 extern struct tpm_chip *tpm_default_chip(void);
 void tpm2_flush_context(struct tpm_chip *chip, u32 handle);
@@ -443,10 +442,6 @@ static inline int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
        return -ENODEV;
 }
 
-static inline int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
-{
-       return -ENODEV;
-}
 static inline int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t max)
 {
        return -ENODEV;
index aa108bea6739b302e9ef4f274f47a05d44014dce..37bce84eef993275e9da814b0dec4a288c1a5bf3 100644 (file)
@@ -356,17 +356,27 @@ out:
  */
 int trusted_tpm_send(unsigned char *cmd, size_t buflen)
 {
+       struct tpm_buf buf;
        int rc;
 
        if (!chip)
                return -ENODEV;
 
+       rc = tpm_try_get_ops(chip);
+       if (rc)
+               return rc;
+
+       buf.flags = 0;
+       buf.data = cmd;
        dump_tpm_buf(cmd);
-       rc = tpm_send(chip, cmd, buflen);
+       rc = tpm_transmit_cmd(chip, &buf, 4, "sending data");
        dump_tpm_buf(cmd);
+
        if (rc > 0)
-               /* Can't return positive return codes values to keyctl */
+               /* TPM error */
                rc = -EPERM;
+
+       tpm_put_ops(chip);
        return rc;
 }
 EXPORT_SYMBOL_GPL(trusted_tpm_send);