Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262611AbVDAEXh (ORCPT ); Thu, 31 Mar 2005 23:23:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262621AbVDAEXh (ORCPT ); Thu, 31 Mar 2005 23:23:37 -0500 Received: from gateway-1237.mvista.com ([12.44.186.158]:4852 "EHLO av.mvista.com") by vger.kernel.org with ESMTP id S262611AbVDAEXZ (ORCPT ); Thu, 31 Mar 2005 23:23:25 -0500 Message-ID: <424CCCB5.3030200@mvista.com> Date: Thu, 31 Mar 2005 22:23:17 -0600 From: Corey Minyard User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.2) Gecko/20040804 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dmitry Torokhov CC: Andrew Morton , lkml , Greg KH Subject: Re: sysfs for IPMI, for new mm kernels References: <424CB9DA.1040707@mvista.com> <200503312243.02139.dtor_core@ameritech.net> In-Reply-To: <200503312243.02139.dtor_core@ameritech.net> Content-Type: multipart/mixed; boundary="------------040009030206000903060008" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3017 Lines: 111 This is a multi-part message in MIME format. --------------040009030206000903060008 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------040009030206000903060008 Content-Type: text/x-patch; name="ipmi-sysfs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ipmi-sysfs.diff" Add support for sysfs to the IPMI device interface. Signed-off-by: Corey Minyard 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 #include #include +#include #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); --------------040009030206000903060008-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/