headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / net / skge.c
index 93c1b1d..8f54143 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/crc32.h>
 #include <linux/dma-mapping.h>
 #include <linux/debugfs.h>
+#include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/mii.h>
 #include <asm/irq.h>
@@ -215,7 +216,7 @@ static void skge_wol_init(struct skge_port *skge)
        if (skge->wol & WAKE_MAGIC)
                ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT;
        else
-               ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT;;
+               ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT;
 
        ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT;
        skge_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl);
@@ -2496,9 +2497,6 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        }
 
        case SIOCSMIIREG:
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
-
                spin_lock_bh(&hw->phy_lock);
                if (hw->chip_id == CHIP_ID_GENESIS)
                        err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f,
@@ -2674,7 +2672,7 @@ static int skge_down(struct net_device *dev)
        if (netif_msg_ifdown(skge))
                printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
 
-       netif_stop_queue(dev);
+       netif_tx_disable(dev);
 
        if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
                del_timer_sync(&skge->link_timer);
@@ -2746,7 +2744,8 @@ static inline int skge_avail(const struct skge_ring *ring)
                + (ring->to_clean - ring->to_use) - 1;
 }
 
-static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
+                                  struct net_device *dev)
 {
        struct skge_port *skge = netdev_priv(dev);
        struct skge_hw *hw = skge->hw;
@@ -2837,8 +2836,6 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
                netif_stop_queue(dev);
        }
 
-       dev->trans_start = jiffies;
-
        return NETDEV_TX_OK;
 }
 
@@ -2881,7 +2878,6 @@ static void skge_tx_clean(struct net_device *dev)
        }
 
        skge->tx_ring.to_clean = e;
-       netif_wake_queue(dev);
 }
 
 static void skge_tx_timeout(struct net_device *dev)
@@ -2893,6 +2889,7 @@ static void skge_tx_timeout(struct net_device *dev)
 
        skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_STOP);
        skge_tx_clean(dev);
+       netif_wake_queue(dev);
 }
 
 static int skge_change_mtu(struct net_device *dev, int new_mtu)
@@ -3214,7 +3211,7 @@ static int skge_poll(struct napi_struct *napi, int to_do)
                unsigned long flags;
 
                spin_lock_irqsave(&hw->hw_lock, flags);
-               __netif_rx_complete(dev, napi);
+               __napi_complete(napi);
                hw->intr_mask |= napimask[skge->port];
                skge_write32(hw, B0_IMSK, hw->intr_mask);
                skge_read32(hw, B0_IMSK);
@@ -3377,7 +3374,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id)
        if (status & (IS_XA1_F|IS_R1_F)) {
                struct skge_port *skge = netdev_priv(hw->dev[0]);
                hw->intr_mask &= ~(IS_XA1_F|IS_R1_F);
-               netif_rx_schedule(hw->dev[0], &skge->napi);
+               napi_schedule(&skge->napi);
        }
 
        if (status & IS_PA_TO_TX1)
@@ -3397,7 +3394,7 @@ static irqreturn_t skge_intr(int irq, void *dev_id)
 
                if (status & (IS_XA2_F|IS_R2_F)) {
                        hw->intr_mask &= ~(IS_XA2_F|IS_R2_F);
-                       netif_rx_schedule(hw->dev[1], &skge->napi);
+                       napi_schedule(&skge->napi);
                }
 
                if (status & IS_PA_TO_RX2) {
@@ -3805,6 +3802,7 @@ static __exit void skge_debug_cleanup(void)
 static const struct net_device_ops skge_netdev_ops = {
        .ndo_open               = skge_up,
        .ndo_stop               = skge_down,
+       .ndo_start_xmit         = skge_xmit_frame,
        .ndo_do_ioctl           = skge_ioctl,
        .ndo_get_stats          = skge_get_stats,
        .ndo_tx_timeout         = skge_tx_timeout,
@@ -3831,7 +3829,6 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        }
 
        SET_NETDEV_DEV(dev, &hw->pdev->dev);
-       dev->hard_start_xmit = skge_xmit_frame;
        dev->netdev_ops = &skge_netdev_ops;
        dev->ethtool_ops = &skge_ethtool_ops;
        dev->watchdog_timeo = TX_WATCHDOG;
@@ -3856,8 +3853,10 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        skge->speed = -1;
        skge->advertising = skge_supported_modes(hw);
 
-       if (device_may_wakeup(&hw->pdev->dev))
+       if (device_can_wakeup(&hw->pdev->dev)) {
                skge->wol = wol_supported(hw) & WAKE_MAGIC;
+               device_set_wakeup_enable(&hw->pdev->dev, skge->wol);
+       }
 
        hw->dev[port] = dev;
 
@@ -3912,12 +3911,12 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
                using_dac = 1;
-               err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-       } else if (!(err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
+               err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+       } else if (!(err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
                using_dac = 0;
-               err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+               err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
        }
 
        if (err) {
@@ -3937,11 +3936,14 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 #endif
 
        err = -ENOMEM;
-       hw = kzalloc(sizeof(*hw), GFP_KERNEL);
+       /* space for skge@pci:0000:04:00.0 */
+       hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:" )
+                    + strlen(pci_name(pdev)) + 1, GFP_KERNEL);
        if (!hw) {
                dev_err(&pdev->dev, "cannot allocate hardware struct\n");
                goto err_out_free_regions;
        }
+       sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev));
 
        hw->pdev = pdev;
        spin_lock_init(&hw->hw_lock);
@@ -3976,7 +3978,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
                goto err_out_free_netdev;
        }
 
-       err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, dev->name, hw);
+       err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, hw->irq_name, hw);
        if (err) {
                dev_err(&pdev->dev, "%s: cannot assign irq %d\n",
                       dev->name, pdev->irq);
@@ -3984,14 +3986,17 @@ static int __devinit skge_probe(struct pci_dev *pdev,
        }
        skge_show_addr(dev);
 
-       if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
-               if (register_netdev(dev1) == 0)
+       if (hw->ports > 1) {
+               dev1 = skge_devinit(hw, 1, using_dac);
+               if (dev1 && register_netdev(dev1) == 0)
                        skge_show_addr(dev1);
                else {
                        /* Failure to register second port need not be fatal */
                        dev_warn(&pdev->dev, "register of second port failed\n");
                        hw->dev[1] = NULL;
-                       free_netdev(dev1);
+                       hw->ports = 1;
+                       if (dev1)
+                               free_netdev(dev1);
                }
        }
        pci_set_drvdata(pdev, hw);