@@ -104,7 +104,7 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
104104
105105 if (clear_wrfifo ) {
106106 for (i = 0 ; i < 4096 ; i ++ ) {
107- status = inb (chip -> vendor -> base + WRFIFO );
107+ status = inb (chip -> vendor . base + WRFIFO );
108108 if (status == 0xff ) {
109109 if (check == 5 )
110110 break ;
@@ -124,8 +124,8 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
124124 */
125125 i = 0 ;
126126 do {
127- status = inb (chip -> vendor -> base + RDFIFO );
128- status = inb (chip -> vendor -> base + STAT );
127+ status = inb (chip -> vendor . base + RDFIFO );
128+ status = inb (chip -> vendor . base + STAT );
129129 i ++ ;
130130 if (i == TPM_MAX_TRIES )
131131 return - EIO ;
@@ -138,7 +138,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
138138 int status ;
139139 int i ;
140140 for (i = 0 ; i < TPM_MAX_TRIES ; i ++ ) {
141- status = inb (chip -> vendor -> base + STAT );
141+ status = inb (chip -> vendor . base + STAT );
142142 /* check the status-register if wait_for_bit is set */
143143 if (status & 1 << wait_for_bit )
144144 break ;
@@ -157,7 +157,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
157157static void wait_and_send (struct tpm_chip * chip , u8 sendbyte )
158158{
159159 wait (chip , STAT_XFE );
160- outb (sendbyte , chip -> vendor -> base + WRFIFO );
160+ outb (sendbyte , chip -> vendor . base + WRFIFO );
161161}
162162
163163 /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
@@ -204,7 +204,7 @@ static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count)
204204 ret = wait (chip , STAT_RDA );
205205 if (ret )
206206 return - EIO ;
207- buf [i ] = inb (chip -> vendor -> base + RDFIFO );
207+ buf [i ] = inb (chip -> vendor . base + RDFIFO );
208208 }
209209
210210 if (buf [0 ] != TPM_VL_VER ) {
@@ -219,7 +219,7 @@ static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count)
219219
220220 for (i = 0 ; i < size ; i ++ ) {
221221 wait (chip , STAT_RDA );
222- buf [i ] = inb (chip -> vendor -> base + RDFIFO );
222+ buf [i ] = inb (chip -> vendor . base + RDFIFO );
223223 }
224224
225225 if ((size == 0x6D00 ) && (buf [1 ] == 0x80 )) {
@@ -268,7 +268,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
268268 u8 count_high , count_low , count_4 , count_3 , count_2 , count_1 ;
269269
270270 /* Disabling Reset, LP and IRQC */
271- outb (RESET_LP_IRQC_DISABLE , chip -> vendor -> base + CMD );
271+ outb (RESET_LP_IRQC_DISABLE , chip -> vendor . base + CMD );
272272
273273 ret = empty_fifo (chip , 1 );
274274 if (ret ) {
@@ -319,7 +319,7 @@ static void tpm_inf_cancel(struct tpm_chip *chip)
319319
320320static u8 tpm_inf_status (struct tpm_chip * chip )
321321{
322- return inb (chip -> vendor -> base + STAT );
322+ return inb (chip -> vendor . base + STAT );
323323}
324324
325325static DEVICE_ATTR (pubek , S_IRUGO , tpm_show_pubek , NULL) ;
@@ -346,7 +346,7 @@ static struct file_operations inf_ops = {
346346 .release = tpm_release ,
347347};
348348
349- static struct tpm_vendor_specific tpm_inf = {
349+ static const struct tpm_vendor_specific tpm_inf = {
350350 .recv = tpm_inf_recv ,
351351 .send = tpm_inf_send ,
352352 .cancel = tpm_inf_cancel ,
@@ -375,6 +375,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
375375 int version [2 ];
376376 int productid [2 ];
377377 char chipname [20 ];
378+ struct tpm_chip * chip ;
378379
379380 /* read IO-ports through PnP */
380381 if (pnp_port_valid (dev , 0 ) && pnp_port_valid (dev , 1 ) &&
@@ -395,14 +396,13 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
395396 goto err_last ;
396397 }
397398 /* publish my base address and request region */
398- tpm_inf .base = TPM_INF_BASE ;
399399 if (request_region
400- (tpm_inf . base , TPM_INF_PORT_LEN , "tpm_infineon0" ) == NULL ) {
400+ (TPM_INF_BASE , TPM_INF_PORT_LEN , "tpm_infineon0" ) == NULL ) {
401401 rc = - EINVAL ;
402402 goto err_last ;
403403 }
404- if (request_region ( TPM_INF_ADDR , TPM_INF_ADDR_LEN ,
405- "tpm_infineon0" ) == NULL ) {
404+ if (request_region
405+ ( TPM_INF_ADDR , TPM_INF_ADDR_LEN , "tpm_infineon0" ) == NULL ) {
406406 rc = - EINVAL ;
407407 goto err_last ;
408408 }
@@ -442,20 +442,20 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
442442
443443 /* configure TPM with IO-ports */
444444 outb (IOLIMH , TPM_INF_ADDR );
445- outb (((tpm_inf . base >> 8 ) & 0xff ), TPM_INF_DATA );
445+ outb (((TPM_INF_BASE >> 8 ) & 0xff ), TPM_INF_DATA );
446446 outb (IOLIML , TPM_INF_ADDR );
447- outb ((tpm_inf . base & 0xff ), TPM_INF_DATA );
447+ outb ((TPM_INF_BASE & 0xff ), TPM_INF_DATA );
448448
449449 /* control if IO-ports are set correctly */
450450 outb (IOLIMH , TPM_INF_ADDR );
451451 ioh = inb (TPM_INF_DATA );
452452 outb (IOLIML , TPM_INF_ADDR );
453453 iol = inb (TPM_INF_DATA );
454454
455- if ((ioh << 8 | iol ) != tpm_inf . base ) {
455+ if ((ioh << 8 | iol ) != TPM_INF_BASE ) {
456456 dev_err (& dev -> dev ,
457- "Could not set IO-ports to 0x%lx \n" ,
458- tpm_inf . base );
457+ "Could not set IO-ports to 0x%x \n" ,
458+ TPM_INF_BASE );
459459 rc = - EIO ;
460460 goto err_release_region ;
461461 }
@@ -466,35 +466,34 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
466466 outb (DISABLE_REGISTER_PAIR , TPM_INF_ADDR );
467467
468468 /* disable RESET, LP and IRQC */
469- outb (RESET_LP_IRQC_DISABLE , tpm_inf . base + CMD );
469+ outb (RESET_LP_IRQC_DISABLE , TPM_INF_BASE + CMD );
470470
471471 /* Finally, we're done, print some infos */
472472 dev_info (& dev -> dev , "TPM found: "
473473 "config base 0x%x, "
474474 "io base 0x%x, "
475- "chip version %02x%02x, "
476- "vendor id %x%x (Infineon), "
477- "product id %02x%02x"
475+ "chip version 0x %02x%02x, "
476+ "vendor id 0x %x%x (Infineon), "
477+ "product id 0x %02x%02x"
478478 "%s\n" ,
479479 TPM_INF_ADDR ,
480480 TPM_INF_BASE ,
481481 version [0 ], version [1 ],
482482 vendorid [0 ], vendorid [1 ],
483483 productid [0 ], productid [1 ], chipname );
484484
485- rc = tpm_register_hardware (& dev -> dev , & tpm_inf );
486- if (rc < 0 ) {
487- rc = - ENODEV ;
485+ if (!(chip = tpm_register_hardware (& dev -> dev , & tpm_inf ))) {
488486 goto err_release_region ;
489487 }
488+ chip -> vendor .base = TPM_INF_BASE ;
490489 return 0 ;
491490 } else {
492491 rc = - ENODEV ;
493492 goto err_release_region ;
494493 }
495494
496495err_release_region :
497- release_region (tpm_inf . base , TPM_INF_PORT_LEN );
496+ release_region (TPM_INF_BASE , TPM_INF_PORT_LEN );
498497 release_region (TPM_INF_ADDR , TPM_INF_ADDR_LEN );
499498
500499err_last :
@@ -506,7 +505,8 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev)
506505 struct tpm_chip * chip = pnp_get_drvdata (dev );
507506
508507 if (chip ) {
509- release_region (chip -> vendor -> base , TPM_INF_PORT_LEN );
508+ release_region (TPM_INF_BASE , TPM_INF_PORT_LEN );
509+ release_region (TPM_INF_ADDR , TPM_INF_ADDR_LEN );
510510 tpm_remove_hardware (chip -> dev );
511511 }
512512}
@@ -538,5 +538,5 @@ module_exit(cleanup_inf);
538538
539539MODULE_AUTHOR ("Marcel Selhorst <selhorst@crypto.rub.de>" );
540540MODULE_DESCRIPTION ("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2" );
541- MODULE_VERSION ("1.7 " );
541+ MODULE_VERSION ("1.8 " );
542542MODULE_LICENSE ("GPL" );
0 commit comments