diff options
author | Kylene Jo Hall <kjhall@us.ibm.com> | 2006-04-22 05:37:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-22 12:19:53 -0400 |
commit | 90dda520c1962d55a0e1d2571deed0d75fd6d6f1 (patch) | |
tree | 38d0da2fbeabb595f248f6029e470a1f2acd763a /drivers/char/tpm/tpm.c | |
parent | beed53a1aaeaae4eb93297c23f1598a726716adf (diff) |
[PATCH] tpm: chip struct update
To assist with chip management and better support the possibility of having
multiple TPMs in the system of the same kind, the struct tpm_vendor_specific
member of the tpm_chip was changed from a pointer to an instance. This patch
changes that declaration and fixes up all accesses to the structure member
except in tpm_infineon which is coming in a patch from Marcel Selhorst.
Signed-off-by: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 187bcdaf7bf6..50013eb8cf1e 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -78,7 +78,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
78 | 78 | ||
79 | down(&chip->tpm_mutex); | 79 | down(&chip->tpm_mutex); |
80 | 80 | ||
81 | if ((rc = chip->vendor->send(chip, (u8 *) buf, count)) < 0) { | 81 | if ((rc = chip->vendor.send(chip, (u8 *) buf, count)) < 0) { |
82 | dev_err(chip->dev, | 82 | dev_err(chip->dev, |
83 | "tpm_transmit: tpm_send: error %zd\n", rc); | 83 | "tpm_transmit: tpm_send: error %zd\n", rc); |
84 | goto out; | 84 | goto out; |
@@ -86,13 +86,12 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
86 | 86 | ||
87 | stop = jiffies + 2 * 60 * HZ; | 87 | stop = jiffies + 2 * 60 * HZ; |
88 | do { | 88 | do { |
89 | u8 status = chip->vendor->status(chip); | 89 | u8 status = chip->vendor.status(chip); |
90 | if ((status & chip->vendor->req_complete_mask) == | 90 | if ((status & chip->vendor.req_complete_mask) == |
91 | chip->vendor->req_complete_val) { | 91 | chip->vendor.req_complete_val) |
92 | goto out_recv; | 92 | goto out_recv; |
93 | } | ||
94 | 93 | ||
95 | if ((status == chip->vendor->req_canceled)) { | 94 | if ((status == chip->vendor.req_canceled)) { |
96 | dev_err(chip->dev, "Operation Canceled\n"); | 95 | dev_err(chip->dev, "Operation Canceled\n"); |
97 | rc = -ECANCELED; | 96 | rc = -ECANCELED; |
98 | goto out; | 97 | goto out; |
@@ -102,14 +101,13 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
102 | rmb(); | 101 | rmb(); |
103 | } while (time_before(jiffies, stop)); | 102 | } while (time_before(jiffies, stop)); |
104 | 103 | ||
105 | 104 | chip->vendor.cancel(chip); | |
106 | chip->vendor->cancel(chip); | ||
107 | dev_err(chip->dev, "Operation Timed out\n"); | 105 | dev_err(chip->dev, "Operation Timed out\n"); |
108 | rc = -ETIME; | 106 | rc = -ETIME; |
109 | goto out; | 107 | goto out; |
110 | 108 | ||
111 | out_recv: | 109 | out_recv: |
112 | rc = chip->vendor->recv(chip, (u8 *) buf, bufsiz); | 110 | rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz); |
113 | if (rc < 0) | 111 | if (rc < 0) |
114 | dev_err(chip->dev, | 112 | dev_err(chip->dev, |
115 | "tpm_transmit: tpm_recv: error %zd\n", rc); | 113 | "tpm_transmit: tpm_recv: error %zd\n", rc); |
@@ -340,7 +338,7 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | |||
340 | if (chip == NULL) | 338 | if (chip == NULL) |
341 | return 0; | 339 | return 0; |
342 | 340 | ||
343 | chip->vendor->cancel(chip); | 341 | chip->vendor.cancel(chip); |
344 | return count; | 342 | return count; |
345 | } | 343 | } |
346 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | 344 | EXPORT_SYMBOL_GPL(tpm_store_cancel); |
@@ -356,7 +354,7 @@ int tpm_open(struct inode *inode, struct file *file) | |||
356 | spin_lock(&driver_lock); | 354 | spin_lock(&driver_lock); |
357 | 355 | ||
358 | list_for_each_entry(pos, &tpm_chip_list, list) { | 356 | list_for_each_entry(pos, &tpm_chip_list, list) { |
359 | if (pos->vendor->miscdev.minor == minor) { | 357 | if (pos->vendor.miscdev.minor == minor) { |
360 | chip = pos; | 358 | chip = pos; |
361 | break; | 359 | break; |
362 | } | 360 | } |
@@ -488,14 +486,14 @@ void tpm_remove_hardware(struct device *dev) | |||
488 | spin_unlock(&driver_lock); | 486 | spin_unlock(&driver_lock); |
489 | 487 | ||
490 | dev_set_drvdata(dev, NULL); | 488 | dev_set_drvdata(dev, NULL); |
491 | misc_deregister(&chip->vendor->miscdev); | 489 | misc_deregister(&chip->vendor.miscdev); |
492 | kfree(chip->vendor->miscdev.name); | 490 | kfree(chip->vendor.miscdev.name); |
493 | 491 | ||
494 | sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); | 492 | sysfs_remove_group(&dev->kobj, chip->vendor.attr_group); |
495 | tpm_bios_log_teardown(chip->bios_dir); | 493 | tpm_bios_log_teardown(chip->bios_dir); |
496 | 494 | ||
497 | dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= | 495 | dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES] &= |
498 | ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); | 496 | ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); |
499 | 497 | ||
500 | kfree(chip); | 498 | kfree(chip); |
501 | 499 | ||
@@ -569,7 +567,7 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry) | |||
569 | chip->user_read_timer.function = user_reader_timeout; | 567 | chip->user_read_timer.function = user_reader_timeout; |
570 | chip->user_read_timer.data = (unsigned long) chip; | 568 | chip->user_read_timer.data = (unsigned long) chip; |
571 | 569 | ||
572 | chip->vendor = entry; | 570 | memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific)); |
573 | 571 | ||
574 | chip->dev_num = -1; | 572 | chip->dev_num = -1; |
575 | 573 | ||
@@ -588,22 +586,22 @@ dev_num_search_complete: | |||
588 | kfree(chip); | 586 | kfree(chip); |
589 | return -ENODEV; | 587 | return -ENODEV; |
590 | } else if (chip->dev_num == 0) | 588 | } else if (chip->dev_num == 0) |
591 | chip->vendor->miscdev.minor = TPM_MINOR; | 589 | chip->vendor.miscdev.minor = TPM_MINOR; |
592 | else | 590 | else |
593 | chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR; | 591 | chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR; |
594 | 592 | ||
595 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); | 593 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); |
596 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); | 594 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); |
597 | chip->vendor->miscdev.name = devname; | 595 | chip->vendor.miscdev.name = devname; |
598 | 596 | ||
599 | chip->vendor->miscdev.dev = dev; | 597 | chip->vendor.miscdev.dev = dev; |
600 | chip->dev = get_device(dev); | 598 | chip->dev = get_device(dev); |
601 | 599 | ||
602 | if (misc_register(&chip->vendor->miscdev)) { | 600 | if (misc_register(&chip->vendor.miscdev)) { |
603 | dev_err(chip->dev, | 601 | dev_err(chip->dev, |
604 | "unable to misc_register %s, minor %d\n", | 602 | "unable to misc_register %s, minor %d\n", |
605 | chip->vendor->miscdev.name, | 603 | chip->vendor.miscdev.name, |
606 | chip->vendor->miscdev.minor); | 604 | chip->vendor.miscdev.minor); |
607 | put_device(dev); | 605 | put_device(dev); |
608 | kfree(chip); | 606 | kfree(chip); |
609 | dev_mask[i] &= !(1 << j); | 607 | dev_mask[i] &= !(1 << j); |
@@ -618,7 +616,7 @@ dev_num_search_complete: | |||
618 | 616 | ||
619 | spin_unlock(&driver_lock); | 617 | spin_unlock(&driver_lock); |
620 | 618 | ||
621 | sysfs_create_group(&dev->kobj, chip->vendor->attr_group); | 619 | sysfs_create_group(&dev->kobj, chip->vendor.attr_group); |
622 | 620 | ||
623 | chip->bios_dir = tpm_bios_log_setup(devname); | 621 | chip->bios_dir = tpm_bios_log_setup(devname); |
624 | 622 | ||