diff options
author | Corey Minyard <minyard@acm.org> | 2005-05-20 02:56:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-20 10:58:04 -0400 |
commit | 37e0915b701281182cea9fc90e894d10addf134a (patch) | |
tree | e327b635e017dfcfd989b203c16ebd55e1d2526b /drivers | |
parent | 45fed46f5b98aaf439e9ef125992ec853cd98499 (diff) |
[PATCH] Add sysfs support for the IPMI device interface
Add support for sysfs to the IPMI device interface.
Clean-ups based on Dimitry Torokovs comment by Philipp Hahn.
Signed-off-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Philipp Hahn <pmhahn@titan.lahn.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/ipmi/ipmi_devintf.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index 49d67f5384a2..4bb9af736fba 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/ipmi.h> | 44 | #include <linux/ipmi.h> |
45 | #include <asm/semaphore.h> | 45 | #include <asm/semaphore.h> |
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/device.h> | ||
47 | 48 | ||
48 | #define IPMI_DEVINTF_VERSION "v33" | 49 | #define IPMI_DEVINTF_VERSION "v33" |
49 | 50 | ||
@@ -519,15 +520,21 @@ MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device. By" | |||
519 | " interface. Other values will set the major device number" | 520 | " interface. Other values will set the major device number" |
520 | " to that value."); | 521 | " to that value."); |
521 | 522 | ||
523 | static struct class *ipmi_class; | ||
524 | |||
522 | static void ipmi_new_smi(int if_num) | 525 | static void ipmi_new_smi(int if_num) |
523 | { | 526 | { |
524 | devfs_mk_cdev(MKDEV(ipmi_major, if_num), | 527 | dev_t dev = MKDEV(ipmi_major, if_num); |
525 | S_IFCHR | S_IRUSR | S_IWUSR, | 528 | |
529 | devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, | ||
526 | "ipmidev/%d", if_num); | 530 | "ipmidev/%d", if_num); |
531 | |||
532 | class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num); | ||
527 | } | 533 | } |
528 | 534 | ||
529 | static void ipmi_smi_gone(int if_num) | 535 | static void ipmi_smi_gone(int if_num) |
530 | { | 536 | { |
537 | class_simple_device_remove(ipmi_class, MKDEV(ipmi_major, if_num)); | ||
531 | devfs_remove("ipmidev/%d", if_num); | 538 | devfs_remove("ipmidev/%d", if_num); |
532 | } | 539 | } |
533 | 540 | ||
@@ -548,8 +555,15 @@ static __init int init_ipmi_devintf(void) | |||
548 | printk(KERN_INFO "ipmi device interface version " | 555 | printk(KERN_INFO "ipmi device interface version " |
549 | IPMI_DEVINTF_VERSION "\n"); | 556 | IPMI_DEVINTF_VERSION "\n"); |
550 | 557 | ||
558 | ipmi_class = class_simple_create(THIS_MODULE, "ipmi"); | ||
559 | if (IS_ERR(ipmi_class)) { | ||
560 | printk(KERN_ERR "ipmi: can't register device class\n"); | ||
561 | return PTR_ERR(ipmi_class); | ||
562 | } | ||
563 | |||
551 | rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); | 564 | rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); |
552 | if (rv < 0) { | 565 | if (rv < 0) { |
566 | class_simple_destroy(ipmi_class); | ||
553 | printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major); | 567 | printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major); |
554 | return rv; | 568 | return rv; |
555 | } | 569 | } |
@@ -563,6 +577,7 @@ static __init int init_ipmi_devintf(void) | |||
563 | rv = ipmi_smi_watcher_register(&smi_watcher); | 577 | rv = ipmi_smi_watcher_register(&smi_watcher); |
564 | if (rv) { | 578 | if (rv) { |
565 | unregister_chrdev(ipmi_major, DEVICE_NAME); | 579 | unregister_chrdev(ipmi_major, DEVICE_NAME); |
580 | class_simple_destroy(ipmi_class); | ||
566 | printk(KERN_WARNING "ipmi: can't register smi watcher\n"); | 581 | printk(KERN_WARNING "ipmi: can't register smi watcher\n"); |
567 | return rv; | 582 | return rv; |
568 | } | 583 | } |
@@ -573,6 +588,7 @@ module_init(init_ipmi_devintf); | |||
573 | 588 | ||
574 | static __exit void cleanup_ipmi(void) | 589 | static __exit void cleanup_ipmi(void) |
575 | { | 590 | { |
591 | class_simple_destroy(ipmi_class); | ||
576 | ipmi_smi_watcher_unregister(&smi_watcher); | 592 | ipmi_smi_watcher_unregister(&smi_watcher); |
577 | devfs_remove(DEVICE_NAME); | 593 | devfs_remove(DEVICE_NAME); |
578 | unregister_chrdev(ipmi_major, DEVICE_NAME); | 594 | unregister_chrdev(ipmi_major, DEVICE_NAME); |