]> git.karo-electronics.de Git - linux-beck.git/commitdiff
pciehp: cleanup pcie_poll_cmd
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Fri, 20 Jun 2008 03:04:33 +0000 (12:04 +0900)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Wed, 25 Jun 2008 22:54:30 +0000 (15:54 -0700)
Cleanup pcie_poll_cmd(): check the slot status once before entering our
completion test loop and convert the loop to a simpler while() block.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/hotplug/pciehp_hpc.c

index c030c94a4acb82952bb34ad408521de523722959..36ea9499e38567949b58ee4ba77d4efda730bee8 100644 (file)
@@ -252,20 +252,23 @@ static inline int pcie_poll_cmd(struct controller *ctrl)
        u16 slot_status;
        int timeout = 1000;
 
-       if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status))
-               if (slot_status & CMD_COMPLETED)
-                       goto completed;
-       for (timeout = 1000; timeout > 0; timeout -= 100) {
+       if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) {
+               if (slot_status & CMD_COMPLETED) {
+                       pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED);
+                       return 1;
+               }
+       }
+       while (timeout > 1000) {
                msleep(100);
-               if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status))
-                       if (slot_status & CMD_COMPLETED)
-                               goto completed;
+               timeout -= 100;
+               if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) {
+                       if (slot_status & CMD_COMPLETED) {
+                               pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED);
+                               return 1;
+                       }
+               }
        }
        return 0;       /* timeout */
-
-completed:
-       pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED);
-       return timeout;
 }
 
 static inline void pcie_wait_cmd(struct controller *ctrl, int poll)