Skip to contentSkip to conversation

IPMI: driver model and sysfs support

PATCH In review Yani Ioannou 2 participants 4 messages Aug 30, 2005 – Nov 26, 2005 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IPMI: driver model and sysfs support

Hi Corey,

Here is a patch against 2.6.13 I've been working on (and mentioned to you at OLS), that adds support for the 2.6 driver model, and sysfs to the ipmi subsystem. It is loosely inspired by the USB driver model system. There is a driver struct added for the ipmi_msghandler, and one for each system interface 'driver' (for each state machine in ipmi_si). A device struct is created for each system interface in the system, and for each unique BMC on the system, with a symlink between each system interface and the bmc it interfaces to. Each bmc has a set of fundamental device attributes, and each of the drivers has a version attribute reflecting the driver/state machine versions. Furthermore each of these devices is registered as a class_device with the ipmi class (moved to ipmi_msghandler) as bmcx and smix.

This in effect creates the following sysfs interface on a machine with a single BMC and two interfaces:

/sys/

|-- block
|-- bus
|   |-- platform
|   |   |-- devices
|   |   |   |-- ipmi_bmc.0 -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- ipmi_si.0 -> ../../../devices/platform/ipmi_si.0
|   |   |   |-- ipmi_si.1 -> ../../../devices/platform/ipmi_si.1
|   |   `-- drivers
|   |       |-- ipmi_bt_sm
|   |       |   |-- bind
|   |       |   |-- ipmi_si.1 -> ../../../../devices/platform/ipmi_si.1
|   |       |   |-- unbind
|   |       |   `-- version
|   |       |-- ipmi_kcs_sm
|   |       |   |-- bind
|   |       |   |-- ipmi_si.0 -> ../../../../devices/platform/ipmi_si.0
|   |       |   |-- unbind
|   |       |   `-- version
|   |       |-- ipmi_msghandler
|   |       |   |-- bind
|   |       |   |-- ipmi_bmc.0 -> ../../../../devices/platform/ipmi_bmc.0
|   |       |   |-- unbind
|   |       |   `-- version
|-- class
|   |-- ipmi
|   |   |-- bmc0
|   |   |   `-- device -> ../../../devices/platform/ipmi_bmc.0
|   |   |-- ipmi0
|   |   |   `-- dev
|   |   |-- ipmi1
|   |   |   `-- dev
|   |   |-- smi0
|   |   |   `-- device -> ../../../devices/platform/ipmi_si.0
|   |   `-- smi1
|   |       `-- device -> ../../../devices/platform/ipmi_si.1
|-- devices
|   |-- platform
|   |   |-- ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- device_id
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_msghandler
|   |   |   |-- firmware_revision
|   |   |   |-- ipmi_version
|   |   |   |-- power
|   |   |   |   `-- state
|   |   |   |-- product_id
|   |   |   `-- revision
|   |   |-- ipmi_si.0
|   |   |   |-- bmc -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_kcs_sm
|   |   |   `-- power
|   |   |       `-- state
|   |   |-- ipmi_si.1
|   |   |   |-- bmc -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_bt_sm
|   |   |   `-- power
|   |   |       `-- state
|-- kernel
|-- module
|   |-- ipmi_devintf
|   |   |-- refcnt
|   |   `-- sections
|   |       `-- __param
|   |-- ipmi_msghandler
|   |   |-- refcnt
|   |   `-- sections
|   |       |-- __ksymtab
|   |       `-- __ksymtab_strings
|   |-- ipmi_si
|   |   |-- refcnt
|   |   `-- sections
|   |       `-- __param

`-- power

My motiviation for the patch is to have a device struct (bmc) to register with the new hwmon class for my in-progress hwmon driver ipmi_sensors. With this patch the driver can create device attributes under bmc devices representing sensor readings for the hwmon/lm_sensors interface.

I have tested the patch on two systems of mine with a single bmc, it should however also work for a machine with multiple bmcs using the guid/product+device id to differentiate.

Thanks,
Yani

---

 drivers/char/ipmi/ipmi_bt_sm.c      |   28 +++
 drivers/char/ipmi/ipmi_devintf.c    |   11 -
 drivers/char/ipmi/ipmi_kcs_sm.c     |   28 +++
 drivers/char/ipmi/ipmi_msghandler.c |  323 +++++++++++++++++++++++++++++++++++-
 drivers/char/ipmi/ipmi_si_intf.c    |  229 ++++++++++++++++++++++---
 drivers/char/ipmi/ipmi_si_sm.h      |    9 -
 drivers/char/ipmi/ipmi_smic_sm.c    |   29 +++
 include/linux/ipmi.h                |  108 ++++++++++++
 include/linux/ipmi_msgdefs.h        |    1 
 include/linux/ipmi_smi.h            |    1 
 10 files changed, 722 insertions(+), 45 deletions(-)
drivers/char/ipmi/ipmi_bt_sm.c +27 -1
@@ -28,6 +28,7 @@
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
 #include "ipmi_si_sm.h"
 
@@ -103,6 +104,31 @@ struct si_sm_data {
 #define BT_INTMASK_R	bt->io->inputb(bt->io, 2)
 #define BT_INTMASK_W(x)	bt->io->outputb(bt->io, 2, x)
 
+static ssize_t bt_driver_show_version(struct device_driver *drv, char *buf){
+	struct ipmi_si_driver *driver = to_ipmi_si_driver(drv);
+	return snprintf(buf, 10, "%s\n", driver->version);
+}
+
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver bt_si_driver = {
+	.owner = THIS_MODULE,
+	.version = IPMI_BT_VERSION,
+	.driver = {
+		.name = "ipmi_bt_sm",
+		.bus = &platform_bus_type
+	},
+	.version_attr = {
+		.attr = {
+			.name = "version",
+			.owner = THIS_MODULE,
+			.mode = S_IRUGO,
+		},
+		.show = bt_driver_show_version,
+	},
+};
+
 /* Convenience routines for debugging.  These are not multi-open safe!
    Note the macros have hardcoded variables in them. */
 
@@ -501,7 +527,7 @@ static int bt_size(void)
 
 struct si_sm_handlers bt_smi_handlers =
 {
-	.version           = IPMI_BT_VERSION,
+	.driver            = &bt_si_driver,
 	.init_data         = bt_init_data,
 	.start_transaction = bt_start_transaction,
 	.get_result        = bt_get_result,
drivers/char/ipmi/ipmi_devintf.c +1 -10
@@ -716,7 +716,7 @@ MODULE_PARM_DESC(ipmi_major, "Sets the m
 		 " interface.  Other values will set the major device number"
 		 " to that value.");
 
-static struct class *ipmi_class;
+extern struct class *ipmi_class;
 
 static void ipmi_new_smi(int if_num)
 {
@@ -751,15 +751,8 @@ static __init int init_ipmi_devintf(void
 	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;
 	}
@@ -773,7 +766,6 @@ static __init int init_ipmi_devintf(void
 	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;
 	}
@@ -784,7 +776,6 @@ module_init(init_ipmi_devintf);
 
 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);
drivers/char/ipmi/ipmi_kcs_sm.c +27 -1
@@ -39,6 +39,7 @@
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
 #include "ipmi_si_sm.h"
 
@@ -111,6 +112,31 @@ struct si_sm_data
 	long          obf_timeout;
 };
 
+static ssize_t kcs_driver_show_version(struct device_driver *drv, char *buf){
+	struct ipmi_si_driver *driver = to_ipmi_si_driver(drv);
+	return snprintf(buf, 10, "%s\n", driver->version);
+}
+
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver kcs_si_driver = {
+	.owner = THIS_MODULE,
+	.version = IPMI_KCS_VERSION,
+	.driver = {
+		.name = "ipmi_kcs_sm",
+		.bus = &platform_bus_type
+	},
+	.version_attr = {
+		.attr = {
+			.name = "version",
+			.owner = THIS_MODULE,
+			.mode = S_IRUGO,
+		},
+		.show = kcs_driver_show_version,
+	},
+};
+
 static unsigned int init_kcs_data(struct si_sm_data *kcs,
 				  struct si_sm_io *io)
 {
@@ -489,7 +515,7 @@ static void kcs_cleanup(struct si_sm_dat
 
 struct si_sm_handlers kcs_smi_handlers =
 {
-	.version           = IPMI_KCS_VERSION,
+	.driver            = &kcs_si_driver,
 	.init_data         = init_kcs_data,
 	.start_transaction = start_kcs_transaction,
 	.get_result        = get_kcs_result,
drivers/char/ipmi/ipmi_msghandler.c +321 -2

359 lines not on this page · raw message

drivers/char/ipmi/ipmi_si_intf.c +202 -27

356 lines not on this page · raw message

drivers/char/ipmi/ipmi_si_sm.h +6 -3
@@ -34,6 +34,8 @@
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/ipmi.h>
+
 /* This is defined by the state machines themselves, it is an opaque
    data type for them to use. */
 struct si_sm_data;
@@ -72,9 +74,10 @@ enum si_sm_result
 /* Handlers for the SMI state machine. */
 struct si_sm_handlers
 {
-	/* Put the version number of the state machine here so the
-           upper layer can print it. */
-	char *version;
+	/* The driver model view of the system interface state machine so it can be
+	   registered/unregistered, also access to the version number so the upper
+	   layer can print it. */
+	struct ipmi_si_driver *driver;
 
 	/* Initialize the data and return the amount of I/O space to
            reserve for the space. */
drivers/char/ipmi/ipmi_smic_sm.c +28 -1
@@ -43,6 +43,7 @@
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
 #include "ipmi_si_sm.h"
 
@@ -111,6 +112,32 @@ struct si_sm_data
         long		 smic_timeout;
 };
 
+static ssize_t smic_driver_show_version(struct device_driver *drv, char *buf){
+	struct ipmi_si_driver *driver = to_ipmi_si_driver(drv);
+	return snprintf(buf, 10, "%s\n", driver->version);
+}
+
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver smic_si_driver = {
+	.owner = THIS_MODULE,
+	.version = IPMI_SMIC_VERSION,
+	.driver = {
+		.name = "ipmi_smic_sm",
+		.bus = &platform_bus_type
+	},
+	.version_attr = {
+		.attr = {
+			.name = "version",
+			.owner = THIS_MODULE,
+			.mode = S_IRUGO,
+		},
+		.show = smic_driver_show_version,
+	},
+
+};
+
 static unsigned int init_smic_data (struct si_sm_data *smic,
 				    struct si_sm_io *io)
 {
@@ -588,7 +615,7 @@ static int smic_size(void)
 
 struct si_sm_handlers smic_smi_handlers =
 {
-	.version           = IPMI_SMIC_VERSION,
+	.driver            = &smic_si_driver,
 	.init_data         = init_smic_data,
 	.start_transaction = start_smic_transaction,
 	.get_result        = smic_get_result,
include/linux/ipmi.h +108 -0

124 lines not on this page · raw message

include/linux/ipmi_msgdefs.h +1 -0
@@ -45,6 +45,7 @@
 
 #define IPMI_NETFN_APP_REQUEST			0x06
 #define IPMI_NETFN_APP_RESPONSE			0x07
+#define IPMI_GET_DEVICE_GUID_CMD           0x08
 #define IPMI_GET_DEVICE_ID_CMD		0x01
 #define IPMI_CLEAR_MSG_FLAGS_CMD	0x30
 #define IPMI_GET_MSG_FLAGS_CMD		0x31
include/linux/ipmi_smi.h +1 -0
@@ -43,6 +43,7 @@
 
 /* Structure for the low-level drivers. */
 typedef struct ipmi_smi *ipmi_smi_t;
+typedef struct smi_info *smi_info_t;
 
 /*
  * Messages to/from the lower layer.  The smi interface will take one
#1 lore raw

This is very good. I believe the structure is correct, but I'm not a sysfs expert.

There are a few things we need to deal with, though.

* There are some significant changes to versioning in the driver that are in the mm tree right now (you can pull them from

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.13-rc6/2.6.13-rc6-mm2/broken-out)

* There are some coding style problems. You have places like:
+static void ipmi_bmc_unregister(struct ipmi_si_device *si,
+ struct ipmi_bmc_device *bmc){
The '{' for functions and structures needs to be on it's own line. Also, several:
+ if(bmc->guid_present){
that need spaces after the 'if' and before the '{'.
The patch also adds some trailing spaces to empty lines, the following is a telltale sign:
-
+
There was also one place where you added unneeded braces to a single statement and another where you deleted the empty line between two functions.
These are all standard kernel coding style rules.

* I'd prefer to store the product id, device id, and manufacturer id decoded. This makes it easier to handle (no need to use "memcmp" to compare) and print. The printing of the product id, for instance, will be rather unnatural in product_id_show().

* guids are not printable strings (see guid_show()).

* The printing of the guid in ipmi_bmc_register is, well, kind of ugly. It should probably be moved to its own function that lets you pass in the rest of the string.

-Corey

Quoted 109 lines · Yani Ioannou

Hi Corey,

Here is a patch against 2.6.13 I've been working on (and mentioned to you at OLS), that adds support for the 2.6 driver model, and sysfs to the ipmi subsystem. It is loosely inspired by the USB driver model system. There is a driver struct added for the ipmi_msghandler, and one for each system interface 'driver' (for each state machine in ipmi_si). A device struct is created for each system interface in the system, and for each unique BMC on the system, with a symlink between each system interface and the bmc it interfaces to. Each bmc has a set of fundamental device attributes, and each of the drivers has a version attribute reflecting the driver/state machine versions. Furthermore each of these devices is registered as a class_device with the ipmi class (moved to ipmi_msghandler) as bmcx and smix.

This in effect creates the following sysfs interface on a machine with a single BMC and two interfaces:

/sys/

|-- block
|-- bus
|   |-- platform
|   |   |-- devices
|   |   |   |-- ipmi_bmc.0 -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- ipmi_si.0 -> ../../../devices/platform/ipmi_si.0
|   |   |   |-- ipmi_si.1 -> ../../../devices/platform/ipmi_si.1
|   |   `-- drivers
|   |       |-- ipmi_bt_sm
|   |       |   |-- bind
|   |       |   |-- ipmi_si.1 -> ../../../../devices/platform/ipmi_si.1
|   |       |   |-- unbind
|   |       |   `-- version
|   |       |-- ipmi_kcs_sm
|   |       |   |-- bind
|   |       |   |-- ipmi_si.0 -> ../../../../devices/platform/ipmi_si.0
|   |       |   |-- unbind
|   |       |   `-- version
|   |       |-- ipmi_msghandler
|   |       |   |-- bind
|   |       |   |-- ipmi_bmc.0 -> ../../../../devices/platform/ipmi_bmc.0
|   |       |   |-- unbind
|   |       |   `-- version
|-- class
|   |-- ipmi
|   |   |-- bmc0
|   |   |   `-- device -> ../../../devices/platform/ipmi_bmc.0
|   |   |-- ipmi0
|   |   |   `-- dev
|   |   |-- ipmi1
|   |   |   `-- dev
|   |   |-- smi0
|   |   |   `-- device -> ../../../devices/platform/ipmi_si.0
|   |   `-- smi1
|   |       `-- device -> ../../../devices/platform/ipmi_si.1
|-- devices
|   |-- platform
|   |   |-- ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- device_id
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_msghandler
|   |   |   |-- firmware_revision
|   |   |   |-- ipmi_version
|   |   |   |-- power
|   |   |   |   `-- state
|   |   |   |-- product_id
|   |   |   `-- revision
|   |   |-- ipmi_si.0
|   |   |   |-- bmc -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_kcs_sm
|   |   |   `-- power
|   |   |       `-- state
|   |   |-- ipmi_si.1
|   |   |   |-- bmc -> ../../../devices/platform/ipmi_bmc.0
|   |   |   |-- bus -> ../../../bus/platform
|   |   |   |-- driver -> ../../../bus/platform/drivers/ipmi_bt_sm
|   |   |   `-- power
|   |   |       `-- state
|-- kernel
|-- module
|   |-- ipmi_devintf
|   |   |-- refcnt
|   |   `-- sections
|   |       `-- __param
|   |-- ipmi_msghandler
|   |   |-- refcnt
|   |   `-- sections
|   |       |-- __ksymtab
|   |       `-- __ksymtab_strings
|   |-- ipmi_si
|   |   |-- refcnt
|   |   `-- sections
|   |       `-- __param

`-- power

My motiviation for the patch is to have a device struct (bmc) to register with the new hwmon class for my in-progress hwmon driver ipmi_sensors. With this patch the driver can create device attributes under bmc devices representing sensor readings for the hwmon/lm_sensors interface.

I have tested the patch on two systems of mine with a single bmc, it should however also work for a machine with multiple bmcs using the guid/product+device id to differentiate.

Thanks,
Yani

#2 lore raw
Quoted 9 lines · Corey Minyard

This is very good. I believe the structure is correct, but I'm not a sysfs expert.

There are a few things we need to deal with, though.

* There are some significant changes to versioning in the driver that are in the mm tree right now (you can pull them from

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.13-rc6/2.6.13-rc6-mm2/broken-out)

Gah, ok :), I'll try to apply with the -mm changes.

Quoted 7 lines

* There are some coding style problems. You have places like:
+static void ipmi_bmc_unregister(struct ipmi_si_device *si,
+ struct ipmi_bmc_device *bmc){
The '{' for functions and structures needs to be on it's own line. Also, several:
+ if(bmc->guid_present){
that need spaces after the 'if' and before the '{'.

Quoted 8 lines

The patch also adds some trailing spaces to empty lines, the following is a telltale sign:
-
+
There was also one place where you added unneeded braces to a single statement and another where you deleted the empty line between two functions.
These are all standard kernel coding style rules.

Yes, I should have caught those, thanks.

Quoted 4 lines

* I'd prefer to store the product id, device id, and manufacturer id decoded. This makes it easier to handle (no need to use "memcmp" to compare) and print. The printing of the product id, for instance, will be rather unnatural in product_id_show().

I was under the impression that they were just OEM strings, and not necessarily ASCII strings? I'll have a look at the specs again.

Quoted 1 line

* guids are not printable strings (see guid_show()).

guid_show, sounds useful!

Thanks,
Yani

#3 lore raw

Hi Corey,

Quoted 5 lines · Yani Ioannou
Quoted 4 lines · Corey Minyard

This is very good. I believe the structure is correct, but I'm not a sysfs expert.

There are a few things we need to deal with, though.

<snip>

Sorry it has been quite a while .. anyway I finally got around to updating the patch with the changes you proposed, and attached is a patch against the latest git (2.6.15-rc2-git6).

Thanks,
Yani

---

 drivers/char/ipmi/ipmi_bt_sm.c      |   13 +
 drivers/char/ipmi/ipmi_devintf.c    |   11 -
 drivers/char/ipmi/ipmi_kcs_sm.c     |   13 +
 drivers/char/ipmi/ipmi_msghandler.c |  374 +++++++++++++++++++++++++++++++++++
 drivers/char/ipmi/ipmi_si_intf.c    |  200 ++++++++++++++++---
 drivers/char/ipmi/ipmi_si_sm.h      |    9 +
 drivers/char/ipmi/ipmi_smic_sm.c    |   13 +
 include/linux/ipmi.h                |  127 ++++++++++++
 include/linux/ipmi_msgdefs.h        |    1 
 include/linux/ipmi_smi.h            |    1 
 10 files changed, 723 insertions(+), 39 deletions(-)

applies-to: 1f3b06d516dac26c976cedfc59cd48781b96f86d 93ace52e69e5cc5258abb14a8c6c8786ca7d209b

drivers/char/ipmi/ipmi_bt_sm.c +13 -0
index 58dcdee..648ab0b 100644
@@ -28,6 +28,7 @@
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
@@ -105,6 +106,17 @@ struct si_sm_data {
 #define BT_INTMASK_R	bt->io->inputb(bt->io, 2)
 #define BT_INTMASK_W(x)	bt->io->outputb(bt->io, 2, x)
 
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver bt_si_driver = {
+	.owner = THIS_MODULE,
+	.driver = {
+		.name = "ipmi_bt_sm",
+		.bus = &platform_bus_type
+	},
+};
+
 /* Convenience routines for debugging.  These are not multi-open safe!
    Note the macros have hardcoded variables in them. */
 
@@ -513,6 +525,7 @@ static int bt_size(void)
 
 struct si_sm_handlers bt_smi_handlers =
 {
+	.driver            = &bt_si_driver,
 	.init_data         = bt_init_data,
 	.start_transaction = bt_start_transaction,
 	.get_result        = bt_get_result,
drivers/char/ipmi/ipmi_devintf.c +1 -10
index 7c0684d..c0e3cc5 100644
@@ -789,7 +789,7 @@ MODULE_PARM_DESC(ipmi_major, "Sets the m
 		 " interface.  Other values will set the major device number"
 		 " to that value.");
 
-static struct class *ipmi_class;
+extern struct class *ipmi_class;
 
 static void ipmi_new_smi(int if_num)
 {
@@ -823,15 +823,8 @@ static __init int init_ipmi_devintf(void
 
 	printk(KERN_INFO "ipmi device interface\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;
 	}
@@ -845,7 +838,6 @@ static __init int init_ipmi_devintf(void
 	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;
 	}
@@ -856,7 +848,6 @@ module_init(init_ipmi_devintf);
 
 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);
drivers/char/ipmi/ipmi_kcs_sm.c +13 -0
index da15541..6e71315 100644
@@ -41,6 +41,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/jiffies.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
 #include "ipmi_si_sm.h"
@@ -120,6 +121,17 @@ struct si_sm_data
 	unsigned long  error0_timeout;
 };
 
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver kcs_si_driver = {
+	.owner = THIS_MODULE,
+	.driver = {
+		.name = "ipmi_kcs_sm",
+		.bus = &platform_bus_type
+	},
+};
+
 static unsigned int init_kcs_data(struct si_sm_data *kcs,
 				  struct si_sm_io *io)
 {
@@ -509,6 +521,7 @@ static void kcs_cleanup(struct si_sm_dat
 
 struct si_sm_handlers kcs_smi_handlers =
 {
+	.driver            = &kcs_si_driver,
 	.init_data         = init_kcs_data,
 	.start_transaction = start_kcs_transaction,
 	.get_result        = get_kcs_result,
drivers/char/ipmi/ipmi_msghandler.c +372 -2

416 lines not on this page · raw message

drivers/char/ipmi/ipmi_si_intf.c +176 -24

287 lines not on this page · raw message

drivers/char/ipmi/ipmi_si_sm.h +6 -3
index bf3d496..c507c65 100644
@@ -34,6 +34,8 @@
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/ipmi.h>
+
 /* This is defined by the state machines themselves, it is an opaque
    data type for them to use. */
 struct si_sm_data;
@@ -73,9 +75,10 @@ enum si_sm_result
 /* Handlers for the SMI state machine. */
 struct si_sm_handlers
 {
-	/* Put the version number of the state machine here so the
-           upper layer can print it. */
-	char *version;
+	/* The driver model view of the system interface state machine so it can be
+	   registered/unregistered, also access to the version number so the upper
+	   layer can print it. */
+	struct ipmi_si_driver *driver;
 
 	/* Initialize the data and return the amount of I/O space to
            reserve for the space. */
drivers/char/ipmi/ipmi_smic_sm.c +13 -0
index 39d7e5e..cf7ccaf 100644
@@ -43,6 +43,7 @@
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/ipmi.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ipmi_msgdefs.h>		/* for completion codes */
@@ -119,6 +120,17 @@ struct si_sm_data
         long		 smic_timeout;
 };
 
+/** 
+ * The driver model view of the IPMI system interface state machine.
+ */
+static struct ipmi_si_driver smic_si_driver = {
+	.owner = THIS_MODULE,
+	.driver = {
+		.name = "ipmi_smic_sm",
+		.bus = &platform_bus_type
+	},
+};
+
 static unsigned int init_smic_data (struct si_sm_data *smic,
 				    struct si_sm_io *io)
 {
@@ -595,6 +607,7 @@ static int smic_size(void)
 
 struct si_sm_handlers smic_smi_handlers =
 {
+	.driver            = &smic_si_driver,
 	.init_data         = init_smic_data,
 	.start_transaction = start_smic_transaction,
 	.get_result        = smic_get_result,
include/linux/ipmi.h +127 -0

143 lines not on this page · raw message

include/linux/ipmi_msgdefs.h +1 -0
index 03bc64d..f8572af 100644
@@ -45,6 +45,7 @@
 
 #define IPMI_NETFN_APP_REQUEST			0x06
 #define IPMI_NETFN_APP_RESPONSE			0x07
+#define IPMI_GET_DEVICE_GUID_CMD           0x08
 #define IPMI_GET_DEVICE_ID_CMD		0x01
 #define IPMI_CLEAR_MSG_FLAGS_CMD	0x30
 #define IPMI_GET_MSG_FLAGS_CMD		0x31
include/linux/ipmi_smi.h +1 -0
index e36ee15..96c2182 100644
@@ -43,6 +43,7 @@
 
 /* Structure for the low-level drivers. */
 typedef struct ipmi_smi *ipmi_smi_t;
+typedef struct smi_info *smi_info_t;
 
 /*
  * Messages to/from the lower layer.  The smi interface will take one

---
0.99.9j