Skip to content

Commit

Permalink
[PATCH] PCI hotplug: convert semaphores to mutex
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ingo Molnar authored and Greg Kroah-Hartman committed Mar 23, 2006
1 parent c408a37 commit 6aa4cdd
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 137 deletions.
3 changes: 2 additions & 1 deletion drivers/pci/hotplug/acpiphp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <linux/acpi.h>
#include <linux/kobject.h> /* for KOBJ_NAME_LEN */
#include <linux/mutex.h>
#include "pci_hotplug.h"

#define dbg(format, arg...) \
Expand Down Expand Up @@ -118,7 +119,7 @@ struct acpiphp_slot {
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# */
Expand Down
12 changes: 6 additions & 6 deletions drivers/pci/hotplug/acpiphp_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#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"
Expand Down Expand Up @@ -188,7 +188,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
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;
Expand Down Expand Up @@ -1401,7 +1401,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
{
int retval;

down(&slot->crit_sect);
mutex_lock(&slot->crit_sect);

/* wake up all functions */
retval = power_on_slot(slot);
Expand All @@ -1413,7 +1413,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
retval = enable_device(slot);

err_exit:
up(&slot->crit_sect);
mutex_unlock(&slot->crit_sect);
return retval;
}

Expand All @@ -1424,7 +1424,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
{
int retval = 0;

down(&slot->crit_sect);
mutex_lock(&slot->crit_sect);

/* unconfigure all functions */
retval = disable_device(slot);
Expand All @@ -1437,7 +1437,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
goto err_exit;

err_exit:
up(&slot->crit_sect);
mutex_unlock(&slot->crit_sect);
return retval;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/pci/hotplug/cpqphp.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#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"

Expand Down Expand Up @@ -286,7 +287,7 @@ struct event_info {
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;
Expand Down
14 changes: 7 additions & 7 deletions drivers/pci/hotplug/cpqphp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,15 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
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);
} else if (status == 0) {
amber_LED_off (ctrl, hp_slot);
} else {
// Done with exclusive hardware access
up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);
return(1);
}

Expand All @@ -617,7 +617,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
wait_for_ctrl_irq (ctrl);

// Done with exclusive hardware access
up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);

return(0);
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
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 */
Expand Down Expand Up @@ -1223,7 +1223,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

// 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;

Expand Down Expand Up @@ -1270,12 +1270,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
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);

Expand Down
56 changes: 28 additions & 28 deletions drivers/pci/hotplug/cpqphp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *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);
Expand Down Expand Up @@ -1333,12 +1333,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* 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);
Expand All @@ -1350,7 +1350,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* 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);
Expand All @@ -1375,7 +1375,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* 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);
Expand All @@ -1386,7 +1386,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);

up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);

if (rc)
return rc;
Expand All @@ -1410,7 +1410,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* 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);
Expand All @@ -1421,13 +1421,13 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* 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);

Expand All @@ -1436,7 +1436,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* 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
Expand All @@ -1445,7 +1445,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* 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);
Expand All @@ -1456,7 +1456,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);

up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);
}

}
Expand Down Expand Up @@ -1488,7 +1488,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
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);
Expand Down Expand Up @@ -1522,7 +1522,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq(ctrl);

up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);

if (rc)
return rc;
Expand All @@ -1532,7 +1532,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* 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__);
Expand All @@ -1553,7 +1553,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
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 */
Expand Down Expand Up @@ -1607,7 +1607,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
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);
Expand All @@ -1618,7 +1618,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* 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);
Expand All @@ -1640,7 +1640,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
}
} while (new_slot);

down(&ctrl->crit_sect);
mutex_lock(&ctrl->crit_sect);

green_LED_on (ctrl, hp_slot);

Expand All @@ -1649,9 +1649,9 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* 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);
Expand All @@ -1662,7 +1662,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);

up(&ctrl->crit_sect);
mutex_unlock(&ctrl->crit_sect);

return rc;
}
Expand Down Expand Up @@ -1721,7 +1721,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
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);
Expand All @@ -1736,7 +1736,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
/* 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) {
Expand Down Expand Up @@ -1899,7 +1899,7 @@ static void interrupt_event_handler(struct controller *ctrl)
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 */
Expand All @@ -1922,7 +1922,7 @@ static void interrupt_event_handler(struct controller *ctrl)
/* 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) {
Expand All @@ -1937,7 +1937,7 @@ static void interrupt_event_handler(struct controller *ctrl)
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");

Expand All @@ -1949,7 +1949,7 @@ static void interrupt_event_handler(struct controller *ctrl)
/* 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;
Expand Down
Loading

0 comments on commit 6aa4cdd

Please sign in to comment.