linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / pci / hotplug / ibmphp_hpc.c
index c3ac98a..1a3eb8d 100644 (file)
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
-#include <linux/mutex.h>
-
 #include "ibmphp.h"
 
-static int to_debug = 0;
+static int to_debug = FALSE;
 #define debug_polling(fmt, arg...)     do { if (to_debug) debug (fmt, arg); } while (0)
 
 //----------------------------------------------------------------------------
@@ -95,15 +93,15 @@ static int to_debug = 0;
 //----------------------------------------------------------------------------
 // macro utilities
 //----------------------------------------------------------------------------
-// if bits 20,22,25,26,27,29,30 are OFF return 1
-#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? 0 : 1))
+// if bits 20,22,25,26,27,29,30 are OFF return TRUE
+#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? FALSE : TRUE))
 
 //----------------------------------------------------------------------------
 // global variables
 //----------------------------------------------------------------------------
 static int ibmphp_shutdown;
 static int tid_poll;
-static struct mutex sem_hpcaccess;     // lock access to HPC
+static struct semaphore sem_hpcaccess; // lock access to HPC
 static struct semaphore semOperations; // lock all operations and
                                        // access to data structures
 static struct semaphore sem_exit;      // make sure polling thread goes away
@@ -133,11 +131,11 @@ void __init ibmphp_hpc_initvars (void)
 {
        debug ("%s - Entry\n", __FUNCTION__);
 
-       mutex_init(&sem_hpcaccess);
+       init_MUTEX (&sem_hpcaccess);
        init_MUTEX (&semOperations);
        init_MUTEX_LOCKED (&sem_exit);
-       to_debug = 0;
-       ibmphp_shutdown = 0;
+       to_debug = FALSE;
+       ibmphp_shutdown = FALSE;
        tid_poll = 0;
 
        debug ("%s - Exit\n", __FUNCTION__);
@@ -739,21 +737,21 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
                // check controller is still not working on the command
                //--------------------------------------------------------------------
                timeout = CMD_COMPLETE_TOUT_SEC;
-               done = 0;
+               done = FALSE;
                while (!done) {
                        rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar,
                                                        &status);
                        if (!rc) {
                                if (NEEDTOCHECK_CMDSTATUS (cmd)) {
                                        if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES)
-                                               done = 1;
+                                               done = TRUE;
                                } else
-                                       done = 1;
+                                       done = TRUE;
                        }
                        if (!done) {
                                msleep(1000);
                                if (timeout < 1) {
-                                       done = 1;
+                                       done = TRUE;
                                        err ("%s - Error command complete timeout\n", __FUNCTION__);
                                        rc = -EFAULT;
                                } else
@@ -780,7 +778,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
 *---------------------------------------------------------------------*/
 static void get_hpc_access (void)
 {
-       mutex_lock(&sem_hpcaccess);
+       down (&sem_hpcaccess);
 }
 
 /*----------------------------------------------------------------------
@@ -788,7 +786,7 @@ static void get_hpc_access (void)
 *---------------------------------------------------------------------*/
 void free_hpc_access (void)
 {
-       mutex_unlock(&sem_hpcaccess);
+       up (&sem_hpcaccess);
 }
 
 /*----------------------------------------------------------------------
@@ -799,7 +797,7 @@ void free_hpc_access (void)
 void ibmphp_lock_operations (void)
 {
        down (&semOperations);
-       to_debug = 1;
+       to_debug = TRUE;
 }
 
 /*----------------------------------------------------------------------
@@ -809,7 +807,7 @@ void ibmphp_unlock_operations (void)
 {
        debug ("%s - Entry\n", __FUNCTION__);
        up (&semOperations);
-       to_debug = 0;
+       to_debug = FALSE;
        debug ("%s - Exit\n", __FUNCTION__);
 }
 
@@ -937,40 +935,40 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
 {
        u8 status;
        int rc = 0;
-       u8 disable = 0;
-       u8 update = 0;
+       u8 disable = FALSE;
+       u8 update = FALSE;
 
        debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot);
 
        // bit 0 - HPC_SLOT_POWER
        if ((pslot->status & 0x01) != (poldslot->status & 0x01))
-               update = 1;
+               update = TRUE;
 
        // bit 1 - HPC_SLOT_CONNECT
        // ignore
 
        // bit 2 - HPC_SLOT_ATTN
        if ((pslot->status & 0x04) != (poldslot->status & 0x04))
-               update = 1;
+               update = TRUE;
 
        // bit 3 - HPC_SLOT_PRSNT2
        // bit 4 - HPC_SLOT_PRSNT1
        if (((pslot->status & 0x08) != (poldslot->status & 0x08))
                || ((pslot->status & 0x10) != (poldslot->status & 0x10)))
-               update = 1;
+               update = TRUE;
 
        // bit 5 - HPC_SLOT_PWRGD
        if ((pslot->status & 0x20) != (poldslot->status & 0x20))
                // OFF -> ON: ignore, ON -> OFF: disable slot
                if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) 
-                       disable = 1;
+                       disable = TRUE;
 
        // bit 6 - HPC_SLOT_BUS_SPEED
        // ignore
 
        // bit 7 - HPC_SLOT_LATCH
        if ((pslot->status & 0x80) != (poldslot->status & 0x80)) {
-               update = 1;
+               update = TRUE;
                // OPEN -> CLOSE
                if (pslot->status & 0x80) {
                        if (SLOT_PWRGD (pslot->status)) {
@@ -979,7 +977,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
                                msleep(1000);
                                rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status);
                                if (SLOT_PWRGD (status))
-                                       update = 1;
+                                       update = TRUE;
                                else    // overwrite power in pslot to OFF
                                        pslot->status &= ~HPC_SLOT_POWER;
                        }
@@ -987,17 +985,17 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
                // CLOSE -> OPEN 
                else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD)
                        && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) {
-                       disable = 1;
+                       disable = TRUE;
                }
                // else - ignore
        }
        // bit 4 - HPC_SLOT_BLINK_ATTN
        if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08))
-               update = 1;
+               update = TRUE;
 
        if (disable) {
                debug ("process_changeinstatus - disable slot\n");
-               pslot->flag = 0;
+               pslot->flag = FALSE;
                rc = ibmphp_do_disable_slot (pslot);
        }
 
@@ -1102,7 +1100,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
 {
        debug ("%s - Entry\n", __FUNCTION__);
 
-       ibmphp_shutdown = 1;
+       ibmphp_shutdown = TRUE;
        debug ("before locking operations \n");
        ibmphp_lock_operations ();
        debug ("after locking operations \n");
@@ -1136,7 +1134,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
                                    u8 * pstatus)
 {
        int rc = 0;
-       u8 done = 0;
+       u8 done = FALSE;
 
        debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout);
 
@@ -1144,14 +1142,14 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
                *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX);
                if (*pstatus == HPC_ERROR) {
                        rc = HPC_ERROR;
-                       done = 1;
+                       done = TRUE;
                }
                if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO)
-                       done = 1;
+                       done = TRUE;
                if (!done) {
                        msleep(1000);
                        if (timeout < 1) {
-                               done = 1;
+                               done = TRUE;
                                err ("HPCreadslot - Error ctlr timeout\n");
                                rc = HPC_ERROR;
                        } else