Skip to content

Commit de44b20

Browse files
cricard13Jarkko Sakkinen
authored andcommitted
tpm: drop 'locality' from struct tpm_vendor_specific
Dropped the field 'locality' from struct tpm_vendor_specific migrated it to the private structures of st33zp24, tpm_i2c_infineon and tpm_tis. 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 756b2bb commit de44b20

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

drivers/char/tpm/st33zp24/st33zp24.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int check_locality(struct tpm_chip *chip)
136136
if (status && (data &
137137
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
138138
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
139-
return chip->vendor.locality;
139+
return tpm_dev->locality;
140140

141141
return -EACCES;
142142
} /* check_locality() */
@@ -153,11 +153,11 @@ static int request_locality(struct tpm_chip *chip)
153153
struct st33zp24_dev *tpm_dev;
154154
u8 data;
155155

156-
if (check_locality(chip) == chip->vendor.locality)
157-
return chip->vendor.locality;
158-
159156
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
160157

158+
if (check_locality(chip) == tpm_dev->locality)
159+
return tpm_dev->locality;
160+
161161
data = TPM_ACCESS_REQUEST_USE;
162162
ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
163163
if (ret < 0)
@@ -168,7 +168,7 @@ static int request_locality(struct tpm_chip *chip)
168168
/* Request locality is usually effective after the request */
169169
do {
170170
if (check_locality(chip) >= 0)
171-
return chip->vendor.locality;
171+
return tpm_dev->locality;
172172
msleep(TPM_TIMEOUT);
173173
} while (time_before(jiffies, stop));
174174

@@ -566,7 +566,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
566566
chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
567567
chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
568568

569-
chip->vendor.locality = LOCALITY0;
569+
tpm_dev->locality = LOCALITY0;
570570

571571
if (irq) {
572572
/* INTERRUPT Setup */

drivers/char/tpm/st33zp24/st33zp24.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct st33zp24_dev {
2525
struct tpm_chip *chip;
2626
void *phy_id;
2727
const struct st33zp24_phy_ops *ops;
28+
int locality;
2829
int irq;
2930
u32 intrs;
3031
int io_lpcpd;

drivers/char/tpm/tpm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ enum tpm2_startup_types {
131131
struct tpm_chip;
132132

133133
struct tpm_vendor_specific {
134-
int locality;
135134
unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
136135
bool timeout_adjusted;
137136
unsigned long duration[3]; /* jiffies */

drivers/char/tpm/tpm_i2c_infineon.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ enum i2c_chip_type {
6666
/* Structure to store I2C TPM specific stuff */
6767
struct tpm_inf_dev {
6868
struct i2c_client *client;
69+
int locality;
6970
u8 buf[TPM_BUFSIZE + sizeof(u8)]; /* max. buffer size + addr */
7071
struct tpm_chip *chip;
7172
enum i2c_chip_type chip_type;
@@ -288,7 +289,7 @@ static int check_locality(struct tpm_chip *chip, int loc)
288289

289290
if ((buf & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
290291
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
291-
chip->vendor.locality = loc;
292+
tpm_dev.locality = loc;
292293
return loc;
293294
}
294295

@@ -337,7 +338,7 @@ static u8 tpm_tis_i2c_status(struct tpm_chip *chip)
337338
u8 i = 0;
338339

339340
do {
340-
if (iic_tpm_read(TPM_STS(chip->vendor.locality), &buf, 1) < 0)
341+
if (iic_tpm_read(TPM_STS(tpm_dev.locality), &buf, 1) < 0)
341342
return 0;
342343

343344
i++;
@@ -351,7 +352,7 @@ static void tpm_tis_i2c_ready(struct tpm_chip *chip)
351352
{
352353
/* this causes the current command to be aborted */
353354
u8 buf = TPM_STS_COMMAND_READY;
354-
iic_tpm_write_long(TPM_STS(chip->vendor.locality), &buf, 1);
355+
iic_tpm_write_long(TPM_STS(tpm_dev.locality), &buf, 1);
355356
}
356357

357358
static ssize_t get_burstcount(struct tpm_chip *chip)
@@ -365,7 +366,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip)
365366
stop = jiffies + chip->vendor.timeout_d;
366367
do {
367368
/* Note: STS is little endian */
368-
if (iic_tpm_read(TPM_STS(chip->vendor.locality)+1, buf, 3) < 0)
369+
if (iic_tpm_read(TPM_STS(tpm_dev.locality)+1, buf, 3) < 0)
369370
burstcnt = 0;
370371
else
371372
burstcnt = (buf[2] << 16) + (buf[1] << 8) + buf[0];
@@ -419,7 +420,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
419420
if (burstcnt > (count - size))
420421
burstcnt = count - size;
421422

422-
rc = iic_tpm_read(TPM_DATA_FIFO(chip->vendor.locality),
423+
rc = iic_tpm_read(TPM_DATA_FIFO(tpm_dev.locality),
423424
&(buf[size]), burstcnt);
424425
if (rc == 0)
425426
size += burstcnt;
@@ -477,7 +478,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
477478
* so we sleep rather than keeping the bus busy
478479
*/
479480
usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
480-
release_locality(chip, chip->vendor.locality, 0);
481+
release_locality(chip, tpm_dev.locality, 0);
481482
return size;
482483
}
483484

@@ -516,7 +517,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
516517
if (burstcnt > (len - 1 - count))
517518
burstcnt = len - 1 - count;
518519

519-
rc = iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality),
520+
rc = iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality),
520521
&(buf[count]), burstcnt);
521522
if (rc == 0)
522523
count += burstcnt;
@@ -539,15 +540,15 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
539540
}
540541

541542
/* write last byte */
542-
iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality), &(buf[count]), 1);
543+
iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
543544
wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
544545
if ((status & TPM_STS_DATA_EXPECT) != 0) {
545546
rc = -EIO;
546547
goto out_err;
547548
}
548549

549550
/* go and do it */
550-
iic_tpm_write(TPM_STS(chip->vendor.locality), &sts, 1);
551+
iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
551552

552553
return len;
553554
out_err:
@@ -556,7 +557,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
556557
* so we sleep rather than keeping the bus busy
557558
*/
558559
usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
559-
release_locality(chip, chip->vendor.locality, 0);
560+
release_locality(chip, tpm_dev.locality, 0);
560561
return rc;
561562
}
562563

@@ -623,7 +624,7 @@ static int tpm_tis_i2c_init(struct device *dev)
623624

624625
return tpm_chip_register(chip);
625626
out_release:
626-
release_locality(chip, chip->vendor.locality, 1);
627+
release_locality(chip, tpm_dev.locality, 1);
627628
tpm_dev.client = NULL;
628629
out_err:
629630
return rc;
@@ -695,7 +696,7 @@ static int tpm_tis_i2c_remove(struct i2c_client *client)
695696
struct tpm_chip *chip = tpm_dev.chip;
696697

697698
tpm_chip_unregister(chip);
698-
release_locality(chip, chip->vendor.locality, 1);
699+
release_locality(chip, tpm_dev.locality, 1);
699700
tpm_dev.client = NULL;
700701

701702
return 0;

0 commit comments

Comments
 (0)