diff options
author | Kylene Hall <kjhall@us.ibm.com> | 2005-06-24 01:02:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:05:26 -0400 |
commit | 6659ca2ab6730c3bbb9fa495f2327b95b955decd (patch) | |
tree | 1b8a9a09a830b0a5233c6e9f073c53260dbef819 /drivers/char/tpm/tpm.c | |
parent | 81179bb6a54c2c626b4cbcc084ca974bb2d7f2a3 (diff) |
[PATCH] tpm: sysfs owernship changes
In the current driver all sysfs files end up owned by the base driver module
rather than the module that actually owns the device this is a problem if the
module is unloaded and the file is open. This patch fixes all that and lumps
the files into an attribute_group.
Signed-off-by: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: Yani Ioannou <yani.ioannou@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r-- | drivers/char/tpm/tpm.c | 35 |
1 files changed, 23 insertions, 12 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 | } |