mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-20 06:20:41 +00:00
tpm: Make chip->{status,cancel,req_canceled} opt
tpm_ftpm_tee does not require chip->status, chip->cancel and chip->req_canceled. Make them optional. Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@opinsys.com> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
372f97a24a
commit
980a573621
2 changed files with 27 additions and 23 deletions
|
@ -58,6 +58,30 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
|
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
|
||||||
|
|
||||||
|
static void tpm_chip_cancel(struct tpm_chip *chip)
|
||||||
|
{
|
||||||
|
if (!chip->ops->cancel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chip->ops->cancel(chip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static u8 tpm_chip_status(struct tpm_chip *chip)
|
||||||
|
{
|
||||||
|
if (!chip->ops->status)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return chip->ops->status(chip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool tpm_chip_req_canceled(struct tpm_chip *chip, u8 status)
|
||||||
|
{
|
||||||
|
if (!chip->ops->req_canceled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return chip->ops->req_canceled(chip, status);
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
|
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
|
||||||
{
|
{
|
||||||
struct tpm_header *header = buf;
|
struct tpm_header *header = buf;
|
||||||
|
@ -104,12 +128,12 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
|
||||||
|
|
||||||
stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
|
stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
|
||||||
do {
|
do {
|
||||||
u8 status = chip->ops->status(chip);
|
u8 status = tpm_chip_status(chip);
|
||||||
if ((status & chip->ops->req_complete_mask) ==
|
if ((status & chip->ops->req_complete_mask) ==
|
||||||
chip->ops->req_complete_val)
|
chip->ops->req_complete_val)
|
||||||
goto out_recv;
|
goto out_recv;
|
||||||
|
|
||||||
if (chip->ops->req_canceled(chip, status)) {
|
if (tpm_chip_req_canceled(chip, status)) {
|
||||||
dev_err(&chip->dev, "Operation Canceled\n");
|
dev_err(&chip->dev, "Operation Canceled\n");
|
||||||
return -ECANCELED;
|
return -ECANCELED;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +142,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
|
||||||
rmb();
|
rmb();
|
||||||
} while (time_before(jiffies, stop));
|
} while (time_before(jiffies, stop));
|
||||||
|
|
||||||
chip->ops->cancel(chip);
|
tpm_chip_cancel(chip);
|
||||||
dev_err(&chip->dev, "Operation Timed out\n");
|
dev_err(&chip->dev, "Operation Timed out\n");
|
||||||
return -ETIME;
|
return -ETIME;
|
||||||
|
|
||||||
|
|
|
@ -164,30 +164,10 @@ static int ftpm_tee_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ftpm_tee_tpm_op_cancel(struct tpm_chip *chip)
|
|
||||||
{
|
|
||||||
/* not supported */
|
|
||||||
}
|
|
||||||
|
|
||||||
static u8 ftpm_tee_tpm_op_status(struct tpm_chip *chip)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ftpm_tee_tpm_req_canceled(struct tpm_chip *chip, u8 status)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct tpm_class_ops ftpm_tee_tpm_ops = {
|
static const struct tpm_class_ops ftpm_tee_tpm_ops = {
|
||||||
.flags = TPM_OPS_AUTO_STARTUP,
|
.flags = TPM_OPS_AUTO_STARTUP,
|
||||||
.recv = ftpm_tee_tpm_op_recv,
|
.recv = ftpm_tee_tpm_op_recv,
|
||||||
.send = ftpm_tee_tpm_op_send,
|
.send = ftpm_tee_tpm_op_send,
|
||||||
.cancel = ftpm_tee_tpm_op_cancel,
|
|
||||||
.status = ftpm_tee_tpm_op_status,
|
|
||||||
.req_complete_mask = 0,
|
|
||||||
.req_complete_val = 0,
|
|
||||||
.req_canceled = ftpm_tee_tpm_req_canceled,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue