aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorKylene Hall <kjhall@us.ibm.com>2005-06-24 01:02:08 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:27 -0400
commite234bc970451edc4021637fe2979b887da873f9a (patch)
tree37d27588e21bd686f1377d4cad207f4a06a4a9ff /drivers/char
parente1a23c6671f2bfd6e5e112848f01334ca39ea2b1 (diff)
[PATCH] tpm: add debugging output
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')
-rw-r--r--drivers/char/tpm/tpm.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 726d1b5b33b0..785dce67942f 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -146,8 +146,12 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
146 146
147 memcpy(data, cap_pcr, sizeof(cap_pcr)); 147 memcpy(data, cap_pcr, sizeof(cap_pcr));
148 if ((len = tpm_transmit(chip, data, sizeof(data))) 148 if ((len = tpm_transmit(chip, data, sizeof(data)))
149 < CAP_PCR_RESULT_SIZE) 149 < CAP_PCR_RESULT_SIZE) {
150 return len; 150 dev_err(&chip->pci_dev->dev, "A TPM error (%d) occurred "
151 "attempting to determine the number of PCRS\n",
152 be32_to_cpu(*((__be32 *) (data + 6))));
153 return 0;
154 }
151 155
152 num_pcrs = be32_to_cpu(*((__be32 *) (data + 14))); 156 num_pcrs = be32_to_cpu(*((__be32 *) (data + 14)));
153 157
@@ -156,16 +160,20 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr,
156 index = cpu_to_be32(i); 160 index = cpu_to_be32(i);
157 memcpy(data + 10, &index, 4); 161 memcpy(data + 10, &index, 4);
158 if ((len = tpm_transmit(chip, data, sizeof(data))) 162 if ((len = tpm_transmit(chip, data, sizeof(data)))
159 < READ_PCR_RESULT_SIZE) 163 < READ_PCR_RESULT_SIZE){
160 return len; 164 dev_err(&chip->pci_dev->dev, "A TPM error (%d) occurred"
165 " attempting to read PCR %d of %d\n",
166 be32_to_cpu(*((__be32 *) (data + 6))), i, num_pcrs);
167 goto out;
168 }
161 str += sprintf(str, "PCR-%02d: ", i); 169 str += sprintf(str, "PCR-%02d: ", i);
162 for (j = 0; j < TPM_DIGEST_SIZE; j++) 170 for (j = 0; j < TPM_DIGEST_SIZE; j++)
163 str += sprintf(str, "%02X ", *(data + 10 + j)); 171 str += sprintf(str, "%02X ", *(data + 10 + j));
164 str += sprintf(str, "\n"); 172 str += sprintf(str, "\n");
165 } 173 }
174out:
166 return str - buf; 175 return str - buf;
167} 176}
168
169EXPORT_SYMBOL_GPL(tpm_show_pcrs); 177EXPORT_SYMBOL_GPL(tpm_show_pcrs);
170 178
171#define READ_PUBEK_RESULT_SIZE 314 179#define READ_PUBEK_RESULT_SIZE 314
@@ -197,8 +205,10 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
197 205
198 if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) < 206 if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) <
199 READ_PUBEK_RESULT_SIZE) { 207 READ_PUBEK_RESULT_SIZE) {
200 rc = len; 208 dev_err(&chip->pci_dev->dev, "A TPM error (%d) occurred "
201 goto out; 209 "attempting to read the PUBEK\n",
210 be32_to_cpu(*((__be32 *) (data + 6))));
211 return 0;
202 } 212 }
203 213
204 /* 214 /*
@@ -230,7 +240,6 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr,
230 str += sprintf(str, "\n"); 240 str += sprintf(str, "\n");
231 } 241 }
232 rc = str - buf; 242 rc = str - buf;
233out:
234 kfree(data); 243 kfree(data);
235 return rc; 244 return rc;
236} 245}