semaphore to mutex conversion.
the conversion was generated via scripts, and the result was validated
automatically via a script as well.
build tested with allyesconfig.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
 
 #include <linux/acpi.h>
 #include <linux/kobject.h>     /* for KOBJ_NAME_LEN */
+#include <linux/mutex.h>
 #include "pci_hotplug.h"
 
 #define dbg(format, arg...)                                    \
        struct acpiphp_bridge *bridge;  /* parent */
        struct list_head funcs;         /* one slot may have different
                                           objects (i.e. for each function) */
-       struct semaphore crit_sect;
+       struct mutex crit_sect;
 
        u32             id;             /* slot id (serial #) for hotplug core */
        u8              device;         /* pci device# */
 
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 #include "../pci.h"
 #include "pci_hotplug.h"
                slot->device = device;
                slot->sun = sun;
                INIT_LIST_HEAD(&slot->funcs);
-               init_MUTEX(&slot->crit_sect);
+               mutex_init(&slot->crit_sect);
 
                slot->next = bridge->slots;
                bridge->slots = slot;
 {
        int retval;
 
-       down(&slot->crit_sect);
+       mutex_lock(&slot->crit_sect);
 
        /* wake up all functions */
        retval = power_on_slot(slot);
                retval = enable_device(slot);
 
  err_exit:
-       up(&slot->crit_sect);
+       mutex_unlock(&slot->crit_sect);
        return retval;
 }
 
 {
        int retval = 0;
 
-       down(&slot->crit_sect);
+       mutex_lock(&slot->crit_sect);
 
        /* unconfigure all functions */
        retval = disable_device(slot);
                goto err_exit;
 
  err_exit:
-       up(&slot->crit_sect);
+       mutex_unlock(&slot->crit_sect);
        return retval;
 }
 
 
 #include <linux/interrupt.h>
 #include <asm/io.h>            /* for read? and write? functions */
 #include <linux/delay.h>       /* for delays */
+#include <linux/mutex.h>
 
 #define MY_NAME        "cpqphp"
 
 struct controller {
        struct controller *next;
        u32 ctrl_int_comp;
-       struct semaphore crit_sect;     /* critical section semaphore */
+       struct mutex crit_sect;         /* critical section mutex */
        void __iomem *hpc_reg;          /* cookie for our pci controller location */
        struct pci_resource *mem_head;
        struct pci_resource *p_mem_head;
 
        hp_slot = func->device - ctrl->slot_device_offset;
 
        // Wait for exclusive access to hardware
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        if (status == 1) {
                amber_LED_on (ctrl, hp_slot);
                amber_LED_off (ctrl, hp_slot);
        } else {
                // Done with exclusive hardware access
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return(1);
        }
 
        wait_for_ctrl_irq (ctrl);
 
        // Done with exclusive hardware access
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return(0);
 }
        dbg("bus device function rev: %d %d %d %d\n", ctrl->bus,
                PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev);
 
-       init_MUTEX(&ctrl->crit_sect);
+       mutex_init(&ctrl->crit_sect);
        init_waitqueue_head(&ctrl->queue);
 
        /* initialize our threads if they haven't already been started up */
 
        // turn off empty slots here unless command line option "ON" set
        // Wait for exclusive access to hardware
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
 
        rc = init_SERR(ctrl);
        if (rc) {
                err("init_SERR failed\n");
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                goto err_free_irq;
        }
 
        // Done with exclusive hardware access
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        cpqhp_create_debugfs_files(ctrl);
 
 
                 **********************************/
                rc = CARD_FUNCTIONING;
        } else {
-               down(&ctrl->crit_sect);
+               mutex_lock(&ctrl->crit_sect);
 
                /* turn on board without attaching to the bus */
                enable_slot_power (ctrl, hp_slot);
                /* Wait for SOBS to be unset */
                wait_for_ctrl_irq (ctrl);
 
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
 
                if (rc)
                        return rc;
 
-               down(&ctrl->crit_sect);
+               mutex_lock(&ctrl->crit_sect);
 
                slot_enable (ctrl, hp_slot);
                green_LED_blink (ctrl, hp_slot);
                /* Wait for SOBS to be unset */
                wait_for_ctrl_irq (ctrl);
 
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
 
                /* Wait for ~1 second because of hot plug spec */
                long_delay(1*HZ);
                                 * called for the "base" bus/dev/func of an
                                 * adapter. */
 
-                               down(&ctrl->crit_sect);
+                               mutex_lock(&ctrl->crit_sect);
 
                                amber_LED_on (ctrl, hp_slot);
                                green_LED_off (ctrl, hp_slot);
                                /* Wait for SOBS to be unset */
                                wait_for_ctrl_irq (ctrl);
 
-                               up(&ctrl->crit_sect);
+                               mutex_unlock(&ctrl->crit_sect);
 
                                if (rc)
                                        return rc;
                                 * called for the "base" bus/dev/func of an
                                 * adapter. */
 
-                               down(&ctrl->crit_sect);
+                               mutex_lock(&ctrl->crit_sect);
 
                                amber_LED_on (ctrl, hp_slot);
                                green_LED_off (ctrl, hp_slot);
                                /* Wait for SOBS to be unset */
                                wait_for_ctrl_irq (ctrl);
 
-                               up(&ctrl->crit_sect);
+                               mutex_unlock(&ctrl->crit_sect);
 
                                return rc;
                        }
                        /* Done configuring so turn LED on full time */
 
-                       down(&ctrl->crit_sect);
+                       mutex_lock(&ctrl->crit_sect);
 
                        green_LED_on (ctrl, hp_slot);
 
                        /* Wait for SOBS to be unset */
                        wait_for_ctrl_irq (ctrl);
 
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        rc = 0;
                } else {
                        /* Something is wrong
                         * in this case it will always be called for the "base"
                         * bus/dev/func of an adapter. */
 
-                       down(&ctrl->crit_sect);
+                       mutex_lock(&ctrl->crit_sect);
 
                        amber_LED_on (ctrl, hp_slot);
                        green_LED_off (ctrl, hp_slot);
                        /* Wait for SOBS to be unset */
                        wait_for_ctrl_irq (ctrl);
 
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                }
 
        }
        dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n",
            __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot);
 
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        /* turn on board without attaching to the bus */
        enable_slot_power(ctrl, hp_slot);
        /* Wait for SOBS to be unset */
        wait_for_ctrl_irq(ctrl);
 
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        if (rc)
                return rc;
        /* turn on board and blink green LED */
 
        dbg("%s: before down\n", __FUNCTION__);
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
        dbg("%s: after down\n", __FUNCTION__);
 
        dbg("%s: before slot_enable\n", __FUNCTION__);
        dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__);
 
        dbg("%s: before up\n", __FUNCTION__);
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
        dbg("%s: after up\n", __FUNCTION__);
 
        /* Wait for ~1 second because of hot plug spec */
                cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
 
                if (rc) {
-                       down(&ctrl->crit_sect);
+                       mutex_lock(&ctrl->crit_sect);
 
                        amber_LED_on (ctrl, hp_slot);
                        green_LED_off (ctrl, hp_slot);
                        /* Wait for SOBS to be unset */
                        wait_for_ctrl_irq (ctrl);
 
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return rc;
                } else {
                        cpqhp_save_slot_config(ctrl, func);
                        }
                } while (new_slot);
 
-               down(&ctrl->crit_sect);
+               mutex_lock(&ctrl->crit_sect);
 
                green_LED_on (ctrl, hp_slot);
 
                /* Wait for SOBS to be unset */
                wait_for_ctrl_irq (ctrl);
 
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
        } else {
-               down(&ctrl->crit_sect);
+               mutex_lock(&ctrl->crit_sect);
 
                amber_LED_on (ctrl, hp_slot);
                green_LED_off (ctrl, hp_slot);
                /* Wait for SOBS to be unset */
                wait_for_ctrl_irq (ctrl);
 
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
 
                return rc;
        }
                func->status = 0x01;
        func->configured = 0;
 
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        green_LED_off (ctrl, hp_slot);
        slot_disable (ctrl, hp_slot);
        /* Wait for SOBS to be unset */
        wait_for_ctrl_irq (ctrl);
 
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        if (!replace_flag && ctrl->add_support) {
                while (func) {
                                        dbg("button cancel\n");
                                        del_timer(&p_slot->task_event);
 
-                                       down(&ctrl->crit_sect);
+                                       mutex_lock(&ctrl->crit_sect);
 
                                        if (p_slot->state == BLINKINGOFF_STATE) {
                                                /* slot is on */
                                        /* Wait for SOBS to be unset */
                                        wait_for_ctrl_irq (ctrl);
 
-                                       up(&ctrl->crit_sect);
+                                       mutex_unlock(&ctrl->crit_sect);
                                }
                                /*** button Released (No action on press...) */
                                else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
                                                p_slot->state = BLINKINGON_STATE;
                                                info(msg_button_on, p_slot->number);
                                        }
-                                       down(&ctrl->crit_sect);
+                                       mutex_lock(&ctrl->crit_sect);
                                        
                                        dbg("blink green LED and turn off amber\n");
                                        
                                        /* Wait for SOBS to be unset */
                                        wait_for_ctrl_irq (ctrl);
 
-                                       up(&ctrl->crit_sect);
+                                       mutex_unlock(&ctrl->crit_sect);
                                        init_timer(&p_slot->task_event);
                                        p_slot->hp_slot = hp_slot;
                                        p_slot->ctrl = ctrl;
 
 #include <linux/pci.h>
 #include <linux/smp_lock.h>
 #include <linux/init.h>
+#include <linux/mutex.h>
+
 #include "ibmphp.h"
 
 static int to_debug = FALSE;
 //----------------------------------------------------------------------------
 static int ibmphp_shutdown;
 static int tid_poll;
-static struct semaphore sem_hpcaccess; // lock access to HPC
+static struct mutex 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
 {
        debug ("%s - Entry\n", __FUNCTION__);
 
-       init_MUTEX (&sem_hpcaccess);
+       mutex_init(&sem_hpcaccess);
        init_MUTEX (&semOperations);
        init_MUTEX_LOCKED (&sem_exit);
        to_debug = FALSE;
 *---------------------------------------------------------------------*/
 static void get_hpc_access (void)
 {
-       down (&sem_hpcaccess);
+       mutex_lock(&sem_hpcaccess);
 }
 
 /*----------------------------------------------------------------------
 *---------------------------------------------------------------------*/
 void free_hpc_access (void)
 {
-       up (&sem_hpcaccess);
+       mutex_unlock(&sem_hpcaccess);
 }
 
 /*----------------------------------------------------------------------
 
 #include <linux/delay.h>
 #include <linux/sched.h>               /* signal_pending() */
 #include <linux/pcieport_if.h>
+#include <linux/mutex.h>
 #include "pci_hotplug.h"
 
 #define MY_NAME        "pciehp"
 #define MAX_EVENTS             10
 struct controller {
        struct controller *next;
-       struct semaphore crit_sect;     /* critical section semaphore */
+       struct mutex crit_sect;         /* critical section mutex */
        struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
        int num_slots;                  /* Number of slots on ctlr */
        int slot_num_inc;               /* 1 or -1 */
 
        }
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
        
                rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
                if (rc) {
                        /* Done with exclusive hardware access */
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        goto err_out_free_ctrl_slot;
                } else
                        /* Wait for the command to complete */
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return 0;
 
 
 static void set_slot_off(struct controller *ctrl, struct slot * pslot)
 {
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
        if (POWER_CTRL(ctrl->ctrlcap)) {
                if (pslot->hpc_ops->power_off_slot(pslot)) {   
                        err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return;
                }
                wait_for_ctrl_irq (ctrl);
        if (ATTN_LED(ctrl->ctrlcap)) { 
                if (pslot->hpc_ops->set_attention_status(pslot, 1)) {   
                        err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return;
                }
                wait_for_ctrl_irq (ctrl);
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 }
 
 /**
                        ctrl->slot_device_offset, hp_slot);
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        if (POWER_CTRL(ctrl->ctrlcap)) {
                /* Power on slot */
                rc = p_slot->hpc_ops->power_on_slot(p_slot);
                if (rc) {
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return -1;
                }
 
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        /* Wait for ~1 second */
        wait_for_ctrl_irq (ctrl);
                pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
        if (PWR_LED(ctrl->ctrlcap)) {
                /* Wait for exclusive access to hardware */
-               down(&ctrl->crit_sect);
+               mutex_lock(&ctrl->crit_sect);
 
                p_slot->hpc_ops->green_led_on(p_slot);
   
                wait_for_ctrl_irq (ctrl);
        
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
        }
        return 0;
 
        dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        if (POWER_CTRL(ctrl->ctrlcap)) {
                /* power off slot */
                rc = p_slot->hpc_ops->power_off_slot(p_slot);
                if (rc) {
                        err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return rc;
                }
                /* Wait for the command to complete */
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return 0;
 }
 
                if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
                        /* Wait for exclusive access to hardware */
-                       down(&p_slot->ctrl->crit_sect);
+                       mutex_lock(&p_slot->ctrl->crit_sect);
 
                        p_slot->hpc_ops->green_led_off(p_slot);
 
                        wait_for_ctrl_irq (p_slot->ctrl);
 
                        /* Done with exclusive hardware access */
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                }
                p_slot->state = STATIC_STATE;
        }
 
                if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
                        /* Wait for exclusive access to hardware */
-                       down(&p_slot->ctrl->crit_sect);
+                       mutex_lock(&p_slot->ctrl->crit_sect);
 
                        p_slot->hpc_ops->green_led_off(p_slot);
 
                        wait_for_ctrl_irq (p_slot->ctrl);
 
                        /* Done with exclusive hardware access */
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                }
                p_slot->state = STATIC_STATE;
        }
                                        switch (p_slot->state) {
                                        case BLINKINGOFF_STATE:
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
                                                
                                                if (PWR_LED(ctrl->ctrlcap)) {
                                                        p_slot->hpc_ops->green_led_on(p_slot);
                                                        wait_for_ctrl_irq (ctrl);
                                                }
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
                                                break;
                                        case BLINKINGON_STATE:
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
 
                                                if (PWR_LED(ctrl->ctrlcap)) {
                                                        p_slot->hpc_ops->green_led_off(p_slot);
                                                        wait_for_ctrl_irq (ctrl);
                                                }
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
 
                                                break;
                                        default:
                                                }
 
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
 
                                                /* blink green LED and turn off amber */
                                                if (PWR_LED(ctrl->ctrlcap)) {
                                                }
 
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
 
                                                init_timer(&p_slot->task_event);
                                                p_slot->task_event.expires = jiffies + 5 * HZ;   /* 5 second delay */
                                        if (POWER_CTRL(ctrl->ctrlcap)) {
                                                dbg("power fault\n");
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
 
                                                if (ATTN_LED(ctrl->ctrlcap)) {
                                                        p_slot->hpc_ops->set_attention_status(p_slot, 1);
                                                }
 
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
                                        }
                                }
                                /***********SURPRISE REMOVAL********************/
        int rc;
 
        /* Check to see if (latch closed, card present, power off) */
-       down(&p_slot->ctrl->crit_sect);
+       mutex_lock(&p_slot->ctrl->crit_sect);
 
        rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
        if (rc || !getstatus) {
                info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return 1;
        }
        if (MRL_SENS(p_slot->ctrl->ctrlcap)) {  
                rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
                if (rc || getstatus) {
                        info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                        return 1;
                }
        }
                rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (rc || getstatus) {
                        info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                        return 1;
                }
        }
-       up(&p_slot->ctrl->crit_sect);
+       mutex_unlock(&p_slot->ctrl->crit_sect);
 
        p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 
                return 1;
 
        /* Check to see if (latch closed, card present, power on) */
-       down(&p_slot->ctrl->crit_sect);
+       mutex_lock(&p_slot->ctrl->crit_sect);
 
        if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {       
                ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
                if (ret || !getstatus) {
                        info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                        return 1;
                }
        }
                ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
                if (ret || getstatus) {
                        info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                        return 1;
                }
        }
                ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (ret || !getstatus) {
                        info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                        return 1;
                }
        }
 
-       up(&p_slot->ctrl->crit_sect);
+       mutex_unlock(&p_slot->ctrl->crit_sect);
 
        ret = remove_board(p_slot);
        update_slot_info(p_slot);
 
        if (pci_enable_device(pdev))
                goto abort_free_ctlr;
        
-       init_MUTEX(&ctrl->crit_sect);
+       mutex_init(&ctrl->crit_sect);
        /* setup wait queue */
        init_waitqueue_head(&ctrl->queue);
 
 
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/sched.h>       /* signal_pending(), struct timer_list */
+#include <linux/mutex.h>
 
 #include "pci_hotplug.h"
 
 
 struct controller {
        struct controller *next;
-       struct semaphore crit_sect;     /* critical section semaphore */
+       struct mutex crit_sect;         /* critical section mutex */
        struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
        int num_slots;                  /* Number of slots on ctlr */
        int slot_num_inc;               /* 1 or -1 */
 
        int rc = 0;
 
        dbg("%s: change to speed %d\n", __FUNCTION__, speed);
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
        if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
                err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return WRONG_BUS_FREQUENCY;
        }
                
                err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
                          __FUNCTION__);
                err("%s: Error code (%d)\n", __FUNCTION__, rc);
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return WRONG_BUS_FREQUENCY;
        }
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
        return rc;
 }
 
                        ctrl->slot_device_offset, hp_slot);
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        /* Power on slot without connecting to bus */
        rc = p_slot->hpc_ops->power_on_slot(p_slot);
        if (rc) {
                err("%s: Failed to power on slot\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return -1;
        }
        
        if (rc) {
                err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return -1;
        }
 
                
                if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
                        err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return WRONG_BUS_FREQUENCY;
                }
                
                        err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
                                  __FUNCTION__);
                        err("%s: Error code (%d)\n", __FUNCTION__, rc);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return WRONG_BUS_FREQUENCY;
                }
                /* turn on board, blink green LED, turn off Amber LED */
                if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
                        err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return rc;
                }
 
                if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
                        err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->crit_sect);
                        return rc;  
                }
        }
        if (rc  || adapter_speed == PCI_SPEED_UNKNOWN) {
                err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return WRONG_BUS_FREQUENCY;
        }
 
        if (rc || bus_speed == PCI_SPEED_UNKNOWN) {
                err("%s: Can't get bus operation speed\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return WRONG_BUS_FREQUENCY;
        }
 
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        if ((rc  = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) {
                err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__);
                                return rc;
        }
 
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
        /* turn on board, blink green LED, turn off Amber LED */
        if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
                err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;
        }
 
        if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
                err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;  
        }
 
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        /* Wait for ~1 second */
        wait_for_ctrl_irq (ctrl);
        p_slot->pwr_save = 1;
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        p_slot->hpc_ops->green_led_on(p_slot);
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return 0;
 
 err_exit:
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        /* turn off slot, turn on Amber LED, turn off Green LED */
        rc = p_slot->hpc_ops->slot_disable(p_slot);
        if (rc) {
                err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;
        }
 
        if (rc) {
                err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        return(rc);
 }
                p_slot->status = 0x01;
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->crit_sect);
 
        /* turn off slot, turn on Amber LED, turn off Green LED */
        rc = p_slot->hpc_ops->slot_disable(p_slot);
        if (rc) {
                err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;
        }
 
        if (rc) {
                err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;  
        }
        
        if (rc) {
                err("%s: Issue of Set Attention command failed\n", __FUNCTION__);
                /* Done with exclusive hardware access */
-               up(&ctrl->crit_sect);
+               mutex_unlock(&ctrl->crit_sect);
                return rc;
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->crit_sect);
 
        p_slot->pwr_save = 0;
        p_slot->is_a_board = 0;
 
                if (shpchp_enable_slot(p_slot)) {
                        /* Wait for exclusive access to hardware */
-                       down(&p_slot->ctrl->crit_sect);
+                       mutex_lock(&p_slot->ctrl->crit_sect);
 
                        p_slot->hpc_ops->green_led_off(p_slot);
 
                        /* Done with exclusive hardware access */
-                       up(&p_slot->ctrl->crit_sect);
+                       mutex_unlock(&p_slot->ctrl->crit_sect);
                }
                p_slot->state = STATIC_STATE;
        }
                                        switch (p_slot->state) {
                                        case BLINKINGOFF_STATE:
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
 
                                                p_slot->hpc_ops->green_led_on(p_slot);
 
                                                p_slot->hpc_ops->set_attention_status(p_slot, 0);
 
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
                                                break;
                                        case BLINKINGON_STATE:
                                                /* Wait for exclusive access to hardware */
-                                               down(&ctrl->crit_sect);
+                                               mutex_lock(&ctrl->crit_sect);
 
                                                p_slot->hpc_ops->green_led_off(p_slot);
 
                                                p_slot->hpc_ops->set_attention_status(p_slot, 0);
 
                                                /* Done with exclusive hardware access */
-                                               up(&ctrl->crit_sect);
+                                               mutex_unlock(&ctrl->crit_sect);
 
                                                break;
                                        default:
                                        }
 
                                        /* Wait for exclusive access to hardware */
-                                       down(&ctrl->crit_sect);
+                                       mutex_lock(&ctrl->crit_sect);
 
                                        /* blink green LED and turn off amber */
                                        p_slot->hpc_ops->green_led_blink(p_slot);
                                        p_slot->hpc_ops->set_attention_status(p_slot, 0);
 
                                        /* Done with exclusive hardware access */
-                                       up(&ctrl->crit_sect);
+                                       mutex_unlock(&ctrl->crit_sect);
 
                                        init_timer(&p_slot->task_event);
                                        p_slot->task_event.expires = jiffies + 5 * HZ;   /* 5 second delay */
                                        /***********POWER FAULT********************/
                                        dbg("%s: power fault\n", __FUNCTION__);
                                        /* Wait for exclusive access to hardware */
-                                       down(&ctrl->crit_sect);
+                                       mutex_lock(&ctrl->crit_sect);
 
                                        p_slot->hpc_ops->set_attention_status(p_slot, 1);
                                        
                                        p_slot->hpc_ops->green_led_off(p_slot);
 
                                        /* Done with exclusive hardware access */
-                                       up(&ctrl->crit_sect);
+                                       mutex_unlock(&ctrl->crit_sect);
                                } else {
                                        /* refresh notification */
                                        if (p_slot)
        int rc;
 
        /* Check to see if (latch closed, card present, power off) */
-       down(&p_slot->ctrl->crit_sect);
+       mutex_lock(&p_slot->ctrl->crit_sect);
        rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
        if (rc || !getstatus) {
                info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
        rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
        if (rc || getstatus) {
                info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
        rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
        if (rc || getstatus) {
                info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
-       up(&p_slot->ctrl->crit_sect);
+       mutex_unlock(&p_slot->ctrl->crit_sect);
 
        p_slot->is_a_board = 1;
 
                return -ENODEV;
 
        /* Check to see if (latch closed, card present, power on) */
-       down(&p_slot->ctrl->crit_sect);
+       mutex_lock(&p_slot->ctrl->crit_sect);
 
        ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
        if (ret || !getstatus) {
                info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
        ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
        if (ret || getstatus) {
                info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
        ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
        if (ret || !getstatus) {
                info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
-               up(&p_slot->ctrl->crit_sect);
+               mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
-       up(&p_slot->ctrl->crit_sect);
+       mutex_unlock(&p_slot->ctrl->crit_sect);
 
        ret = remove_board(p_slot);
        update_slot_info(p_slot);
 
        }
        dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
 
-       init_MUTEX(&ctrl->crit_sect);
+       mutex_init(&ctrl->crit_sect);
        /* Setup wait queue */
        init_waitqueue_head(&ctrl->queue);