Skip to content

Commit 980a573

Browse files
committed
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>
1 parent 372f97a commit 980a573

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

drivers/char/tpm/tpm-interface.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,30 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
5858
}
5959
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
6060

61+
static void tpm_chip_cancel(struct tpm_chip *chip)
62+
{
63+
if (!chip->ops->cancel)
64+
return;
65+
66+
chip->ops->cancel(chip);
67+
}
68+
69+
static u8 tpm_chip_status(struct tpm_chip *chip)
70+
{
71+
if (!chip->ops->status)
72+
return 0;
73+
74+
return chip->ops->status(chip);
75+
}
76+
77+
static bool tpm_chip_req_canceled(struct tpm_chip *chip, u8 status)
78+
{
79+
if (!chip->ops->req_canceled)
80+
return false;
81+
82+
return chip->ops->req_canceled(chip, status);
83+
}
84+
6185
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
6286
{
6387
struct tpm_header *header = buf;
@@ -104,12 +128,12 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
104128

105129
stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
106130
do {
107-
u8 status = chip->ops->status(chip);
131+
u8 status = tpm_chip_status(chip);
108132
if ((status & chip->ops->req_complete_mask) ==
109133
chip->ops->req_complete_val)
110134
goto out_recv;
111135

112-
if (chip->ops->req_canceled(chip, status)) {
136+
if (tpm_chip_req_canceled(chip, status)) {
113137
dev_err(&chip->dev, "Operation Canceled\n");
114138
return -ECANCELED;
115139
}
@@ -118,7 +142,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
118142
rmb();
119143
} while (time_before(jiffies, stop));
120144

121-
chip->ops->cancel(chip);
145+
tpm_chip_cancel(chip);
122146
dev_err(&chip->dev, "Operation Timed out\n");
123147
return -ETIME;
124148

drivers/char/tpm/tpm_ftpm_tee.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,30 +164,10 @@ static int ftpm_tee_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t len)
164164
return 0;
165165
}
166166

167-
static void ftpm_tee_tpm_op_cancel(struct tpm_chip *chip)
168-
{
169-
/* not supported */
170-
}
171-
172-
static u8 ftpm_tee_tpm_op_status(struct tpm_chip *chip)
173-
{
174-
return 0;
175-
}
176-
177-
static bool ftpm_tee_tpm_req_canceled(struct tpm_chip *chip, u8 status)
178-
{
179-
return false;
180-
}
181-
182167
static const struct tpm_class_ops ftpm_tee_tpm_ops = {
183168
.flags = TPM_OPS_AUTO_STARTUP,
184169
.recv = ftpm_tee_tpm_op_recv,
185170
.send = ftpm_tee_tpm_op_send,
186-
.cancel = ftpm_tee_tpm_op_cancel,
187-
.status = ftpm_tee_tpm_op_status,
188-
.req_complete_mask = 0,
189-
.req_complete_val = 0,
190-
.req_canceled = ftpm_tee_tpm_req_canceled,
191171
};
192172

193173
/*

0 commit comments

Comments
 (0)