]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/shpchp_hpc.c
shpchp: remove unnecessary cmd_busy member from struct controller
[linux-2.6] / drivers / pci / hotplug / shpchp_hpc.c
index 446e9beff046e01548c2b2c6de61c76fe0779199..bbe450f098e6eaa9447cc722e1df769e9d628b43 100644 (file)
@@ -302,6 +302,12 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
        add_timer(&php_ctlr->int_poll_timer);
 }
 
+static inline int is_ctrl_busy(struct controller *ctrl)
+{
+       u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
+       return cmd_status & 0x1;
+}
+
 /*
  * Returns 1 if SHPC finishes executing a command within 1 sec,
  * otherwise returns 0.
@@ -309,16 +315,14 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
 static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
 {
        int i;
-       u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
 
-       if (!(cmd_status & 0x1))
+       if (!is_ctrl_busy(ctrl))
                return 1;
 
        /* Check every 0.1 sec for a total of 1 sec */
        for (i = 0; i < 10; i++) {
                msleep(100);
-               cmd_status = shpc_readw(ctrl, CMD_STATUS);
-               if (!(cmd_status & 0x1))
+               if (!is_ctrl_busy(ctrl))
                        return 1;
        }
 
@@ -335,15 +339,14 @@ static inline int shpc_wait_cmd(struct controller *ctrl)
                rc = shpc_poll_ctrl_busy(ctrl);
        else
                rc = wait_event_interruptible_timeout(ctrl->queue,
-                                               !ctrl->cmd_busy, timeout);
-       if (!rc) {
+                                               !is_ctrl_busy(ctrl), timeout);
+       if (!rc && is_ctrl_busy(ctrl)) {
                retval = -EIO;
                err("Command not completed in 1000 msec\n");
        } else if (rc < 0) {
                retval = -EINTR;
                info("Command was interrupted by a signal\n");
        }
-       ctrl->cmd_busy = 0;
 
        return retval;
 }
@@ -374,7 +377,6 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
        /* To make sure the Controller Busy bit is 0 before we send out the
         * command. 
         */
-       slot->ctrl->cmd_busy = 1;
        shpc_writew(ctrl, CMD, temp_word);
 
        /*
@@ -924,7 +926,6 @@ static irqreturn_t shpc_isr(int irq, void *dev_id)
                serr_int &= ~SERR_INTR_RSVDZ_MASK;
                shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
 
-               ctrl->cmd_busy = 0;
                wake_up_interruptible(&ctrl->queue);
        }