]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
bnx2x: Rework power state handling code
authorVladislav Zolotarov <vladz@broadcom.com>
Mon, 19 Apr 2010 01:14:49 +0000 (01:14 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Apr 2010 20:17:11 +0000 (13:17 -0700)
Move "don't shut down the power" logic into bnx2x_set_power_state() to make the code cleaner.

Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bnx2x_main.c

index d7c00748e2706f2f2e44d57b977eae5ad3870b14..c4bc006f510423a9c53de8f75a83e9130e26c51d 100644 (file)
@@ -11935,6 +11935,14 @@ static int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
                break;
 
        case PCI_D3hot:
+               /* If there are other clients above don't
+                  shut down the power */
+               if (atomic_read(&bp->pdev->enable_cnt) != 1)
+                       return 0;
+               /* Don't shut down the power for emulation and FPGA */
+               if (CHIP_REV_IS_SLOW(bp))
+                       return 0;
+
                pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
                pmcsr |= 3;
 
@@ -12551,9 +12559,7 @@ static int bnx2x_close(struct net_device *dev)
 
        /* Unload the driver, release IRQs */
        bnx2x_nic_unload(bp, UNLOAD_CLOSE);
-       if (atomic_read(&bp->pdev->enable_cnt) == 1)
-               if (!CHIP_REV_IS_SLOW(bp))
-                       bnx2x_set_power_state(bp, PCI_D3hot);
+       bnx2x_set_power_state(bp, PCI_D3hot);
 
        return 0;
 }