From: Corey Minyard <cminyard@mvista.com>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: Andrew Morton <akpm@osdl.org>,
lkml <linux-kernel@vger.kernel.org>, Greg KH <greg@kroah.com>
Subject: Re: sysfs for IPMI, for new mm kernels
Date: Thu, 31 Mar 2005 22:23:17 -0600 [thread overview]
Message-ID: <424CCCB5.3030200@mvista.com> (raw)
In-Reply-To: <200503312243.02139.dtor_core@ameritech.net>
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
Dmitry Torokhov wrote:
>On Thursday 31 March 2005 22:02, Corey Minyard wrote:
>
>
>>+ snprintf(name, sizeof(name), "ipmi%d", if_num);
>>+ class_device_create(ipmi_class, dev, NULL, name);
>>
>>
>>
>
>class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num) ?
>
>
>
Yes, much better. Let's try again...
-Corey
[-- Attachment #2: ipmi-sysfs.diff --]
[-- Type: text/x-patch, Size: 2040 bytes --]
Add support for sysfs to the IPMI device interface.
Signed-off-by: Corey Minyard <minyard@acm.org>
Index: linux-2.6.12-rc1/drivers/char/ipmi/ipmi_devintf.c
===================================================================
--- linux-2.6.12-rc1.orig/drivers/char/ipmi/ipmi_devintf.c
+++ linux-2.6.12-rc1/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,21 @@
" interface. Other values will set the major device number"
" to that value.");
+static struct class *ipmi_class;
+
static void ipmi_new_smi(int if_num)
{
- devfs_mk_cdev(MKDEV(ipmi_major, if_num),
- S_IFCHR | S_IRUSR | S_IWUSR,
+ dev_t dev = MKDEV(ipmi_major, if_num);
+
+ devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
"ipmidev/%d", if_num);
+
+ class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num);
}
static void ipmi_smi_gone(int if_num)
{
+ class_device_destroy(ipmi_class, MKDEV(ipmi_major, if_num));
devfs_remove("ipmidev/%d", if_num);
}
@@ -548,8 +555,15 @@
printk(KERN_INFO "ipmi device interface version "
IPMI_DEVINTF_VERSION "\n");
+ ipmi_class = class_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_destroy(ipmi_class);
printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
return rv;
}
@@ -563,6 +577,7 @@
rv = ipmi_smi_watcher_register(&smi_watcher);
if (rv) {
unregister_chrdev(ipmi_major, DEVICE_NAME);
+ class_destroy(ipmi_class);
printk(KERN_WARNING "ipmi: can't register smi watcher\n");
return rv;
}
@@ -573,6 +588,7 @@
static __exit void cleanup_ipmi(void)
{
+ class_destroy(ipmi_class);
ipmi_smi_watcher_unregister(&smi_watcher);
devfs_remove(DEVICE_NAME);
unregister_chrdev(ipmi_major, DEVICE_NAME);
prev parent reply other threads:[~2005-04-01 4:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-01 3:02 sysfs for IPMI, for new mm kernels Corey Minyard
2005-04-01 3:43 ` Dmitry Torokhov
2005-04-01 4:23 ` Corey Minyard [this message]
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=424CCCB5.3030200@mvista.com \
--to=cminyard@mvista.com \
--cc=akpm@osdl.org \
--cc=dtor_core@ameritech.net \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.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