tpm: suppress durations sysfs output if not read
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Tue, 23 Aug 2011 12:52:10 +0000 (08:52 -0400)
committerJames Morris <jmorris@namei.org>
Tue, 23 Aug 2011 23:30:08 +0000 (09:30 +1000)
Suppress the output in the 'durations' sysfs entry if they were not read
during driver initialization. This is similar to other sysfs entries
that return nothing if for some reason sending the commands to the TPM
fails.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
drivers/char/tpm/tpm.c

index caf8012ef47ce1c69af6f07df4f62e7c5676a581..e53af7638186840d449a65de533667dbb164316c 100644 (file)
@@ -963,6 +963,9 @@ ssize_t tpm_show_durations(struct device *dev, struct device_attribute *attr,
 {
        struct tpm_chip *chip = dev_get_drvdata(dev);
 
+       if (chip->vendor.duration[TPM_LONG] == 0)
+               return 0;
+
        return sprintf(buf, "%d %d %d [%s]\n",
                       jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
                       jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),