Skip to content

Commit

Permalink
pciehp: cleanup wait command completion
Browse files Browse the repository at this point in the history
This patch cleans up the code to wait for command completion.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Kenji Kaneshige authored and Greg Kroah-Hartman committed Feb 7, 2007
1 parent 75e1317 commit 44ef4ce
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 193 deletions.
18 changes: 0 additions & 18 deletions drivers/pci/hotplug/pciehp.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,6 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
return NULL;
}

static inline int wait_for_ctrl_irq(struct controller *ctrl)
{
DECLARE_WAITQUEUE(wait, current);

add_wait_queue(&ctrl->queue, &wait);
if (!pciehp_poll_mode)
/* Sleep for up to 1 second */
msleep_interruptible(1000);
else
msleep_interruptible(2500);

remove_wait_queue(&ctrl->queue, &wait);
if (signal_pending(current))
return -EINTR;

return 0;
}

struct hpc_ops {
int (*power_on_slot)(struct slot *slot);
int (*power_off_slot)(struct slot *slot);
Expand Down
14 changes: 1 addition & 13 deletions drivers/pci/hotplug/pciehp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,25 +374,13 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
pciehp_ctrl_list = ctrl;
}

/* Wait for exclusive access to hardware */
mutex_lock(&ctrl->ctrl_lock);

t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */

if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
if (rc) {
/* Done with exclusive hardware access */
mutex_unlock(&ctrl->ctrl_lock);
if (rc)
goto err_out_free_ctrl_slot;
} else
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);
}

/* Done with exclusive hardware access */
mutex_unlock(&ctrl->ctrl_lock);

return 0;

err_out_free_ctrl_slot:
Expand Down
Loading

0 comments on commit 44ef4ce

Please sign in to comment.