@@ -66,6 +66,7 @@ enum i2c_chip_type {
66
66
/* Structure to store I2C TPM specific stuff */
67
67
struct tpm_inf_dev {
68
68
struct i2c_client * client ;
69
+ int locality ;
69
70
u8 buf [TPM_BUFSIZE + sizeof (u8 )]; /* max. buffer size + addr */
70
71
struct tpm_chip * chip ;
71
72
enum i2c_chip_type chip_type ;
@@ -288,7 +289,7 @@ static int check_locality(struct tpm_chip *chip, int loc)
288
289
289
290
if ((buf & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID )) ==
290
291
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID )) {
291
- chip -> vendor .locality = loc ;
292
+ tpm_dev .locality = loc ;
292
293
return loc ;
293
294
}
294
295
@@ -337,7 +338,7 @@ static u8 tpm_tis_i2c_status(struct tpm_chip *chip)
337
338
u8 i = 0 ;
338
339
339
340
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 )
341
342
return 0 ;
342
343
343
344
i ++ ;
@@ -351,7 +352,7 @@ static void tpm_tis_i2c_ready(struct tpm_chip *chip)
351
352
{
352
353
/* this causes the current command to be aborted */
353
354
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 );
355
356
}
356
357
357
358
static ssize_t get_burstcount (struct tpm_chip * chip )
@@ -365,7 +366,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip)
365
366
stop = jiffies + chip -> vendor .timeout_d ;
366
367
do {
367
368
/* 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 )
369
370
burstcnt = 0 ;
370
371
else
371
372
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)
419
420
if (burstcnt > (count - size ))
420
421
burstcnt = count - size ;
421
422
422
- rc = iic_tpm_read (TPM_DATA_FIFO (chip -> vendor .locality ),
423
+ rc = iic_tpm_read (TPM_DATA_FIFO (tpm_dev .locality ),
423
424
& (buf [size ]), burstcnt );
424
425
if (rc == 0 )
425
426
size += burstcnt ;
@@ -477,7 +478,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
477
478
* so we sleep rather than keeping the bus busy
478
479
*/
479
480
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 );
481
482
return size ;
482
483
}
483
484
@@ -516,7 +517,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
516
517
if (burstcnt > (len - 1 - count ))
517
518
burstcnt = len - 1 - count ;
518
519
519
- rc = iic_tpm_write (TPM_DATA_FIFO (chip -> vendor .locality ),
520
+ rc = iic_tpm_write (TPM_DATA_FIFO (tpm_dev .locality ),
520
521
& (buf [count ]), burstcnt );
521
522
if (rc == 0 )
522
523
count += burstcnt ;
@@ -539,15 +540,15 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
539
540
}
540
541
541
542
/* 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 );
543
544
wait_for_stat (chip , TPM_STS_VALID , chip -> vendor .timeout_c , & status );
544
545
if ((status & TPM_STS_DATA_EXPECT ) != 0 ) {
545
546
rc = - EIO ;
546
547
goto out_err ;
547
548
}
548
549
549
550
/* 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 );
551
552
552
553
return len ;
553
554
out_err :
@@ -556,7 +557,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
556
557
* so we sleep rather than keeping the bus busy
557
558
*/
558
559
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 );
560
561
return rc ;
561
562
}
562
563
@@ -623,7 +624,7 @@ static int tpm_tis_i2c_init(struct device *dev)
623
624
624
625
return tpm_chip_register (chip );
625
626
out_release :
626
- release_locality (chip , chip -> vendor .locality , 1 );
627
+ release_locality (chip , tpm_dev .locality , 1 );
627
628
tpm_dev .client = NULL ;
628
629
out_err :
629
630
return rc ;
@@ -695,7 +696,7 @@ static int tpm_tis_i2c_remove(struct i2c_client *client)
695
696
struct tpm_chip * chip = tpm_dev .chip ;
696
697
697
698
tpm_chip_unregister (chip );
698
- release_locality (chip , chip -> vendor .locality , 1 );
699
+ release_locality (chip , tpm_dev .locality , 1 );
699
700
tpm_dev .client = NULL ;
700
701
701
702
return 0 ;
0 commit comments