Skip to content

Commit eb5854e

Browse files
author
Jarkko Sakkinen
committed
tpm: replace tpm_gen_interrupt() with tpm_tis_gen_interrupt()
Since tpm_gen_interrupt() is only used in tpm_tis_core.c this commit replaces it with an internal tpm_tis_gen_interrupt(). The semantics also changed in a way that on a system error the driver initialization is failed. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
1 parent d4abd95 commit eb5854e

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

drivers/char/tpm/tpm-interface.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -461,21 +461,7 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
461461
*cap = tpm_cmd.params.getcap_out.cap;
462462
return rc;
463463
}
464-
465-
void tpm_gen_interrupt(struct tpm_chip *chip)
466-
{
467-
struct tpm_cmd_t tpm_cmd;
468-
ssize_t rc;
469-
470-
tpm_cmd.header.in = tpm_getcap_header;
471-
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
472-
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
473-
tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
474-
475-
rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
476-
"attempting to determine the timeouts");
477-
}
478-
EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
464+
EXPORT_SYMBOL_GPL(tpm_getcap);
479465

480466
#define TPM_ORD_STARTUP cpu_to_be32(153)
481467
#define TPM_ST_CLEAR cpu_to_be16(1)

drivers/char/tpm/tpm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd, int len,
487487
ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
488488
const char *desc);
489489
int tpm_get_timeouts(struct tpm_chip *);
490-
void tpm_gen_interrupt(struct tpm_chip *);
491490
int tpm1_auto_startup(struct tpm_chip *chip);
492491
int tpm_do_selftest(struct tpm_chip *chip);
493492
unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
@@ -534,6 +533,5 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
534533
int tpm2_auto_startup(struct tpm_chip *chip);
535534
void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
536535
unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
537-
int tpm2_gen_interrupt(struct tpm_chip *chip);
538536
int tpm2_probe(struct tpm_chip *chip);
539537
#endif

drivers/char/tpm/tpm2-cmd.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
736736

737737
return rc;
738738
}
739+
EXPORT_SYMBOL_GPL(tpm2_get_tpm_pt);
739740

740741
#define TPM2_STARTUP_IN_SIZE \
741742
(sizeof(struct tpm_input_header) + \
@@ -923,23 +924,6 @@ static int tpm2_do_selftest(struct tpm_chip *chip)
923924
return rc;
924925
}
925926

926-
/**
927-
* tpm2_gen_interrupt() - generate an interrupt
928-
* @chip: TPM chip to use
929-
*
930-
* 0 is returned when the operation is successful. If a negative number is
931-
* returned it remarks a POSIX error code. If a positive number is returned
932-
* it remarks a TPM error.
933-
*/
934-
int tpm2_gen_interrupt(struct tpm_chip *chip)
935-
{
936-
u32 dummy;
937-
938-
return tpm2_get_tpm_pt(chip, 0x100, &dummy,
939-
"attempting to generate an interrupt");
940-
}
941-
EXPORT_SYMBOL_GPL(tpm2_gen_interrupt);
942-
943927
/**
944928
* tpm2_probe() - probe TPM 2.0
945929
* @chip: TPM chip to use

drivers/char/tpm/tpm_tis_core.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,18 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
526526
return IRQ_HANDLED;
527527
}
528528

529+
static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
530+
{
531+
const char *desc = "attempting to generate an interrupt";
532+
u32 cap2;
533+
cap_t cap;
534+
535+
if (chip->flags & TPM_CHIP_FLAG_TPM2)
536+
return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
537+
else
538+
return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
539+
}
540+
529541
/* Register the IRQ and issue a command that will cause an interrupt. If an
530542
* irq is seen then leave the chip setup for IRQ operation, otherwise reverse
531543
* everything and leave in polling mode. Returns 0 on success.
@@ -575,10 +587,9 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
575587
/* Generate an interrupt by having the core call through to
576588
* tpm_tis_send
577589
*/
578-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
579-
tpm2_gen_interrupt(chip);
580-
else
581-
tpm_gen_interrupt(chip);
590+
rc = tpm_tis_gen_interrupt(chip);
591+
if (rc < 0)
592+
return rc;
582593

583594
/* tpm_tis_send will either confirm the interrupt is working or it
584595
* will call disable_irq which undoes all of the above.

0 commit comments

Comments
 (0)