public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: Linus Torvalds <torvalds@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] Add sysfs support for the IPMI device interface
Date: Thu, 19 May 2005 18:26:04 -0500	[thread overview]
Message-ID: <428D208C.1000307@acm.org> (raw)

Linus,

Could you please add this patch to the main tree?  I can't send it to 
Andrew because he has a rework of this in his tree that has not made it 
into yours yet, and I'd like to have this in before 2.6.12 is released.

-Corey


Add support for sysfs to the IPMI device interface.

Signed-off-by: Corey Minyard <minyard@acm.org>

Index: linux-2.6.11-mm1/drivers/char/ipmi/ipmi_devintf.c
===================================================================
--- linux-2.6.11-mm1.orig/drivers/char/ipmi/ipmi_devintf.c
+++ linux-2.6.11-mm1/drivers/char/ipmi/ipmi_devintf.c
@@ -44,6 +44,7 @@
 #include <linux/ipmi.h>
 #include <asm/semaphore.h>
 #include <linux/init.h>
+#include <linux/device.h>
 
 #define IPMI_DEVINTF_VERSION "v33"
 
@@ -519,15 +520,24 @@
          " interface.  Other values will set the major device number"
          " to that value.");
 
+static struct class_simple *ipmi_class;
+
 static void ipmi_new_smi(int if_num)
 {
+    char                  name[10];
+    dev_t                 dev = MKDEV(ipmi_major, if_num);
+
     devfs_mk_cdev(MKDEV(ipmi_major, if_num),
               S_IFCHR | S_IRUSR | S_IWUSR,
               "ipmidev/%d", if_num);
+
+    snprintf(name, sizeof(name), "ipmi%d", if_num);
+    class_simple_device_add(ipmi_class, dev, NULL, name);
 }
 
 static void ipmi_smi_gone(int if_num)
 {
+    class_simple_device_remove(MKDEV(ipmi_major, if_num));
     devfs_remove("ipmidev/%d", if_num);
 }
 
@@ -548,8 +558,15 @@
     printk(KERN_INFO "ipmi device interface version "
            IPMI_DEVINTF_VERSION "\n");
 
+    ipmi_class = class_simple_create(THIS_MODULE, "ipmi");
+    if (IS_ERR(ipmi_class)) {
+        printk(KERN_ERR "ipmi: can't register device class\n");
+        return PTR_ERR(ipmi_class);
+    }
+
     rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
     if (rv < 0) {
+        class_simple_destroy(ipmi_class);
         printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
         return rv;
     }
@@ -563,6 +580,7 @@
     rv = ipmi_smi_watcher_register(&smi_watcher);
     if (rv) {
         unregister_chrdev(ipmi_major, DEVICE_NAME);
+        class_simple_destroy(ipmi_class);
         printk(KERN_WARNING "ipmi: can't register smi watcher\n");
         return rv;
     }
@@ -573,6 +591,7 @@
 
 static __exit void cleanup_ipmi(void)
 {
+    class_simple_destroy(ipmi_class);
     ipmi_smi_watcher_unregister(&smi_watcher);
     devfs_remove(DEVICE_NAME);
     unregister_chrdev(ipmi_major, DEVICE_NAME);


             reply	other threads:[~2005-05-19 23:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-19 23:26 Corey Minyard [this message]
2005-05-20  5:15 ` [PATCH] Add sysfs support for the IPMI device interface Greg KH
2005-05-20  6:56 ` Philipp Matthias Hahn
2005-05-20 13:00   ` Corey Minyard
2005-05-22  3:20     ` AsterixTheGaul
2005-05-22  3:23       ` AsterixTheGaul
     [not found] <200505201511.j4KFBgHG002490@hera.kernel.org>
2005-05-22  6:57 ` Dave Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=428D208C.1000307@acm.org \
    --to=minyard@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox