diff options
-rw-r--r-- | drivers/char/tpm/tpm.c | 35 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.h | 9 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 16 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_nsc.c | 17 |
4 files changed, 64 insertions, 13 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 84b2d46e6ff0..b72050c851d2 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -208,7 +208,8 @@ static const u8 pcrread[] = { | |||
208 | 0, 0, 0, 0 /* PCR index */ | 208 | 0, 0, 0, 0 /* PCR index */ |
209 | }; | 209 | }; |
210 | 210 | ||
211 | static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char *buf) | 211 | ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, |
212 | char *buf) | ||
212 | { | 213 | { |
213 | u8 data[READ_PCR_RESULT_SIZE]; | 214 | u8 data[READ_PCR_RESULT_SIZE]; |
214 | ssize_t len; | 215 | ssize_t len; |
@@ -243,7 +244,7 @@ static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char | |||
243 | return str - buf; | 244 | return str - buf; |
244 | } | 245 | } |
245 | 246 | ||
246 | static DEVICE_ATTR(pcrs, S_IRUGO, show_pcrs, NULL); | 247 | EXPORT_SYMBOL_GPL(tpm_show_pcrs); |
247 | 248 | ||
248 | #define READ_PUBEK_RESULT_SIZE 314 | 249 | #define READ_PUBEK_RESULT_SIZE 314 |
249 | static const u8 readpubek[] = { | 250 | static const u8 readpubek[] = { |
@@ -252,7 +253,8 @@ static const u8 readpubek[] = { | |||
252 | 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ | 253 | 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ |
253 | }; | 254 | }; |
254 | 255 | ||
255 | static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf) | 256 | ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, |
257 | char *buf) | ||
256 | { | 258 | { |
257 | u8 *data; | 259 | u8 *data; |
258 | ssize_t len; | 260 | ssize_t len; |
@@ -311,7 +313,7 @@ out: | |||
311 | return rc; | 313 | return rc; |
312 | } | 314 | } |
313 | 315 | ||
314 | static DEVICE_ATTR(pubek, S_IRUGO, show_pubek, NULL); | 316 | EXPORT_SYMBOL_GPL(tpm_show_pubek); |
315 | 317 | ||
316 | #define CAP_VER_RESULT_SIZE 18 | 318 | #define CAP_VER_RESULT_SIZE 18 |
317 | static const u8 cap_version[] = { | 319 | static const u8 cap_version[] = { |
@@ -332,7 +334,8 @@ static const u8 cap_manufacturer[] = { | |||
332 | 0, 0, 1, 3 | 334 | 0, 0, 1, 3 |
333 | }; | 335 | }; |
334 | 336 | ||
335 | static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf) | 337 | ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, |
338 | char *buf) | ||
336 | { | 339 | { |
337 | u8 data[sizeof(cap_manufacturer)]; | 340 | u8 data[sizeof(cap_manufacturer)]; |
338 | ssize_t len; | 341 | ssize_t len; |
@@ -365,8 +368,20 @@ static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char | |||
365 | 368 | ||
366 | return str - buf; | 369 | return str - buf; |
367 | } | 370 | } |
371 | EXPORT_SYMBOL_GPL(tpm_show_caps); | ||
372 | |||
373 | ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | ||
374 | const char *buf, size_t count) | ||
375 | { | ||
376 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
377 | if (chip == NULL) | ||
378 | return 0; | ||
379 | |||
380 | chip->vendor->cancel(chip); | ||
381 | return count; | ||
382 | } | ||
383 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | ||
368 | 384 | ||
369 | static DEVICE_ATTR(caps, S_IRUGO, show_caps, NULL); | ||
370 | 385 | ||
371 | /* | 386 | /* |
372 | * Device file system interface to the TPM | 387 | * Device file system interface to the TPM |
@@ -517,9 +532,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev) | |||
517 | pci_set_drvdata(pci_dev, NULL); | 532 | pci_set_drvdata(pci_dev, NULL); |
518 | misc_deregister(&chip->vendor->miscdev); | 533 | misc_deregister(&chip->vendor->miscdev); |
519 | 534 | ||
520 | device_remove_file(&pci_dev->dev, &dev_attr_pubek); | 535 | sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group); |
521 | device_remove_file(&pci_dev->dev, &dev_attr_pcrs); | ||
522 | device_remove_file(&pci_dev->dev, &dev_attr_caps); | ||
523 | 536 | ||
524 | pci_disable_device(pci_dev); | 537 | pci_disable_device(pci_dev); |
525 | 538 | ||
@@ -648,9 +661,7 @@ dev_num_search_complete: | |||
648 | 661 | ||
649 | list_add(&chip->list, &tpm_chip_list); | 662 | list_add(&chip->list, &tpm_chip_list); |
650 | 663 | ||
651 | device_create_file(&pci_dev->dev, &dev_attr_pubek); | 664 | sysfs_create_group(&pci_dev->dev.kobj, chip->vendor->attr_group); |
652 | device_create_file(&pci_dev->dev, &dev_attr_pcrs); | ||
653 | device_create_file(&pci_dev->dev, &dev_attr_caps); | ||
654 | 665 | ||
655 | return 0; | 666 | return 0; |
656 | } | 667 | } |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 3a5af7e06624..a3ff4dc5bdb3 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -35,6 +35,14 @@ enum tpm_addr { | |||
35 | TPM_DATA = 0x4F | 35 | TPM_DATA = 0x4F |
36 | }; | 36 | }; |
37 | 37 | ||
38 | extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr, | ||
39 | char *); | ||
40 | extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr, | ||
41 | char *); | ||
42 | extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr, | ||
43 | char *); | ||
44 | extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr, | ||
45 | const char *, size_t); | ||
38 | 46 | ||
39 | struct tpm_chip; | 47 | struct tpm_chip; |
40 | 48 | ||
@@ -47,6 +55,7 @@ struct tpm_vendor_specific { | |||
47 | int (*send) (struct tpm_chip *, u8 *, size_t); | 55 | int (*send) (struct tpm_chip *, u8 *, size_t); |
48 | void (*cancel) (struct tpm_chip *); | 56 | void (*cancel) (struct tpm_chip *); |
49 | struct miscdevice miscdev; | 57 | struct miscdevice miscdev; |
58 | struct attribute_group *attr_group; | ||
50 | }; | 59 | }; |
51 | 60 | ||
52 | struct tpm_chip { | 61 | struct tpm_chip { |
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index 3271391892e8..07abfb7143b1 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -126,6 +126,21 @@ static struct file_operations atmel_ops = { | |||
126 | .release = tpm_release, | 126 | .release = tpm_release, |
127 | }; | 127 | }; |
128 | 128 | ||
129 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | ||
130 | static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); | ||
131 | static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL); | ||
132 | static DEVICE_ATTR(cancel, S_IWUSR |S_IWGRP, NULL, tpm_store_cancel); | ||
133 | |||
134 | static struct attribute* atmel_attrs[] = { | ||
135 | &dev_attr_pubek.attr, | ||
136 | &dev_attr_pcrs.attr, | ||
137 | &dev_attr_caps.attr, | ||
138 | &dev_attr_cancel.attr, | ||
139 | 0, | ||
140 | }; | ||
141 | |||
142 | static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs }; | ||
143 | |||
129 | static struct tpm_vendor_specific tpm_atmel = { | 144 | static struct tpm_vendor_specific tpm_atmel = { |
130 | .recv = tpm_atml_recv, | 145 | .recv = tpm_atml_recv, |
131 | .send = tpm_atml_send, | 146 | .send = tpm_atml_send, |
@@ -133,6 +148,7 @@ static struct tpm_vendor_specific tpm_atmel = { | |||
133 | .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL, | 148 | .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL, |
134 | .req_complete_val = ATML_STATUS_DATA_AVAIL, | 149 | .req_complete_val = ATML_STATUS_DATA_AVAIL, |
135 | .base = TPM_ATML_BASE, | 150 | .base = TPM_ATML_BASE, |
151 | .attr_group = &atmel_attr_grp, | ||
136 | .miscdev = { .fops = &atmel_ops, }, | 152 | .miscdev = { .fops = &atmel_ops, }, |
137 | }; | 153 | }; |
138 | 154 | ||
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 24832abe0b2d..675290169508 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
@@ -224,6 +224,21 @@ static struct file_operations nsc_ops = { | |||
224 | .release = tpm_release, | 224 | .release = tpm_release, |
225 | }; | 225 | }; |
226 | 226 | ||
227 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | ||
228 | static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); | ||
229 | static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL); | ||
230 | static DEVICE_ATTR(cancel, S_IWUSR|S_IWGRP, NULL, tpm_store_cancel); | ||
231 | |||
232 | static struct attribute * nsc_attrs[] = { | ||
233 | &dev_attr_pubek.attr, | ||
234 | &dev_attr_pcrs.attr, | ||
235 | &dev_attr_caps.attr, | ||
236 | &dev_attr_cancel.attr, | ||
237 | 0, | ||
238 | }; | ||
239 | |||
240 | static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs }; | ||
241 | |||
227 | static struct tpm_vendor_specific tpm_nsc = { | 242 | static struct tpm_vendor_specific tpm_nsc = { |
228 | .recv = tpm_nsc_recv, | 243 | .recv = tpm_nsc_recv, |
229 | .send = tpm_nsc_send, | 244 | .send = tpm_nsc_send, |
@@ -231,8 +246,8 @@ static struct tpm_vendor_specific tpm_nsc = { | |||
231 | .req_complete_mask = NSC_STATUS_OBF, | 246 | .req_complete_mask = NSC_STATUS_OBF, |
232 | .req_complete_val = NSC_STATUS_OBF, | 247 | .req_complete_val = NSC_STATUS_OBF, |
233 | .base = TPM_NSC_BASE, | 248 | .base = TPM_NSC_BASE, |
249 | .attr_group = &nsc_attr_grp, | ||
234 | .miscdev = { .fops = &nsc_ops, }, | 250 | .miscdev = { .fops = &nsc_ops, }, |
235 | |||
236 | }; | 251 | }; |
237 | 252 | ||
238 | static int __devinit tpm_nsc_init(struct pci_dev *pci_dev, | 253 | static int __devinit tpm_nsc_init(struct pci_dev *pci_dev, |