e1000: consolidate managability enabling/disabling
[pandora-kernel.git] / drivers / net / e100.c
index 26073c3..c2ae2a2 100644 (file)
@@ -1215,7 +1215,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb
 *  the literal in the instruction before the code is loaded, the
 *  driver can change the algorithm.
 *
-*  INTDELAY - This loads the dead-man timer with its inital value.
+*  INTDELAY - This loads the dead-man timer with its initial value.
 *    When this timer expires the interrupt is asserted, and the
 *    timer is reset each time a new packet is received.  (see
 *    BUNDLEMAX below to set the limit on number of chained packets)
@@ -1930,9 +1930,8 @@ static int e100_rx_alloc_list(struct nic *nic)
        nic->rx_to_use = nic->rx_to_clean = NULL;
        nic->ru_running = RU_UNINITIALIZED;
 
-       if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC)))
+       if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
                return -ENOMEM;
-       memset(nic->rxs, 0, sizeof(struct rx) * count);
 
        for(rx = nic->rxs, i = 0; i < count; rx++, i++) {
                rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
@@ -1949,7 +1948,7 @@ static int e100_rx_alloc_list(struct nic *nic)
        return 0;
 }
 
-static irqreturn_t e100_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t e100_intr(int irq, void *dev_id)
 {
        struct net_device *netdev = dev_id;
        struct nic *nic = netdev_priv(netdev);
@@ -2005,7 +2004,7 @@ static void e100_netpoll(struct net_device *netdev)
        struct nic *nic = netdev_priv(netdev);
 
        e100_disable_irq(nic);
-       e100_intr(nic->pdev->irq, netdev, NULL);
+       e100_intr(nic->pdev->irq, netdev);
        e100_tx_clean(nic);
        e100_enable_irq(nic);
 }
@@ -2039,7 +2038,6 @@ static int e100_change_mtu(struct net_device *netdev, int new_mtu)
        return 0;
 }
 
-#ifdef CONFIG_PM
 static int e100_asf(struct nic *nic)
 {
        /* ASF can be enabled from eeprom */
@@ -2048,7 +2046,6 @@ static int e100_asf(struct nic *nic)
           !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
           ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE));
 }
-#endif
 
 static int e100_up(struct nic *nic)
 {
@@ -2104,9 +2101,10 @@ static void e100_tx_timeout(struct net_device *netdev)
        schedule_work(&nic->tx_timeout_task);
 }
 
-static void e100_tx_timeout_task(struct net_device *netdev)
+static void e100_tx_timeout_task(struct work_struct *work)
 {
-       struct nic *nic = netdev_priv(netdev);
+       struct nic *nic = container_of(work, struct nic, tx_timeout_task);
+       struct net_device *netdev = nic->netdev;
 
        DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
                readb(&nic->csr->scb.status));
@@ -2639,8 +2637,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
        nic->blink_timer.function = e100_blink_led;
        nic->blink_timer.data = (unsigned long)nic;
 
-       INIT_WORK(&nic->tx_timeout_task,
-               (void (*)(void *))e100_tx_timeout_task, netdev);
+       INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
 
        if((err = e100_alloc(nic))) {
                DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
@@ -2715,34 +2712,35 @@ static void __devexit e100_remove(struct pci_dev *pdev)
        }
 }
 
+#ifdef CONFIG_PM
 static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct nic *nic = netdev_priv(netdev);
 
+#ifdef CONFIG_E100_NAPI
        if (netif_running(netdev))
-               e100_down(nic);
-       e100_hw_reset(nic);
-       netif_device_detach(netdev);
+               netif_poll_disable(nic->netdev);
+#endif
+       del_timer_sync(&nic->watchdog);
+       netif_carrier_off(nic->netdev);
 
-#ifdef CONFIG_PM
        pci_save_state(pdev);
-       if (nic->flags & (wol_magic | e100_asf(nic)))
-#else
-       if (nic->flags & (wol_magic))
-#endif
-               pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
-       else
-               /* disable PME */
-               pci_enable_wake(pdev, 0, 0);
+
+       if ((nic->flags & wol_magic) | e100_asf(nic)) {
+               pci_enable_wake(pdev, PCI_D3hot, 1);
+               pci_enable_wake(pdev, PCI_D3cold, 1);
+       } else {
+               pci_enable_wake(pdev, PCI_D3hot, 0);
+               pci_enable_wake(pdev, PCI_D3cold, 0);
+       }
 
        pci_disable_device(pdev);
-       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       pci_set_power_state(pdev, PCI_D3hot);
 
        return 0;
 }
 
-#ifdef CONFIG_PM
 static int e100_resume(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
@@ -2764,7 +2762,26 @@ static int e100_resume(struct pci_dev *pdev)
 
 static void e100_shutdown(struct pci_dev *pdev)
 {
-       e100_suspend(pdev, PMSG_SUSPEND);
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct nic *nic = netdev_priv(netdev);
+
+#ifdef CONFIG_E100_NAPI
+       if (netif_running(netdev))
+               netif_poll_disable(nic->netdev);
+#endif
+       del_timer_sync(&nic->watchdog);
+       netif_carrier_off(nic->netdev);
+
+       if ((nic->flags & wol_magic) | e100_asf(nic)) {
+               pci_enable_wake(pdev, PCI_D3hot, 1);
+               pci_enable_wake(pdev, PCI_D3cold, 1);
+       } else {
+               pci_enable_wake(pdev, PCI_D3hot, 0);
+               pci_enable_wake(pdev, PCI_D3cold, 0);
+       }
+
+       pci_disable_device(pdev);
+       pci_set_power_state(pdev, PCI_D3hot);
 }
 
 /* ------------------ PCI Error Recovery infrastructure  -------------- */
@@ -2848,9 +2865,9 @@ static struct pci_driver e100_driver = {
        .id_table =     e100_id_table,
        .probe =        e100_probe,
        .remove =       __devexit_p(e100_remove),
+#ifdef CONFIG_PM
        /* Power Management hooks */
        .suspend =      e100_suspend,
-#ifdef CONFIG_PM
        .resume =       e100_resume,
 #endif
        .shutdown =     e100_shutdown,