don't use __devexit_p to wrap sgiseeq_remove
[safe/jmp/linux-2.6] / drivers / net / wan / sbni.c
index f2d0712..1cc24a4 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 
+#include <net/net_namespace.h>
 #include <net/arp.h>
 
 #include <asm/io.h>
@@ -67,7 +68,6 @@
 /* device private data */
 
 struct net_local {
-       struct net_device_stats stats;
        struct timer_list       watchdog;
 
        spinlock_t      lock;
@@ -114,12 +114,12 @@ 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 *, struct pt_regs * );
+static irqreturn_t sbni_interrupt( int, void * );
 static void  handle_channel( struct net_device * );
 static int   recv_frame( struct net_device * );
 static void  send_frame( struct net_device * );
@@ -185,6 +185,7 @@ static unsigned int  netcard_portlist[ ] __initdata = {
        0x2b0, 0x2b4, 0x2c0, 0x2c4, 0x2d0, 0x2d4, 0x2e0, 0x2e4, 0x2f0, 0x2f4,
        0 };
 
+#define NET_LOCAL_LOCK(dev) (((struct net_local *)netdev_priv(dev))->lock)
 
 /*
  * Look for SBNI card which addr stored in dev->base_addr, if nonzero.
@@ -206,17 +207,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;
-
-       SET_MODULE_OWNER( dev );
+       dev->netdev_ops = &sbni_netdev_ops;
 }
 
 int __init sbni_probe(int unit)
@@ -229,6 +234,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);
 
@@ -288,7 +295,7 @@ static int __init sbni_init(struct net_device *dev)
 }
 
 
-int __init
+static int __init
 sbni_pci_probe( struct net_device  *dev )
 {
        struct pci_dev  *pdev = NULL;
@@ -319,12 +326,10 @@ sbni_pci_probe( struct net_device  *dev )
                                continue;
                }
 
-               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",
+               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"
+       " You should use the PCI BIOS setup to assign a valid IRQ line.\n",
                                pci_irq_line );
 
                /* avoiding re-enable dual adapters */
@@ -379,22 +384,23 @@ sbni_probe1( struct net_device  *dev,  unsigned long  ioaddr,  int  irq )
        dev->irq = irq;
        dev->base_addr = ioaddr;
 
-       /* Allocate dev->priv and fill in sbni-specific dev fields. */
-       nl = dev->priv;
+       /* Fill in sbni-specific dev fields. */
+       nl = netdev_priv(dev);
        if( !nl ) {
                printk( KERN_ERR "%s: unable to get memory!\n", dev->name );
                release_region( ioaddr, SBNI_IO_EXTENT );
                return NULL;
        }
 
-       dev->priv = nl;
        memset( nl, 0, sizeof(struct net_local) );
        spin_lock_init( &nl->lock );
 
        /* store MAC address (generate if that isn't known) */
-       *(u16 *)dev->dev_addr = htons( 0x00ff );
-       *(u32 *)(dev->dev_addr + 2) = htonl( 0x01000000 |
-               ( (mac[num]  ?  mac[num]  :  (u32)((long)dev->priv)) & 0x00ffffff) );
+       *(__be16 *)dev->dev_addr = htons( 0x00ff );
+       *(__be32 *)(dev->dev_addr + 2) = htonl( 0x01000000 |
+               ((mac[num] ?
+               mac[num] :
+               (u32)((long)netdev_priv(dev))) & 0x00ffffff));
 
        /* store link settings (speed, receive level ) */
        nl->maxframe  = DEFAULT_FRAME_LEN;
@@ -439,7 +445,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;
@@ -448,7 +454,7 @@ sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
 
        /* Looking for idle device in the list */
        for( p = dev;  p; ) {
-               struct net_local  *nl = (struct net_local *) p->priv;
+               struct net_local  *nl = netdev_priv(p);
                spin_lock( &nl->lock );
                if( nl->tx_buf_p  ||  (nl->state & FL_LINE_DOWN) ) {
                        p = nl->link;
@@ -458,19 +464,19 @@ 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  = (struct net_local *) dev->priv;
+       struct net_local  *nl  = netdev_priv(dev);
 
        netif_stop_queue( dev );
        spin_lock( &nl->lock );
@@ -478,7 +484,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 */
@@ -501,15 +507,15 @@ sbni_start_xmit( struct sk_buff  *skb,  struct net_device  *dev )
  */ 
 
 static irqreturn_t
-sbni_interrupt( int  irq,  void  *dev_id,  struct pt_regs  *regs )
+sbni_interrupt( int  irq,  void  *dev_id )
 {
-       struct net_device         *dev = (struct net_device *) dev_id;
-       struct net_local  *nl  = (struct net_local *) dev->priv;
+       struct net_device         *dev = dev_id;
+       struct net_local  *nl  = netdev_priv(dev);
        int     repeat;
 
        spin_lock( &nl->lock );
        if( nl->second )
-               spin_lock( &((struct net_local *) nl->second->priv)->lock );
+               spin_lock(&NET_LOCAL_LOCK(nl->second));
 
        do {
                repeat = 0;
@@ -523,7 +529,7 @@ sbni_interrupt( int  irq,  void  *dev_id,  struct pt_regs  *regs )
        } while( repeat );
 
        if( nl->second )
-               spin_unlock( &((struct net_local *)nl->second->priv)->lock );
+               spin_unlock(&NET_LOCAL_LOCK(nl->second));
        spin_unlock( &nl->lock );
        return IRQ_HANDLED;
 }
@@ -532,7 +538,7 @@ sbni_interrupt( int  irq,  void  *dev_id,  struct pt_regs  *regs )
 static void
 handle_channel( struct net_device  *dev )
 {
-       struct net_local        *nl    = (struct net_local *) dev->priv;
+       struct net_local        *nl    = netdev_priv(dev);
        unsigned long           ioaddr = dev->base_addr;
 
        int  req_ans;
@@ -541,7 +547,7 @@ handle_channel( struct net_device  *dev )
 #ifdef CONFIG_SBNI_MULTILINE
        /* Lock the master device because we going to change its local data */
        if( nl->state & FL_SLAVE )
-               spin_lock( &((struct net_local *) nl->master->priv)->lock );
+               spin_lock(&NET_LOCAL_LOCK(nl->master));
 #endif
 
        outb( (inb( ioaddr + CSR0 ) & ~EN_INT) | TR_REQ, ioaddr + CSR0 );
@@ -577,7 +583,7 @@ handle_channel( struct net_device  *dev )
 
 #ifdef CONFIG_SBNI_MULTILINE
        if( nl->state & FL_SLAVE )
-               spin_unlock( &((struct net_local *) nl->master->priv)->lock );
+               spin_unlock(&NET_LOCAL_LOCK(nl->master));
 #endif
 }
 
@@ -590,13 +596,13 @@ handle_channel( struct net_device  *dev )
 static int
 recv_frame( struct net_device  *dev )
 {
-       struct net_local  *nl   = (struct net_local *) dev->priv;
+       struct net_local  *nl   = netdev_priv(dev);
        unsigned long  ioaddr   = dev->base_addr;
 
        u32  crc = CRC32_INITIAL;
 
-       unsigned  framelen, frameno, ack;
-       unsigned  is_first, frame_ok;
+       unsigned  framelen = 0, frameno, ack;
+       unsigned  is_first, frame_ok = 0;
 
        if( check_fhdr( ioaddr, &framelen, &frameno, &ack, &is_first, &crc ) ) {
                frame_ok = framelen > 4
@@ -604,8 +610,7 @@ recv_frame( struct net_device  *dev )
                        :  skip_tail( ioaddr, framelen, crc );
                if( frame_ok )
                        interpret_ack( dev, ack );
-       } else
-               frame_ok = 0;
+       }
 
        outb( inb( ioaddr + CSR0 ) ^ CT_ZER, ioaddr + CSR0 );
        if( frame_ok ) {
@@ -625,7 +630,7 @@ recv_frame( struct net_device  *dev )
 static void
 send_frame( struct net_device  *dev )
 {
-       struct net_local  *nl    = (struct net_local *) dev->priv;
+       struct net_local  *nl    = netdev_priv(dev);
 
        u32  crc = CRC32_INITIAL;
 
@@ -682,7 +687,7 @@ do_send:
 static void
 download_data( struct net_device  *dev,  u32  *crc_p )
 {
-       struct net_local  *nl    = (struct net_local *) dev->priv;
+       struct net_local  *nl    = netdev_priv(dev);
        struct sk_buff    *skb   = nl->tx_buf_p;
 
        unsigned  len = min_t(unsigned int, skb->len - nl->outpos, nl->framelen);
@@ -701,7 +706,7 @@ static int
 upload_data( struct net_device  *dev,  unsigned  framelen,  unsigned  frameno,
             unsigned  is_first,  u32  crc )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        int  frame_ok;
 
@@ -723,13 +728,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 *) nl->master->priv)
-                               ->stats.rx_errors++,
-                       ((struct net_local *) nl->master->priv)
-                               ->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,27 +745,28 @@ upload_data( struct net_device  *dev,  unsigned  framelen,  unsigned  frameno,
                 */
                nl->wait_frameno = 0,
 #ifdef CONFIG_SBNI_MULTILINE
-               ((struct net_local *) nl->master->priv)->stats.rx_errors++,
-               ((struct net_local *) nl->master->priv)->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;
 }
 
 
-static __inline void
-send_complete( struct net_local  *nl )
+static inline void
+send_complete( struct net_device *dev )
 {
+       struct net_local  *nl = netdev_priv(dev);
+
 #ifdef CONFIG_SBNI_MULTILINE
-       ((struct net_local *) nl->master->priv)->stats.tx_packets++;
-       ((struct net_local *) nl->master->priv)->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 );
 
@@ -777,7 +781,7 @@ send_complete( struct net_local  *nl )
 static void
 interpret_ack( struct net_device  *dev,  unsigned  ack )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        if( ack == FRAME_SENT_OK ) {
                nl->state &= ~FL_NEED_RESEND;
@@ -790,7 +794,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
@@ -811,7 +815,7 @@ interpret_ack( struct net_device  *dev,  unsigned  ack )
 static int
 append_frame_to_pkt( struct net_device  *dev,  unsigned  framelen,  u32  crc )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        u8  *p;
 
@@ -842,7 +846,7 @@ append_frame_to_pkt( struct net_device  *dev,  unsigned  framelen,  u32  crc )
 static void
 prepare_to_send( struct sk_buff  *skb,  struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        unsigned int  len;
 
@@ -858,7 +862,7 @@ prepare_to_send( struct sk_buff  *skb,  struct net_device  *dev )
                len = SBNI_MIN_LEN;
 
        nl->tx_buf_p    = skb;
-       nl->tx_frameno  = (len + nl->maxframe - 1) / nl->maxframe;
+       nl->tx_frameno  = DIV_ROUND_UP(len, nl->maxframe);
        nl->framelen    = len < nl->maxframe  ?  len  :  nl->maxframe;
 
        outb( inb( dev->base_addr + CSR0 ) | TR_REQ,  dev->base_addr + CSR0 );
@@ -873,19 +877,17 @@ prepare_to_send( struct sk_buff  *skb,  struct net_device  *dev )
 static void
 drop_xmit_queue( struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        if( nl->tx_buf_p )
                dev_kfree_skb_any( nl->tx_buf_p ),
                nl->tx_buf_p = NULL,
 #ifdef CONFIG_SBNI_MULTILINE
-               ((struct net_local *) nl->master->priv)
-                       ->stats.tx_errors++,
-               ((struct net_local *) nl->master->priv)
-                       ->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;
@@ -905,7 +907,7 @@ drop_xmit_queue( struct net_device  *dev )
 static void
 send_frame_header( struct net_device  *dev,  u32  *crc_p )
 {
-       struct net_local  *nl  = (struct net_local *) dev->priv;
+       struct net_local  *nl  = netdev_priv(dev);
 
        u32  crc = *crc_p;
        u32  len_field = nl->framelen + 6;      /* CRC + frameno + reserved */
@@ -999,11 +1001,6 @@ get_rx_buf( struct net_device  *dev )
        if( !skb )
                return  NULL;
 
-#ifdef CONFIG_SBNI_MULTILINE
-       skb->dev = ((struct net_local *) dev->priv)->master;
-#else
-       skb->dev = dev;
-#endif
        skb_reserve( skb, 2 );          /* Align IP on longword boundaries */
        return  skb;
 }
@@ -1012,7 +1009,7 @@ get_rx_buf( struct net_device  *dev )
 static void
 indicate_pkt( struct net_device  *dev )
 {
-       struct net_local  *nl  = (struct net_local *) dev->priv;
+       struct net_local  *nl  = netdev_priv(dev);
        struct sk_buff    *skb = nl->rx_buf_p;
 
        skb_put( skb, nl->inppos );
@@ -1020,15 +1017,13 @@ indicate_pkt( struct net_device  *dev )
 #ifdef CONFIG_SBNI_MULTILINE
        skb->protocol = eth_type_trans( skb, nl->master );
        netif_rx( skb );
-       dev->last_rx = jiffies;
-       ++((struct net_local *) nl->master->priv)->stats.rx_packets;
-       ((struct net_local *) nl->master->priv)->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 );
-       dev->last_rx = jiffies;
-       ++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 */
 }
@@ -1045,7 +1040,7 @@ static void
 sbni_watchdog( unsigned long  arg )
 {
        struct net_device  *dev = (struct net_device *) arg;
-       struct net_local   *nl  = (struct net_local *) dev->priv;
+       struct net_local   *nl  = netdev_priv(dev);
        struct timer_list  *w   = &nl->watchdog; 
        unsigned long      flags;
        unsigned char      csr0;
@@ -1098,7 +1093,7 @@ static unsigned char  timeout_rxl_tab[] = {
 static void
 card_start( struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        nl->timer_ticks = CHANGE_LEVEL_START_TICKS;
        nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND);
@@ -1120,7 +1115,7 @@ card_start( struct net_device  *dev )
 static void
 change_level( struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        if( nl->delta_rxl == 0 )        /* do not auto-negotiate RxL */
                return;
@@ -1144,7 +1139,7 @@ change_level( struct net_device  *dev )
 static void
 timeout_change_level( struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        nl->cur_rxl_index = timeout_rxl_tab[ nl->timeout_rxl ];
        if( ++nl->timeout_rxl >= 4 )
@@ -1167,7 +1162,7 @@ timeout_change_level( struct net_device  *dev )
 static int
 sbni_open( struct net_device  *dev )
 {
-       struct net_local        *nl = (struct net_local *) dev->priv;
+       struct net_local        *nl = netdev_priv(dev);
        struct timer_list       *w  = &nl->watchdog;
 
        /*
@@ -1183,7 +1178,7 @@ sbni_open( struct net_device  *dev )
                                 ||  (*p)->base_addr == dev->base_addr - 4)
                            &&  (*p)->flags & IFF_UP ) {
 
-                               ((struct net_local *) ((*p)->priv))
+                               ((struct net_local *) (netdev_priv(*p)))
                                        ->second = dev;
                                printk( KERN_NOTICE "%s: using shared irq "
                                        "with %s\n", dev->name, (*p)->name );
@@ -1192,7 +1187,7 @@ sbni_open( struct net_device  *dev )
                        }
        }
 
-       if( request_irq(dev->irq, sbni_interrupt, SA_SHIRQ, dev->name, dev) ) {
+       if( request_irq(dev->irq, sbni_interrupt, IRQF_SHARED, dev->name, dev) ) {
                printk( KERN_ERR "%s: unable to get IRQ %d.\n",
                        dev->name, dev->irq );
                return  -EAGAIN;
@@ -1201,7 +1196,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 );
@@ -1223,7 +1218,7 @@ handler_attached:
 static int
 sbni_close( struct net_device  *dev )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv;
+       struct net_local  *nl = netdev_priv(dev);
 
        if( nl->second  &&  nl->second->flags & IFF_UP ) {
                printk( KERN_NOTICE "Secondary channel (%s) is active!\n",
@@ -1307,7 +1302,7 @@ sbni_card_probe( unsigned long  ioaddr )
 static int
 sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
 {
-       struct net_local  *nl = (struct net_local *) dev->priv; 
+       struct net_local  *nl = netdev_priv(dev);
        struct sbni_flags  flags;
        int  error = 0;
 
@@ -1324,7 +1319,7 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
                break;
 
        case  SIOCDEVRESINSTATS :
-               if( current->euid != 0 )        /* root only */
+               if (!capable(CAP_NET_ADMIN))
                        return  -EPERM;
                memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) );
                break;
@@ -1341,7 +1336,7 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
                break;
 
        case  SIOCDEVSHWSTATE :
-               if( current->euid != 0 )        /* root only */
+               if (!capable(CAP_NET_ADMIN))
                        return  -EPERM;
 
                spin_lock( &nl->lock );
@@ -1362,12 +1357,12 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
 #ifdef CONFIG_SBNI_MULTILINE
 
        case  SIOCDEVENSLAVE :
-               if( current->euid != 0 )        /* root only */
+               if (!capable(CAP_NET_ADMIN))
                        return  -EPERM;
 
                if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name ))
                        return -EFAULT;
-               slave_dev = dev_get_by_name( slave_name );
+               slave_dev = dev_get_by_name(&init_net, slave_name );
                if( !slave_dev  ||  !(slave_dev->flags & IFF_UP) ) {
                        printk( KERN_ERR "%s: trying to enslave non-active "
                                "device %s\n", dev->name, slave_name );
@@ -1377,7 +1372,7 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
                return  enslave( dev, slave_dev );
 
        case  SIOCDEVEMANSIPATE :
-               if( current->euid != 0 )        /* root only */
+               if (!capable(CAP_NET_ADMIN))
                        return  -EPERM;
 
                return  emancipate( dev );
@@ -1397,8 +1392,8 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
 static int
 enslave( struct net_device  *dev,  struct net_device  *slave_dev )
 {
-       struct net_local  *nl  = (struct net_local *) dev->priv;
-       struct net_local  *snl = (struct net_local *) slave_dev->priv;
+       struct net_local  *nl  = netdev_priv(dev);
+       struct net_local  *snl = netdev_priv(slave_dev);
 
        if( nl->state & FL_SLAVE )      /* This isn't master or free device */
                return  -EBUSY;
@@ -1417,7 +1412,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 */
 
@@ -1432,9 +1427,9 @@ enslave( struct net_device  *dev,  struct net_device  *slave_dev )
 static int
 emancipate( struct net_device  *dev )
 {
-       struct net_local   *snl = (struct net_local *) dev->priv;
+       struct net_local   *snl = netdev_priv(dev);
        struct net_device  *p   = snl->master;
-       struct net_local   *nl  = (struct net_local *) p->priv;
+       struct net_local   *nl  = netdev_priv(p);
 
        if( !(snl->state & FL_SLAVE) )
                return  -EINVAL;
@@ -1445,7 +1440,7 @@ emancipate( struct net_device  *dev )
 
        /* exclude from list */
        for(;;) {       /* must be in list */
-               struct net_local  *t = (struct net_local *) p->priv;
+               struct net_local  *t = netdev_priv(p);
                if( t->link == dev ) {
                        t->link = snl->link;
                        break;
@@ -1468,14 +1463,6 @@ emancipate( struct net_device  *dev )
 
 #endif
 
-
-static struct net_device_stats *
-sbni_get_stats( struct net_device  *dev )
-{
-       return  &((struct net_local *) dev->priv)->stats;
-}
-
-
 static void
 set_multicast_list( struct net_device  *dev )
 {
@@ -1524,17 +1511,18 @@ int __init init_module( void )
 }
 
 void
-cleanup_module( void )
+cleanup_module(void)
 {
-       struct net_device  *dev;
-       int  num;
+       int i;
 
-       for( num = 0;  num < SBNI_MAX_NUM_CARDS;  ++num )
-               if( (dev = sbni_cards[ num ]) != NULL ) {
-                       unregister_netdev( dev );
-                       release_region( dev->base_addr, SBNI_IO_EXTENT );
-                       free_netdev( dev );
+       for (i = 0;  i < SBNI_MAX_NUM_CARDS;  ++i) {
+               struct net_device *dev = sbni_cards[i];
+               if (dev != NULL) {
+                       unregister_netdev(dev);
+                       release_region(dev->base_addr, SBNI_IO_EXTENT);
+                       free_netdev(dev);
                }
+       }
 }
 
 #else  /* MODULE */