net: remove driver_data direct access of struct device
[safe/jmp/linux-2.6] / drivers / net / 3c523.c
index 23a3123..8f734d7 100644 (file)
@@ -308,7 +308,7 @@ static int elmc_open(struct net_device *dev)
 
 static int __init check586(struct net_device *dev, unsigned long where, unsigned size)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        char *iscp_addrs[2];
        int i = 0;
 
@@ -347,9 +347,9 @@ static int __init check586(struct net_device *dev, unsigned long where, unsigned
  * set iscp at the right place, called by elmc_probe and open586.
  */
 
-void alloc586(struct net_device *dev)
+static void alloc586(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        elmc_id_reset586();
        DELAY(2);
@@ -403,6 +403,20 @@ static int elmc_getinfo(char *buf, int slot, void *d)
        return len;
 }                              /* elmc_getinfo() */
 
+static const struct net_device_ops netdev_ops = {
+       .ndo_open               = elmc_open,
+       .ndo_stop               = elmc_close,
+       .ndo_get_stats          = elmc_get_stats,
+       .ndo_start_xmit         = elmc_send_packet,
+       .ndo_tx_timeout         = elmc_timeout,
+#ifdef ELMC_MULTICAST
+       .ndo_set_multicast_list = set_multicast_list,
+#endif
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 /*****************************************************************/
 
 static int __init do_elmc_probe(struct net_device *dev)
@@ -415,7 +429,7 @@ static int __init do_elmc_probe(struct net_device *dev)
        int i = 0;
        unsigned int size = 0;
        int retval;
-       struct priv *pr = dev->priv;
+       struct priv *pr = netdev_priv(dev);
 
        if (MCA_bus == 0) {
                return -ENODEV;
@@ -544,17 +558,8 @@ static int __init do_elmc_probe(struct net_device *dev)
        printk(KERN_INFO "%s: hardware address %pM\n",
               dev->name, dev->dev_addr);
 
-       dev->open = &elmc_open;
-       dev->stop = &elmc_close;
-       dev->get_stats = &elmc_get_stats;
-       dev->hard_start_xmit = &elmc_send_packet;
-       dev->tx_timeout = &elmc_timeout;
+       dev->netdev_ops = &netdev_ops;
        dev->watchdog_timeo = HZ;
-#ifdef ELMC_MULTICAST
-       dev->set_multicast_list = &set_multicast_list;
-#else
-       dev->set_multicast_list = NULL;
-#endif
        dev->ethtool_ops = &netdev_ethtool_ops;
 
        /* note that we haven't actually requested the IRQ from the kernel.
@@ -576,13 +581,14 @@ err_out:
        return retval;
 }
 
+#ifdef MODULE
 static void cleanup_card(struct net_device *dev)
 {
-       mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot, NULL, NULL);
+       mca_set_adapter_procfn(((struct priv *)netdev_priv(dev))->slot,
+                               NULL, NULL);
        release_region(dev->base_addr, ELMC_IO_EXTENT);
 }
-
-#ifndef MODULE
+#else
 struct net_device * __init elmc_probe(int unit)
 {
        struct net_device *dev = alloc_etherdev(sizeof(struct priv));
@@ -614,7 +620,7 @@ static int init586(struct net_device *dev)
        void *ptr;
        unsigned long s;
        int i, result = 0;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        volatile struct configure_cmd_struct *cfg_cmd;
        volatile struct iasetup_cmd_struct *ias_cmd;
        volatile struct tdr_cmd_struct *tdr_cmd;
@@ -850,7 +856,7 @@ static void *alloc_rfa(struct net_device *dev, void *ptr)
        volatile struct rfd_struct *rfd = (struct rfd_struct *) ptr;
        volatile struct rbd_struct *rbd;
        int i;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        memset((char *) rfd, 0, sizeof(struct rfd_struct) * p->num_recv_buffs);
        p->rfd_first = rfd;
@@ -911,7 +917,7 @@ elmc_interrupt(int irq, void *dev_id)
        }
        /* reading ELMC_CTRL also clears the INT bit. */
 
-       p = (struct priv *) dev->priv;
+       p = netdev_priv(dev);
 
        while ((stat = p->scb->status & STAT_MASK))
        {
@@ -967,7 +973,7 @@ static void elmc_rcv_int(struct net_device *dev)
        unsigned short totlen;
        struct sk_buff *skb;
        struct rbd_struct *rbd;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        for (; (status = p->rfd_top->status) & STAT_COMPL;) {
                rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
@@ -983,7 +989,6 @@ static void elmc_rcv_int(struct net_device *dev)
                                        skb_copy_to_linear_data(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen);
                                        skb->protocol = eth_type_trans(skb, dev);
                                        netif_rx(skb);
-                                       dev->last_rx = jiffies;
                                        dev->stats.rx_packets++;
                                        dev->stats.rx_bytes += totlen;
                                } else {
@@ -1011,7 +1016,7 @@ static void elmc_rcv_int(struct net_device *dev)
 
 static void elmc_rnr_int(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        dev->stats.rx_errors++;
 
@@ -1034,7 +1039,7 @@ static void elmc_rnr_int(struct net_device *dev)
 static void elmc_xmt_int(struct net_device *dev)
 {
        int status;
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        status = p->xmit_cmds[p->xmit_last]->cmd_status;
        if (!(status & STAT_COMPL)) {
@@ -1077,7 +1082,7 @@ static void elmc_xmt_int(struct net_device *dev)
 
 static void startrecv586(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        p->scb->rfa_offset = make16(p->rfd_first);
        p->scb->cmd = RUC_START;
@@ -1091,7 +1096,7 @@ static void startrecv586(struct net_device *dev)
 
 static void elmc_timeout(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        /* COMMAND-UNIT active? */
        if (p->scb->status & CU_ACTIVE) {
 #ifdef DEBUG
@@ -1127,7 +1132,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
 #ifndef NO_NOPCOMMANDS
        int next_nop;
 #endif
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
 
        netif_stop_queue(dev);
 
@@ -1198,7 +1203,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
 
 static struct net_device_stats *elmc_get_stats(struct net_device *dev)
 {
-       struct priv *p = (struct priv *) dev->priv;
+       struct priv *p = netdev_priv(dev);
        unsigned short crc, aln, rsc, ovrn;
 
        crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */