fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / ipmi / ipmi_smic_sm.c
index 7bd7041..e64ea7d 100644 (file)
 
 #include <linux/kernel.h> /* For printk. */
 #include <linux/string.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/ipmi_msgdefs.h>                /* for completion codes */
 #include "ipmi_si_sm.h"
 
-#define IPMI_SMIC_VERSION "v31"
-
 /* smic_debug is a bit-field
  *     SMIC_DEBUG_ENABLE -     turned on for now
  *     SMIC_DEBUG_MSG -        commands and their responses
@@ -58,6 +58,8 @@
 #define        SMIC_DEBUG_ENABLE       1
 
 static int smic_debug = 1;
+module_param(smic_debug, int, 0644);
+MODULE_PARM_DESC(smic_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
 
 enum smic_states {
        SMIC_IDLE,
@@ -78,11 +80,17 @@ enum smic_states {
 #define SMIC_MAX_ERROR_RETRIES 3
 
 /* Timeouts in microseconds. */
-#define SMIC_RETRY_TIMEOUT 100000
+#define SMIC_RETRY_TIMEOUT 2000000
 
 /* SMIC Flags Register Bits */
 #define SMIC_RX_DATA_READY     0x80
 #define SMIC_TX_DATA_READY     0x40
+/*
+ * SMIC_SMI and SMIC_EVM_DATA_AVAIL are only used by
+ * a few systems, and then only by Systems Management
+ * Interrupts, not by the OS.  Always ignore these bits.
+ *
+ */
 #define SMIC_SMI               0x10
 #define SMIC_EVM_DATA_AVAIL    0x08
 #define SMIC_SMS_DATA_AVAIL    0x04
@@ -133,12 +141,14 @@ static int start_smic_transaction(struct si_sm_data *smic,
 {
        unsigned int i;
 
-       if ((size < 2) || (size > MAX_SMIC_WRITE_SIZE)) {
-               return -1;
-       }
-       if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED)) {
-               return -2;
-       }
+       if (size < 2)
+               return IPMI_REQ_LEN_INVALID_ERR;
+       if (size > MAX_SMIC_WRITE_SIZE)
+               return IPMI_REQ_LEN_EXCEEDED_ERR;
+
+       if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
+               return IPMI_NOT_IN_MY_STATE_ERR;
+
        if (smic_debug & SMIC_DEBUG_MSG) {
                printk(KERN_INFO "start_smic_transaction -");
                for (i = 0; i < size; i ++) {
@@ -366,8 +376,7 @@ static enum si_sm_result smic_event (struct si_sm_data *smic, long time)
        switch (smic->state) {
        case SMIC_IDLE:
                /* in IDLE we check for available messages */
-               if (flags & (SMIC_SMI |
-                            SMIC_EVM_DATA_AVAIL | SMIC_SMS_DATA_AVAIL))
+               if (flags & SMIC_SMS_DATA_AVAIL)
                {
                        return SI_SM_ATTN;
                }
@@ -588,7 +597,6 @@ static int smic_size(void)
 
 struct si_sm_handlers smic_smi_handlers =
 {
-       .version           = IPMI_SMIC_VERSION,
        .init_data         = init_smic_data,
        .start_transaction = start_smic_transaction,
        .get_result        = smic_get_result,