Skip to content

Commit 4f0feb5

Browse files
committed
tpm: Remove tpm_send()
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>
1 parent cf792e9 commit 4f0feb5

3 files changed

Lines changed: 12 additions & 32 deletions

File tree

drivers/char/tpm/tpm-interface.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -342,31 +342,6 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
342342
}
343343
EXPORT_SYMBOL_GPL(tpm_pcr_extend);
344344

345-
/**
346-
* tpm_send - send a TPM command
347-
* @chip: a &struct tpm_chip instance, %NULL for the default chip
348-
* @cmd: a TPM command buffer
349-
* @buflen: the length of the TPM command buffer
350-
*
351-
* Return: same as with tpm_transmit_cmd()
352-
*/
353-
int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
354-
{
355-
struct tpm_buf buf;
356-
int rc;
357-
358-
chip = tpm_find_get_ops(chip);
359-
if (!chip)
360-
return -ENODEV;
361-
362-
buf.data = cmd;
363-
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
364-
365-
tpm_put_ops(chip);
366-
return rc;
367-
}
368-
EXPORT_SYMBOL_GPL(tpm_send);
369-
370345
int tpm_auto_startup(struct tpm_chip *chip)
371346
{
372347
int rc;

include/linux/tpm.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ extern int tpm_pcr_read(struct tpm_chip *chip, u32 pcr_idx,
422422
struct tpm_digest *digest);
423423
extern int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
424424
struct tpm_digest *digests);
425-
extern int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen);
426425
extern int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t max);
427426
extern struct tpm_chip *tpm_default_chip(void);
428427
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,
443442
return -ENODEV;
444443
}
445444

446-
static inline int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
447-
{
448-
return -ENODEV;
449-
}
450445
static inline int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t max)
451446
{
452447
return -ENODEV;

security/keys/trusted-keys/trusted_tpm1.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,27 @@ static int TSS_checkhmac2(unsigned char *buffer,
356356
*/
357357
int trusted_tpm_send(unsigned char *cmd, size_t buflen)
358358
{
359+
struct tpm_buf buf;
359360
int rc;
360361

361362
if (!chip)
362363
return -ENODEV;
363364

365+
rc = tpm_try_get_ops(chip);
366+
if (rc)
367+
return rc;
368+
369+
buf.flags = 0;
370+
buf.data = cmd;
364371
dump_tpm_buf(cmd);
365-
rc = tpm_send(chip, cmd, buflen);
372+
rc = tpm_transmit_cmd(chip, &buf, 4, "sending data");
366373
dump_tpm_buf(cmd);
374+
367375
if (rc > 0)
368-
/* Can't return positive return codes values to keyctl */
376+
/* TPM error */
369377
rc = -EPERM;
378+
379+
tpm_put_ops(chip);
370380
return rc;
371381
}
372382
EXPORT_SYMBOL_GPL(trusted_tpm_send);

0 commit comments

Comments
 (0)