USB: remove leftover references to udev->autosuspend_disabled
[safe/jmp/linux-2.6] / drivers / net / wan / sbni.c
index 78f7bc9..cff13a9 100644 (file)
@@ -43,7 +43,6 @@
 #include <linux/fcntl.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
@@ -68,7 +67,6 @@
 /* device private data */
 
 struct net_local {
-       struct net_device_stats stats;
        struct timer_list       watchdog;
 
        spinlock_t      lock;
@@ -115,9 +113,9 @@ static int  sbni_pci_probe( struct net_device  * );
 static struct net_device  *sbni_probe1(struct net_device *, unsigned long, int);
 static int  sbni_open( struct net_device * );
 static int  sbni_close( struct net_device * );
-static int  sbni_start_xmit( struct sk_buff *, struct net_device * );
+static netdev_tx_t sbni_start_xmit(struct sk_buff *,
+                                        struct net_device * );
 static int  sbni_ioctl( struct net_device *, struct ifreq *, int );
-static struct net_device_stats  *sbni_get_stats( struct net_device * );
 static void  set_multicast_list( struct net_device * );
 
 static irqreturn_t sbni_interrupt( int, void * );
@@ -196,9 +194,9 @@ static unsigned int  netcard_portlist[ ] __initdata = {
 static inline int __init
 sbni_isa_probe( struct net_device  *dev )
 {
-       if( dev->base_addr > 0x1ff
-           &&  request_region( dev->base_addr, SBNI_IO_EXTENT, dev->name )
-           &&  sbni_probe1( dev, dev->base_addr, dev->irq ) )
+       if( dev->base_addr > 0x1ff &&
+           request_region( dev->base_addr, SBNI_IO_EXTENT, dev->name ) &&
+           sbni_probe1( dev, dev->base_addr, dev->irq ) )
 
                return  0;
        else {
@@ -208,15 +206,21 @@ sbni_isa_probe( struct net_device  *dev )
        }
 }
 
+static const struct net_device_ops sbni_netdev_ops = {
+       .ndo_open               = sbni_open,
+       .ndo_stop               = sbni_close,
+       .ndo_start_xmit         = sbni_start_xmit,
+       .ndo_set_multicast_list = set_multicast_list,
+       .ndo_do_ioctl           = sbni_ioctl,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 static void __init sbni_devsetup(struct net_device *dev)
 {
        ether_setup( dev );
-       dev->open               = &sbni_open;
-       dev->stop               = &sbni_close;
-       dev->hard_start_xmit    = &sbni_start_xmit;
-       dev->get_stats          = &sbni_get_stats;
-       dev->set_multicast_list = &set_multicast_list;
-       dev->do_ioctl           = &sbni_ioctl;
+       dev->netdev_ops = &sbni_netdev_ops;
 }
 
 int __init sbni_probe(int unit)
@@ -229,6 +233,8 @@ int __init sbni_probe(int unit)
        if (!dev)
                return -ENOMEM;
 
+       dev->netdev_ops = &sbni_netdev_ops;
+
        sprintf(dev->name, "sbni%d", unit);
        netdev_boot_setup_check(dev);
 
@@ -279,8 +285,8 @@ static int __init sbni_init(struct net_device *dev)
 
        for( i = 0;  netcard_portlist[ i ];  ++i ) {
                int  ioaddr = netcard_portlist[ i ];
-               if( request_region( ioaddr, SBNI_IO_EXTENT, dev->name )
-                   &&  sbni_probe1( dev, ioaddr, 0 ))
+               if( request_region( ioaddr, SBNI_IO_EXTENT, dev->name ) &&
+                   sbni_probe1( dev, ioaddr, 0 ))
                        return 0;
        }
 
@@ -299,9 +305,9 @@ sbni_pci_probe( struct net_device  *dev )
                unsigned long  pci_ioaddr;
                u16  subsys;
 
-               if( pdev->vendor != SBNI_PCI_VENDOR
-                   &&  pdev->device != SBNI_PCI_DEVICE )
-                               continue;
+               if( pdev->vendor != SBNI_PCI_VENDOR &&
+                   pdev->device != SBNI_PCI_DEVICE )
+                       continue;
 
                pci_ioaddr = pci_resource_start( pdev, 0 );
                pci_irq_line = pdev->irq;
@@ -320,11 +326,9 @@ sbni_pci_probe( struct net_device  *dev )
                }
 
                if (pci_irq_line <= 0 || pci_irq_line >= nr_irqs)
-                       printk( KERN_WARNING "  WARNING: The PCI BIOS assigned "
-                               "this PCI card to IRQ %d, which is unlikely "
-                               "to work!.\n"
-                               KERN_WARNING " You should use the PCI BIOS "
-                               "setup to assign a valid IRQ line.\n",
+                       printk( KERN_WARNING
+       "  WARNING: The PCI BIOS assigned this PCI card to IRQ %d, which is unlikely to work!.\n"
+       " You should use the PCI BIOS setup to assign a valid IRQ line.\n",
                                pci_irq_line );
 
                /* avoiding re-enable dual adapters */
@@ -440,7 +444,7 @@ sbni_probe1( struct net_device  *dev,  unsigned long  ioaddr,  int  irq )
 
 #ifdef CONFIG_SBNI_MULTILINE
 
-static int
+static netdev_tx_t
 sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
 {
        struct net_device  *p;
@@ -459,16 +463,16 @@ sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
                        prepare_to_send( skb, p );
                        spin_unlock( &nl->lock );
                        netif_start_queue( dev );
-                       return  0;
+                       return NETDEV_TX_OK;
                }
        }
 
-       return  1;
+       return NETDEV_TX_BUSY;
 }
 
 #else  /* CONFIG_SBNI_MULTILINE */
 
-static int
+static netdev_tx_t
 sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
 {
        struct net_local  *nl  = netdev_priv(dev);
@@ -479,7 +483,7 @@ sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
        prepare_to_send( skb, dev );
 
        spin_unlock( &nl->lock );
-       return  0;
+       return NETDEV_TX_OK;
 }
 
 #endif /* CONFIG_SBNI_MULTILINE */
@@ -723,13 +727,11 @@ upload_data( struct net_device  *dev,  unsigned  framelen,  unsigned  frameno,
                        nl->wait_frameno = 0,
                        nl->inppos = 0,
 #ifdef CONFIG_SBNI_MULTILINE
-                       ((struct net_local *)netdev_priv(nl->master))
-                               ->stats.rx_errors++,
-                       ((struct net_local *)netdev_priv(nl->master))
-                               ->stats.rx_missed_errors++;
+                       nl->master->stats.rx_errors++,
+                       nl->master->stats.rx_missed_errors++;
 #else
-                       nl->stats.rx_errors++,
-                       nl->stats.rx_missed_errors++;
+                       dev->stats.rx_errors++,
+                       dev->stats.rx_missed_errors++;
 #endif
                        /* now skip all frames until is_first != 0 */
        } else
@@ -742,13 +744,11 @@ upload_data( struct net_device  *dev,  unsigned  framelen,  unsigned  frameno,
                 */
                nl->wait_frameno = 0,
 #ifdef CONFIG_SBNI_MULTILINE
-               ((struct net_local *)netdev_priv(nl->master))
-                       ->stats.rx_errors++,
-               ((struct net_local *)netdev_priv(nl->master))
-                       ->stats.rx_crc_errors++;
+               nl->master->stats.rx_errors++,
+               nl->master->stats.rx_crc_errors++;
 #else
-               nl->stats.rx_errors++,
-               nl->stats.rx_crc_errors++;
+               dev->stats.rx_errors++,
+               dev->stats.rx_crc_errors++;
 #endif
 
        return  frame_ok;
@@ -756,15 +756,16 @@ upload_data( struct net_device  *dev,  unsigned  framelen,  unsigned  frameno,
 
 
 static inline void
-send_complete( struct net_local  *nl )
+send_complete( struct net_device *dev )
 {
+       struct net_local  *nl = netdev_priv(dev);
+
 #ifdef CONFIG_SBNI_MULTILINE
-       ((struct net_local *)netdev_priv(nl->master))->stats.tx_packets++;
-       ((struct net_local *)netdev_priv(nl->master))->stats.tx_bytes
-               += nl->tx_buf_p->len;
+       nl->master->stats.tx_packets++;
+       nl->master->stats.tx_bytes += nl->tx_buf_p->len;
 #else
-       nl->stats.tx_packets++;
-       nl->stats.tx_bytes += nl->tx_buf_p->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes += nl->tx_buf_p->len;
 #endif
        dev_kfree_skb_irq( nl->tx_buf_p );
 
@@ -792,7 +793,7 @@ interpret_ack( struct net_device  *dev,  unsigned  ack )
                                                   nl->maxframe,
                                                   nl->tx_buf_p->len - nl->outpos);
                        else
-                               send_complete( nl ),
+                               send_complete( dev ),
 #ifdef CONFIG_SBNI_MULTILINE
                                netif_wake_queue( nl->master );
 #else
@@ -881,13 +882,11 @@ drop_xmit_queue( struct net_device  *dev )
                dev_kfree_skb_any( nl->tx_buf_p ),
                nl->tx_buf_p = NULL,
 #ifdef CONFIG_SBNI_MULTILINE
-               ((struct net_local *)netdev_priv(nl->master))
-                       ->stats.tx_errors++,
-               ((struct net_local *)netdev_priv(nl->master))
-                       ->stats.tx_carrier_errors++;
+               nl->master->stats.tx_errors++,
+               nl->master->stats.tx_carrier_errors++;
 #else
-               nl->stats.tx_errors++,
-               nl->stats.tx_carrier_errors++;
+               dev->stats.tx_errors++,
+               dev->stats.tx_carrier_errors++;
 #endif
 
        nl->tx_frameno  = 0;
@@ -977,8 +976,8 @@ check_fhdr( u32  ioaddr,  u32  *framelen,  u32  *frameno,  u32  *ack,
        *ack = *framelen & FRAME_ACK_MASK;
        *is_first = (*framelen & FRAME_FIRST) != 0;
 
-       if( (*framelen &= FRAME_LEN_MASK) < 6
-           ||  *framelen > SBNI_MAX_FRAME - 3 )
+       if( (*framelen &= FRAME_LEN_MASK) < 6 ||
+           *framelen > SBNI_MAX_FRAME - 3 )
                return  0;
 
        value = inb( ioaddr + DAT );
@@ -1017,14 +1016,13 @@ indicate_pkt( struct net_device  *dev )
 #ifdef CONFIG_SBNI_MULTILINE
        skb->protocol = eth_type_trans( skb, nl->master );
        netif_rx( skb );
-       ++((struct net_local *)netdev_priv(nl->master))->stats.rx_packets;
-       ((struct net_local *)netdev_priv(nl->master))->stats.rx_bytes +=
-               nl->inppos;
+       ++nl->master->stats.rx_packets;
+       nl->master->stats.rx_bytes += nl->inppos;
 #else
        skb->protocol = eth_type_trans( skb, dev );
        netif_rx( skb );
-       ++nl->stats.rx_packets;
-       nl->stats.rx_bytes += nl->inppos;
+       ++dev->stats.rx_packets;
+       dev->stats.rx_bytes += nl->inppos;
 #endif
        nl->rx_buf_p = NULL;    /* protocol driver will clear this sk_buff */
 }
@@ -1174,10 +1172,10 @@ sbni_open( struct net_device  *dev )
        if( dev->base_addr < 0x400 ) {          /* ISA only */
                struct net_device  **p = sbni_cards;
                for( ;  *p  &&  p < sbni_cards + SBNI_MAX_NUM_CARDS;  ++p )
-                       if( (*p)->irq == dev->irq
-                           &&  ((*p)->base_addr == dev->base_addr + 4
-                                ||  (*p)->base_addr == dev->base_addr - 4)
-                           &&  (*p)->flags & IFF_UP ) {
+                       if( (*p)->irq == dev->irq &&
+                           ((*p)->base_addr == dev->base_addr + 4 ||
+                            (*p)->base_addr == dev->base_addr - 4) &&
+                           (*p)->flags & IFF_UP ) {
 
                                ((struct net_local *) (netdev_priv(*p)))
                                        ->second = dev;
@@ -1197,7 +1195,7 @@ sbni_open( struct net_device  *dev )
 handler_attached:
 
        spin_lock( &nl->lock );
-       memset( &nl->stats, 0, sizeof(struct net_device_stats) );
+       memset( &dev->stats, 0, sizeof(struct net_device_stats) );
        memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) );
 
        card_start( dev );
@@ -1413,7 +1411,7 @@ enslave( struct net_device  *dev,  struct net_device  *slave_dev )
 
        /* Summary statistics of MultiLine operation will be stored
           in master's counters */
-       memset( &snl->stats, 0, sizeof(struct net_device_stats) );
+       memset( &slave_dev->stats, 0, sizeof(struct net_device_stats) );
        netif_stop_queue( slave_dev );
        netif_wake_queue( dev );        /* Now we are able to transmit */
 
@@ -1464,14 +1462,6 @@ emancipate( struct net_device  *dev )
 
 #endif
 
-
-static struct net_device_stats *
-sbni_get_stats( struct net_device  *dev )
-{
-       return  &((struct net_local *)netdev_priv(dev))->stats;
-}
-
-
 static void
 set_multicast_list( struct net_device  *dev )
 {