sky2: Flow control frames recorded as dropped packets
[safe/jmp/linux-2.6] / drivers / net / pci-skeleton.c
index bf952ac..2027383 100644 (file)
@@ -105,7 +105,7 @@ IVc. Errata
 
 static char version[] __devinitdata =
 KERN_INFO NETDRV_DRIVER_LOAD_MSG "\n"
-KERN_INFO "  Support available from http://foo.com/bar/baz.html\n";
+"  Support available from http://foo.com/bar/baz.html\n";
 
 /* define to 1 to enable PIO instead of MMIO */
 #undef USE_IO_OPS
@@ -211,7 +211,7 @@ static struct {
 };
 
 
-static struct pci_device_id netdrv_pci_tbl[] = {
+static DEFINE_PCI_DEVICE_TABLE(netdrv_pci_tbl) = {
        {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
        {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, NETDRV_CB },
        {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMC1211TX },
@@ -728,6 +728,17 @@ err_out:
        return rc;
 }
 
+static const struct net_device_ops netdrv_netdev_ops = {
+       .ndo_open               = netdrv_open,
+       .ndo_stop               = netdrv_close,
+       .ndo_start_xmit         = netdrv_start_xmit,
+       .ndo_set_multicast_list = netdrv_set_rx_mode,
+       .ndo_do_ioctl           = netdrv_ioctl,
+       .ndo_tx_timeout         = netdrv_tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+};
 
 static int __devinit netdrv_init_one (struct pci_dev *pdev,
                                       const struct pci_device_id *ent)
@@ -769,19 +780,13 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev,
                ((u16 *) (dev->dev_addr))[i] =
                    le16_to_cpu (read_eeprom (ioaddr, i + 7, addr_len));
 
-       /* The Rtl8139-specific entries in the device structure. */
-       dev->open = netdrv_open;
-       dev->hard_start_xmit = netdrv_start_xmit;
-       dev->stop = netdrv_close;
-       dev->set_multicast_list = netdrv_set_rx_mode;
-       dev->do_ioctl = netdrv_ioctl;
-       dev->tx_timeout = netdrv_tx_timeout;
+       dev->netdev_ops = &netdrv_netdev_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
 
        dev->irq = pdev->irq;
        dev->base_addr = (unsigned long) ioaddr;
 
-       /* dev->priv/tp zeroed and aligned in alloc_etherdev */
+       /* netdev_priv()/tp zeroed and aligned in alloc_etherdev */
        tp = netdev_priv(dev);
 
        /* note: tp->chipset set in netdrv_init_board */
@@ -1220,8 +1225,8 @@ static void netdrv_timer (unsigned long data)
        mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);
 
        if (!tp->duplex_lock && mii_lpa != 0xffff) {
-               int duplex = (mii_lpa & LPA_100FULL)
-                   || (mii_lpa & 0x01C0) == 0x0040;
+               int duplex = ((mii_lpa & LPA_100FULL) ||
+                             (mii_lpa & 0x01C0) == 0x0040);
                if (tp->full_duplex != duplex) {
                        tp->full_duplex = duplex;
                        printk (KERN_INFO
@@ -1351,7 +1356,7 @@ static int netdrv_start_xmit (struct sk_buff *skb, struct net_device *dev)
        DPRINTK ("%s: Queued Tx packet at %p size %u to slot %d.\n",
                 dev->name, skb->data, skb->len, entry);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 
@@ -1565,7 +1570,6 @@ static void netdrv_rx_interrupt (struct net_device *dev,
 
                        skb->protocol = eth_type_trans (skb, dev);
                        netif_rx (skb);
-                       dev->last_rx = jiffies;
                        dev->stats.rx_bytes += pkt_size;
                        dev->stats.rx_packets++;
                } else {
@@ -1608,8 +1612,8 @@ static void netdrv_weird_interrupt (struct net_device *dev,
            (tp->drv_flags & HAS_LNK_CHNG)) {
                /* Really link-change on new chips. */
                int lpar = NETDRV_R16 (NWayLPAR);
-               int duplex = (lpar & 0x0100) || (lpar & 0x01C0) == 0x0040
-                               || tp->duplex_lock;
+               int duplex = ((lpar & 0x0100) || (lpar & 0x01C0) == 0x0040 ||
+                             tp->duplex_lock);
                if (tp->full_duplex != duplex) {
                        tp->full_duplex = duplex;
                        NETDRV_W8 (Cfg9346, Cfg9346_Unlock);
@@ -1780,11 +1784,6 @@ static int netdrv_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
                break;
 
        case SIOCSMIIREG:               /* Write MII PHY register. */
-               if (!capable (CAP_NET_ADMIN)) {
-                       rc = -EPERM;
-                       break;
-               }
-
                spin_lock_irqsave (&tp->lock, flags);
                mdio_write (dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
                spin_unlock_irqrestore (&tp->lock, flags);
@@ -1821,8 +1820,8 @@ static void netdrv_set_rx_mode (struct net_device *dev)
                    AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
                    AcceptAllPhys;
                mc_filter[1] = mc_filter[0] = 0xffffffff;
-       } else if ((dev->mc_count > multicast_filter_limit)
-                  || (dev->flags & IFF_ALLMULTI)) {
+       } else if ((dev->mc_count > multicast_filter_limit) ||
+                  (dev->flags & IFF_ALLMULTI)) {
                /* Too many to filter perfectly -- accept all multicasts. */
                rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
                mc_filter[1] = mc_filter[0] = 0xffffffff;