aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm.c
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2011-01-11 14:37:29 -0500
committerRajiv Andrade <srajiv@linux.vnet.ibm.com>2011-02-10 22:30:50 -0500
commit9b29050f8f75916f974a2d231ae5d3cd59792296 (patch)
treee556ea7e22297756159a1c564ed576671c419fb8 /drivers/char/tpm/tpm.c
parentd3d373e0e3f51f335d8c722dd1340ab812fdf94b (diff)
tpm_tis: Use timeouts returned from TPM
The current TPM TIS driver in git discards the timeout values returned from the TPM. The check of the response packet needs to consider that the return_code field is 0 on success and the size of the expected packet is equivalent to the header size + u32 length indicator for the TPM_GetCapability() result + 3 timeout indicators of type u32. I am also adding a sysfs entry 'timeouts' showing the timeouts that are being used. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Tested-by: Guillaume Chazarain <guichaz@gmail.com> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r--drivers/char/tpm/tpm.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 36e0fa161c2b..faf5a2c65926 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -577,9 +577,11 @@ duration:
577 if (rc) 577 if (rc)
578 return; 578 return;
579 579
580 if (be32_to_cpu(tpm_cmd.header.out.return_code) 580 if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
581 != 3 * sizeof(u32)) 581 be32_to_cpu(tpm_cmd.header.out.length)
582 != sizeof(tpm_cmd.header.out) + sizeof(u32) + 3 * sizeof(u32))
582 return; 583 return;
584
583 duration_cap = &tpm_cmd.params.getcap_out.cap.duration; 585 duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
584 chip->vendor.duration[TPM_SHORT] = 586 chip->vendor.duration[TPM_SHORT] =
585 usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short)); 587 usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
@@ -939,6 +941,18 @@ ssize_t tpm_show_caps_1_2(struct device * dev,
939} 941}
940EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); 942EXPORT_SYMBOL_GPL(tpm_show_caps_1_2);
941 943
944ssize_t tpm_show_timeouts(struct device *dev, struct device_attribute *attr,
945 char *buf)
946{
947 struct tpm_chip *chip = dev_get_drvdata(dev);
948
949 return sprintf(buf, "%d %d %d\n",
950 jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
951 jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),
952 jiffies_to_usecs(chip->vendor.duration[TPM_LONG]));
953}
954EXPORT_SYMBOL_GPL(tpm_show_timeouts);
955
942ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, 956ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr,
943 const char *buf, size_t count) 957 const char *buf, size_t count)
944{ 958{