Skip to content

Commit 756b2bb

Browse files
cricard13Jarkko Sakkinen
authored andcommitted
tpm: drop 'read_queue' from struct tpm_vendor_specific
Dropped the field 'read_queue' from struct tpm_vendor_specific and make it available to the various private structures in the drivers. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent d18c574 commit 756b2bb

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

drivers/char/tpm/st33zp24/st33zp24.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
338338
wait_for_stat(chip,
339339
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
340340
chip->vendor.timeout_c,
341-
&chip->vendor.read_queue, true) == 0) {
341+
&tpm_dev->read_queue, true) == 0) {
342342
burstcnt = get_burstcount(chip);
343343
if (burstcnt < 0)
344344
return burstcnt;
@@ -367,7 +367,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
367367
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
368368

369369
tpm_dev->intrs++;
370-
wake_up_interruptible(&chip->vendor.read_queue);
370+
wake_up_interruptible(&tpm_dev->read_queue);
371371
disable_irq_nosync(tpm_dev->irq);
372372

373373
return IRQ_HANDLED;
@@ -407,7 +407,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
407407
st33zp24_cancel(chip);
408408
if (wait_for_stat
409409
(chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
410-
&chip->vendor.read_queue, false) < 0) {
410+
&tpm_dev->read_queue, false) < 0) {
411411
ret = -ETIME;
412412
goto out_err;
413413
}
@@ -453,7 +453,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
453453

454454
ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
455455
tpm_calc_ordinal_duration(chip, ordinal),
456-
&chip->vendor.read_queue, false);
456+
&tpm_dev->read_queue, false);
457457
if (ret < 0)
458458
goto out_err;
459459
}
@@ -570,7 +570,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
570570

571571
if (irq) {
572572
/* INTERRUPT Setup */
573-
init_waitqueue_head(&chip->vendor.read_queue);
573+
init_waitqueue_head(&tpm_dev->read_queue);
574574
tpm_dev->intrs = 0;
575575

576576
if (request_locality(chip) != LOCALITY0) {
@@ -674,7 +674,7 @@ int st33zp24_pm_resume(struct device *dev)
674674
gpio_set_value(tpm_dev->io_lpcpd, 1);
675675
ret = wait_for_stat(chip,
676676
TPM_STS_VALID, chip->vendor.timeout_b,
677-
&chip->vendor.read_queue, false);
677+
&tpm_dev->read_queue, false);
678678
} else {
679679
ret = tpm_pm_resume(dev);
680680
if (!ret)

drivers/char/tpm/st33zp24/st33zp24.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct st33zp24_dev {
2828
int irq;
2929
u32 intrs;
3030
int io_lpcpd;
31+
wait_queue_head_t read_queue;
3132
};
3233

3334

drivers/char/tpm/tpm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ struct tpm_vendor_specific {
137137
unsigned long duration[3]; /* jiffies */
138138
bool duration_adjusted;
139139
void *priv;
140-
141-
wait_queue_head_t read_queue;
142140
};
143141

144142
#define TPM_VPRIV(c) ((c)->vendor.priv)

drivers/char/tpm/tpm_i2c_nuvoton.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
struct priv_data {
5858
int irq;
5959
unsigned int intrs;
60+
wait_queue_head_t read_queue;
6061
};
6162

6263
static s32 i2c_nuvoton_read_buf(struct i2c_client *client, u8 offset, u8 size,
@@ -232,13 +233,14 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
232233
static int i2c_nuvoton_recv_data(struct i2c_client *client,
233234
struct tpm_chip *chip, u8 *buf, size_t count)
234235
{
236+
struct priv_data *priv = chip->vendor.priv;
235237
s32 rc;
236238
int burst_count, bytes2read, size = 0;
237239

238240
while (size < count &&
239241
i2c_nuvoton_wait_for_data_avail(chip,
240242
chip->vendor.timeout_c,
241-
&chip->vendor.read_queue) == 0) {
243+
&priv->read_queue) == 0) {
242244
burst_count = i2c_nuvoton_get_burstcount(client, chip);
243245
if (burst_count < 0) {
244246
dev_err(&chip->dev,
@@ -265,6 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
265267
/* Read TPM command results */
266268
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
267269
{
270+
struct priv_data *priv = chip->vendor.priv;
268271
struct device *dev = chip->dev.parent;
269272
struct i2c_client *client = to_i2c_client(dev);
270273
s32 rc;
@@ -286,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
286289
* tag, paramsize, and result
287290
*/
288291
status = i2c_nuvoton_wait_for_data_avail(
289-
chip, chip->vendor.timeout_c, &chip->vendor.read_queue);
292+
chip, chip->vendor.timeout_c, &priv->read_queue);
290293
if (status != 0) {
291294
dev_err(dev, "%s() timeout on dataAvail\n", __func__);
292295
size = -ETIMEDOUT;
@@ -348,6 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
348351
*/
349352
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
350353
{
354+
struct priv_data *priv = chip->vendor.priv;
351355
struct device *dev = chip->dev.parent;
352356
struct i2c_client *client = to_i2c_client(dev);
353357
u32 ordinal;
@@ -440,7 +444,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
440444
rc = i2c_nuvoton_wait_for_data_avail(chip,
441445
tpm_calc_ordinal_duration(chip,
442446
ordinal),
443-
&chip->vendor.read_queue);
447+
&priv->read_queue);
444448
if (rc) {
445449
dev_err(dev, "%s() timeout command duration\n", __func__);
446450
i2c_nuvoton_ready(chip);
@@ -477,7 +481,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
477481
struct priv_data *priv = chip->vendor.priv;
478482

479483
priv->intrs++;
480-
wake_up(&chip->vendor.read_queue);
484+
wake_up(&priv->read_queue);
481485
disable_irq_nosync(priv->irq);
482486
return IRQ_HANDLED;
483487
}
@@ -541,7 +545,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
541545
return -ENOMEM;
542546
chip->vendor.priv = priv;
543547

544-
init_waitqueue_head(&chip->vendor.read_queue);
548+
init_waitqueue_head(&priv->read_queue);
545549

546550
/* Default timeouts */
547551
chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);

drivers/char/tpm/tpm_tis.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct priv_data {
9999
int irq;
100100
bool irq_tested;
101101
wait_queue_head_t int_queue;
102+
wait_queue_head_t read_queue;
102103
};
103104

104105
#if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
@@ -252,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
252253
wait_for_tpm_stat(chip,
253254
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
254255
chip->vendor.timeout_c,
255-
&chip->vendor.read_queue, true)
256+
&priv->read_queue, true)
256257
== 0) {
257258
burstcnt = get_burstcount(chip);
258259
for (; burstcnt > 0 && size < count; burstcnt--)
@@ -421,7 +422,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
421422

422423
if (wait_for_tpm_stat
423424
(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
424-
&chip->vendor.read_queue, false) < 0) {
425+
&priv->read_queue, false) < 0) {
425426
rc = -ETIME;
426427
goto out_err;
427428
}
@@ -575,7 +576,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
575576

576577
((struct priv_data *)chip->vendor.priv)->irq_tested = true;
577578
if (interrupt & TPM_INTF_DATA_AVAIL_INT)
578-
wake_up_interruptible(&chip->vendor.read_queue);
579+
wake_up_interruptible(&priv->read_queue);
579580
if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
580581
for (i = 0; i < 5; i++)
581582
if (check_locality(chip, i) >= 0)
@@ -795,7 +796,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
795796
}
796797

797798
/* INTERRUPT Setup */
798-
init_waitqueue_head(&chip->vendor.read_queue);
799+
init_waitqueue_head(&priv->read_queue);
799800
init_waitqueue_head(&priv->int_queue);
800801
if (interrupts && tpm_info->irq != -1) {
801802
if (tpm_info->irq) {

drivers/char/tpm/xen-tpmfront.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct tpm_private {
2929
int ring_ref;
3030
domid_t backend_id;
3131
int irq;
32+
wait_queue_head_t read_queue;
3233
};
3334

3435
enum status_bits {
@@ -89,7 +90,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
8990

9091
/* Wait for completion of any existing command or cancellation */
9192
if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c,
92-
&chip->vendor.read_queue, true) < 0) {
93+
&priv->read_queue, true) < 0) {
9394
vtpm_cancel(chip);
9495
return -ETIME;
9596
}
@@ -105,7 +106,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
105106
duration = tpm_calc_ordinal_duration(chip, ordinal);
106107

107108
if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration,
108-
&chip->vendor.read_queue, true) < 0) {
109+
&priv->read_queue, true) < 0) {
109110
/* got a signal or timeout, try to cancel */
110111
vtpm_cancel(chip);
111112
return -ETIME;
@@ -126,7 +127,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
126127

127128
/* In theory the wait at the end of _send makes this one unnecessary */
128129
if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c,
129-
&chip->vendor.read_queue, true) < 0) {
130+
&priv->read_queue, true) < 0) {
130131
vtpm_cancel(chip);
131132
return -ETIME;
132133
}
@@ -162,7 +163,7 @@ static irqreturn_t tpmif_interrupt(int dummy, void *dev_id)
162163
switch (priv->shr->state) {
163164
case VTPM_STATE_IDLE:
164165
case VTPM_STATE_FINISH:
165-
wake_up_interruptible(&priv->chip->vendor.read_queue);
166+
wake_up_interruptible(&priv->read_queue);
166167
break;
167168
case VTPM_STATE_SUBMIT:
168169
case VTPM_STATE_CANCEL:
@@ -180,7 +181,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)
180181
if (IS_ERR(chip))
181182
return PTR_ERR(chip);
182183

183-
init_waitqueue_head(&chip->vendor.read_queue);
184+
init_waitqueue_head(&priv->read_queue);
184185

185186
priv->chip = chip;
186187
TPM_VPRIV(chip) = priv;

0 commit comments

Comments
 (0)