aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>2013-09-17 20:19:44 -0400
committerPeter Huewe <peterhuewe@gmx.de>2013-10-22 13:42:41 -0400
commite907481bed439cd04fb24084baab41015b89da6e (patch)
tree70bee2856387ab821ae02fe95b7fecc2c710871f /drivers/char
parentcb996158dfe8a31377700f46b7f3d69ddc5ae1e4 (diff)
tpm: Remove tpm_show_caps_1_2
The version of the TPM should not depend on the bus it is connected through. 1.1, 1.2 and soon 2.0 TPMS will be all be able to use the same bus interfaces. Make tpm_show_caps try the 1.2 capability first. If that fails then fall back to the 1.1 capability. This effectively auto-detects what interface the TPM supports at run-time. Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com> Reviewed-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tpm/tpm.c56
-rw-r--r--drivers/char/tpm/tpm.h2
-rw-r--r--drivers/char/tpm/tpm_i2c_infineon.c2
-rw-r--r--drivers/char/tpm/tpm_i2c_stm_st33.c2
-rw-r--r--drivers/char/tpm/tpm_ibmvtpm.c2
-rw-r--r--drivers/char/tpm/tpm_tis.c2
6 files changed, 27 insertions, 39 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index c3ab508222af..72f0c68d466e 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1020,43 +1020,33 @@ ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr,
1020 str += sprintf(str, "Manufacturer: 0x%x\n", 1020 str += sprintf(str, "Manufacturer: 0x%x\n",
1021 be32_to_cpu(cap.manufacturer_id)); 1021 be32_to_cpu(cap.manufacturer_id));
1022 1022
1023 rc = tpm_getcap(dev, CAP_VERSION_1_1, &cap, 1023 /* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
1024 "attempting to determine the 1.1 version");
1025 if (rc)
1026 return 0;
1027 str += sprintf(str,
1028 "TCG version: %d.%d\nFirmware version: %d.%d\n",
1029 cap.tpm_version.Major, cap.tpm_version.Minor,
1030 cap.tpm_version.revMajor, cap.tpm_version.revMinor);
1031 return str - buf;
1032}
1033EXPORT_SYMBOL_GPL(tpm_show_caps);
1034
1035ssize_t tpm_show_caps_1_2(struct device * dev,
1036 struct device_attribute * attr, char *buf)
1037{
1038 cap_t cap;
1039 ssize_t rc;
1040 char *str = buf;
1041
1042 rc = tpm_getcap(dev, TPM_CAP_PROP_MANUFACTURER, &cap,
1043 "attempting to determine the manufacturer");
1044 if (rc)
1045 return 0;
1046 str += sprintf(str, "Manufacturer: 0x%x\n",
1047 be32_to_cpu(cap.manufacturer_id));
1048 rc = tpm_getcap(dev, CAP_VERSION_1_2, &cap, 1024 rc = tpm_getcap(dev, CAP_VERSION_1_2, &cap,
1049 "attempting to determine the 1.2 version"); 1025 "attempting to determine the 1.2 version");
1050 if (rc) 1026 if (!rc) {
1051 return 0; 1027 str += sprintf(str,
1052 str += sprintf(str, 1028 "TCG version: %d.%d\nFirmware version: %d.%d\n",
1053 "TCG version: %d.%d\nFirmware version: %d.%d\n", 1029 cap.tpm_version_1_2.Major,
1054 cap.tpm_version_1_2.Major, cap.tpm_version_1_2.Minor, 1030 cap.tpm_version_1_2.Minor,
1055 cap.tpm_version_1_2.revMajor, 1031 cap.tpm_version_1_2.revMajor,
1056 cap.tpm_version_1_2.revMinor); 1032 cap.tpm_version_1_2.revMinor);
1033 } else {
1034 /* Otherwise just use TPM_STRUCT_VER */
1035 rc = tpm_getcap(dev, CAP_VERSION_1_1, &cap,
1036 "attempting to determine the 1.1 version");
1037 if (rc)
1038 return 0;
1039 str += sprintf(str,
1040 "TCG version: %d.%d\nFirmware version: %d.%d\n",
1041 cap.tpm_version.Major,
1042 cap.tpm_version.Minor,
1043 cap.tpm_version.revMajor,
1044 cap.tpm_version.revMinor);
1045 }
1046
1057 return str - buf; 1047 return str - buf;
1058} 1048}
1059EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); 1049EXPORT_SYMBOL_GPL(tpm_show_caps);
1060 1050
1061ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr, 1051ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr,
1062 char *buf) 1052 char *buf)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 0df18b56b2c5..f32847872193 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -59,8 +59,6 @@ extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr,
59 char *); 59 char *);
60extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr, 60extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr,
61 char *); 61 char *);
62extern ssize_t tpm_show_caps_1_2(struct device *, struct device_attribute *attr,
63 char *);
64extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr, 62extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr,
65 const char *, size_t); 63 const char *, size_t);
66extern ssize_t tpm_show_enabled(struct device *, struct device_attribute *attr, 64extern ssize_t tpm_show_enabled(struct device *, struct device_attribute *attr,
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index e33d8e551eff..fefd2aa5c81e 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -581,7 +581,7 @@ static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
581static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL); 581static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
582static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); 582static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
583static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL); 583static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
584static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); 584static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
585static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); 585static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
586static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL); 586static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
587static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL); 587static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
index b2390b6173e7..a0d6ceb5d005 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -584,7 +584,7 @@ static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL);
584static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL); 584static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
585static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); 585static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
586static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL); 586static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, NULL);
587static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); 587static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
588static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); 588static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
589 589
590static struct attribute *stm_tpm_attrs[] = { 590static struct attribute *stm_tpm_attrs[] = {
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index 838f04314814..2783a42aa732 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -419,7 +419,7 @@ static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
419static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); 419static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
420static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, 420static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
421 NULL); 421 NULL);
422static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); 422static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
423static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); 423static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
424static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL); 424static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
425static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL); 425static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 5796d0157ce0..1b74459c0723 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -448,7 +448,7 @@ static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL);
448static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); 448static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL);
449static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, 449static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated,
450 NULL); 450 NULL);
451static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); 451static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
452static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); 452static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel);
453static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL); 453static DEVICE_ATTR(durations, S_IRUGO, tpm_show_durations, NULL);
454static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL); 454static DEVICE_ATTR(timeouts, S_IRUGO, tpm_show_timeouts, NULL);