mac80211: fix paged defragmentation
[safe/jmp/linux-2.6] / net / atm / lec.c
index d2b44e9..5da5753 100644 (file)
@@ -1,9 +1,11 @@
 /*
- * lec.c: Lan Emulation driver 
+ * lec.c: Lan Emulation driver
  *
  * Marko Kiiskila <mkiiskila@yahoo.com>
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
+
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <linux/capability.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
 #include <asm/byteorder.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <net/arp.h>
 #include <net/dst.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
-#include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 
 /* TokenRing if needed */
@@ -35,7 +36,6 @@
 
 /* Proxy LEC knows about bridging */
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
-#include <linux/if_bridge.h>
 #include "../bridge/br_private.h"
 
 static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
@@ -49,12 +49,6 @@ static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
 #include "lec_arpc.h"
 #include "resources.h"
 
-#if 0
-#define DPRINTK printk
-#else
-#define DPRINTK(format,args...)
-#endif
-
 #define DUMP_PACKETS 0         /*
                                 * 0 = None,
                                 * 1 = 30 first bytes
@@ -67,46 +61,59 @@ static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
                                 */
 
 static int lec_open(struct net_device *dev);
-static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
+                                 struct net_device *dev);
 static int lec_close(struct net_device *dev);
-static struct net_device_stats *lec_get_stats(struct net_device *dev);
-static void lec_init(struct net_device *dev);
 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
-                                         unsigned char *mac_addr);
+                                         const unsigned char *mac_addr);
 static int lec_arp_remove(struct lec_priv *priv,
                          struct lec_arp_table *to_remove);
 /* LANE2 functions */
-static void lane2_associate_ind(struct net_device *dev, u8 *mac_address,
-                               u8 *tlvs, u32 sizeoftlvs);
-static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
+static void lane2_associate_ind(struct net_device *dev, const u8 *mac_address,
+                               const u8 *tlvs, u32 sizeoftlvs);
+static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
                         u8 **tlvs, u32 *sizeoftlvs);
-static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
-                              u8 *tlvs, u32 sizeoftlvs);
+static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
+                              const u8 *tlvs, u32 sizeoftlvs);
 
-static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
+static int lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
                           unsigned long permanent);
 static void lec_arp_check_empties(struct lec_priv *priv,
                                  struct atm_vcc *vcc, struct sk_buff *skb);
 static void lec_arp_destroy(struct lec_priv *priv);
 static void lec_arp_init(struct lec_priv *priv);
 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
-                                      unsigned char *mac_to_find,
+                                      const unsigned char *mac_to_find,
                                       int is_rdesc,
                                       struct lec_arp_table **ret_entry);
-static void lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
-                          unsigned char *atm_addr, unsigned long remoteflag,
+static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
+                          const unsigned char *atm_addr,
+                          unsigned long remoteflag,
                           unsigned int targetless_le_arp);
 static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id);
 static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc);
 static void lec_set_flush_tran_id(struct lec_priv *priv,
-                                 unsigned char *atm_addr,
+                                 const unsigned char *atm_addr,
                                  unsigned long tran_id);
-static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
+static void lec_vcc_added(struct lec_priv *priv,
+                         const struct atmlec_ioc *ioc_data,
                          struct atm_vcc *vcc,
-                         void (*old_push) (struct atm_vcc *vcc,
-                                           struct sk_buff *skb));
+                         void (*old_push)(struct atm_vcc *vcc,
+                                          struct sk_buff *skb));
 static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
 
+/* must be done under lec_arp_lock */
+static inline void lec_arp_hold(struct lec_arp_table *entry)
+{
+       atomic_inc(&entry->usage);
+}
+
+static inline void lec_arp_put(struct lec_arp_table *entry)
+{
+       if (atomic_dec_and_test(&entry->usage))
+               kfree(entry);
+}
+
 static struct lane2_ops lane2_ops = {
        lane2_resolve,          /* resolve,             spec 3.1.3 */
        lane2_associate_req,    /* associate_req,       spec 3.1.4 */
@@ -144,9 +151,10 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
                mesg = (struct atmlec_msg *)skb2->data;
                mesg->type = l_topology_change;
                buff += 4;
-               mesg->content.normal.flag = *buff & 0x01;       /* 0x01 is topology change */
+               mesg->content.normal.flag = *buff & 0x01;
+                                       /* 0x01 is topology change */
 
-               priv = (struct lec_priv *)dev->priv;
+               priv = netdev_priv(dev);
                atm_force_charge(priv->lecd, skb2->truesize);
                sk = sk_atm(priv->lecd);
                skb_queue_tail(&sk->sk_receive_queue, skb2);
@@ -170,7 +178,7 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
 static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
 {
        struct trh_hdr *trh;
-       int riflen, num_rdsc;
+       unsigned int riflen, num_rdsc;
 
        trh = (struct trh_hdr *)packet;
        if (trh->daddr[0] & (uint8_t) 0x80)
@@ -191,9 +199,9 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
        memset(rdesc, 0, ETH_ALEN);
        /* offset 4 comes from LAN destination field in LE control frames */
        if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT))
-               memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t));
+               memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(__be16));
        else {
-               memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t));
+               memcpy(&rdesc[4], &trh->rseg[1], sizeof(__be16));
                rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
        }
 
@@ -212,41 +220,42 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
 
 static int lec_open(struct net_device *dev)
 {
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
-
        netif_start_queue(dev);
-       memset(&priv->stats, 0, sizeof(struct net_device_stats));
+       memset(&dev->stats, 0, sizeof(struct net_device_stats));
 
        return 0;
 }
 
-static __inline__ void
-lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv)
+static void
+lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
 {
+       struct net_device *dev = skb->dev;
+
        ATM_SKB(skb)->vcc = vcc;
        ATM_SKB(skb)->atm_options = vcc->atm_options;
 
        atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
        if (vcc->send(vcc, skb) < 0) {
-               priv->stats.tx_dropped++;
+               dev->stats.tx_dropped++;
                return;
        }
 
-       priv->stats.tx_packets++;
-       priv->stats.tx_bytes += skb->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes += skb->len;
 }
 
 static void lec_tx_timeout(struct net_device *dev)
 {
-       printk(KERN_INFO "%s: tx timeout\n", dev->name);
+       pr_info("%s\n", dev->name);
        dev->trans_start = jiffies;
        netif_wake_queue(dev);
 }
 
-static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
+                                 struct net_device *dev)
 {
        struct sk_buff *skb2;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
        struct lecdatahdr_8023 *lec_h;
        struct atm_vcc *vcc;
        struct lec_arp_table *entry;
@@ -256,22 +265,19 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
        unsigned char rdesc[ETH_ALEN];  /* Token Ring route descriptor */
 #endif
        int is_rdesc;
-#if DUMP_PACKETS > 0
-       char buf[300];
-       int i = 0;
-#endif /* DUMP_PACKETS >0 */
 
-       DPRINTK("lec_start_xmit called\n");
+       pr_debug("called\n");
        if (!priv->lecd) {
-               printk("%s:No lecd attached\n", dev->name);
-               priv->stats.tx_errors++;
+               pr_info("%s:No lecd attached\n", dev->name);
+               dev->stats.tx_errors++;
                netif_stop_queue(dev);
-               return -EUNATCH;
+               kfree_skb(skb);
+               return NETDEV_TX_OK;
        }
 
-       DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
-               (long)skb->head, (long)skb->data, (long)skb->tail,
-               (long)skb->end);
+       pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
+                (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb),
+                (long)skb_end_pointer(skb));
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
        if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0)
                lec_handle_bridge(skb, dev);
@@ -279,12 +285,11 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* Make sure we have room for lec_id */
        if (skb_headroom(skb) < 2) {
-
-               DPRINTK("lec_start_xmit: reallocating skb\n");
+               pr_debug("reallocating skb\n");
                skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
                kfree_skb(skb);
                if (skb2 == NULL)
-                       return 0;
+                       return NETDEV_TX_OK;
                skb = skb2;
        }
        skb_push(skb, 2);
@@ -302,28 +307,22 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
                skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
                kfree_skb(skb);
                if (skb2 == NULL)
-                       return 0;
+                       return NETDEV_TX_OK;
                skb = skb2;
        }
 #endif
 
-#if DUMP_PACKETS > 0
-       printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name,
-              skb->len, priv->lecid);
 #if DUMP_PACKETS >= 2
-       for (i = 0; i < skb->len && i < 99; i++) {
-               sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
-       }
+#define MAX_DUMP_SKB 99
 #elif DUMP_PACKETS >= 1
-       for (i = 0; i < skb->len && i < 30; i++) {
-               sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
-       }
+#define MAX_DUMP_SKB 30
+#endif
+#if DUMP_PACKETS >= 1
+       printk(KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n",
+              dev->name, skb->len, priv->lecid);
+       print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
+                      skb->data, min(skb->len, MAX_DUMP_SKB), true);
 #endif /* DUMP_PACKETS >= 1 */
-       if (i == skb->len)
-               printk("%s\n", buf);
-       else
-               printk("%s...\n", buf);
-#endif /* DUMP_PACKETS > 0 */
 
        /* Minimum ethernet-frame size */
 #ifdef CONFIG_TR
@@ -339,8 +338,8 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
                                               GFP_ATOMIC);
                        dev_kfree_skb(skb);
                        if (skb2 == NULL) {
-                               priv->stats.tx_dropped++;
-                               return 0;
+                               dev->stats.tx_dropped++;
+                               return NETDEV_TX_OK;
                        }
                        skb = skb2;
                }
@@ -361,43 +360,32 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
 #endif
        entry = NULL;
        vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
-       DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name,
-               vcc, vcc ? vcc->flags : 0, entry);
+       pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n",
+                dev->name, vcc, vcc ? vcc->flags : 0, entry);
        if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) {
                if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
-                       DPRINTK("%s:lec_start_xmit: queuing packet, ",
-                               dev->name);
-                       DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
-                               lec_h->h_dest[0], lec_h->h_dest[1],
-                               lec_h->h_dest[2], lec_h->h_dest[3],
-                               lec_h->h_dest[4], lec_h->h_dest[5]);
+                       pr_debug("%s:queuing packet, MAC address %pM\n",
+                                dev->name, lec_h->h_dest);
                        skb_queue_tail(&entry->tx_wait, skb);
                } else {
-                       DPRINTK
-                           ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ",
-                            dev->name);
-                       DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
-                               lec_h->h_dest[0], lec_h->h_dest[1],
-                               lec_h->h_dest[2], lec_h->h_dest[3],
-                               lec_h->h_dest[4], lec_h->h_dest[5]);
-                       priv->stats.tx_dropped++;
+                       pr_debug("%s:tx queue full or no arp entry, dropping, MAC address: %pM\n",
+                                dev->name, lec_h->h_dest);
+                       dev->stats.tx_dropped++;
                        dev_kfree_skb(skb);
                }
-               return 0;
+               goto out;
        }
 #if DUMP_PACKETS > 0
-       printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci);
+       printk(KERN_DEBUG "%s:sending to vpi:%d vci:%d\n",
+              dev->name, vcc->vpi, vcc->vci);
 #endif /* DUMP_PACKETS > 0 */
 
        while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
-               DPRINTK("lec.c: emptying tx queue, ");
-               DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
-                       lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
-                       lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
-               lec_send(vcc, skb2, priv);
+               pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest);
+               lec_send(vcc, skb2);
        }
 
-       lec_send(vcc, skb, priv);
+       lec_send(vcc, skb);
 
        if (!atm_may_send(vcc, 0)) {
                struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
@@ -415,8 +403,11 @@ static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        netif_wake_queue(dev);
        }
 
+out:
+       if (entry)
+               lec_arp_put(entry);
        dev->trans_start = jiffies;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* The inverse routine to net_open(). */
@@ -426,20 +417,11 @@ static int lec_close(struct net_device *dev)
        return 0;
 }
 
-/*
- * Get the current statistics.
- * This may be called with the card open or closed.
- */
-static struct net_device_stats *lec_get_stats(struct net_device *dev)
-{
-       return &((struct lec_priv *)dev->priv)->stats;
-}
-
 static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
 {
        unsigned long flags;
        struct net_device *dev = (struct net_device *)vcc->proto_data;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
        struct atmlec_msg *mesg;
        struct lec_arp_table *entry;
        int i;
@@ -449,17 +431,15 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
        mesg = (struct atmlec_msg *)skb->data;
        tmp = skb->data;
        tmp += sizeof(struct atmlec_msg);
-       DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
+       pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
        switch (mesg->type) {
        case l_set_mac_addr:
-               for (i = 0; i < 6; i++) {
+               for (i = 0; i < 6; i++)
                        dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
-               }
                break;
        case l_del_mac_addr:
-               for (i = 0; i < 6; i++) {
+               for (i = 0; i < 6; i++)
                        dev->dev_addr[i] = 0;
-               }
                break;
        case l_addr_delete:
                lec_addr_delete(priv, mesg->content.normal.atm_addr,
@@ -485,10 +465,10 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
                               mesg->content.normal.atm_addr,
                               mesg->content.normal.flag,
                               mesg->content.normal.targetless_le_arp);
-               DPRINTK("lec: in l_arp_update\n");
+               pr_debug("in l_arp_update\n");
                if (mesg->sizeoftlvs != 0) {    /* LANE2 3.1.5 */
-                       DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n",
-                               mesg->sizeoftlvs);
+                       pr_debug("LANE2 3.1.5, got tlvs, size %d\n",
+                                mesg->sizeoftlvs);
                        lane2_associate_ind(dev, mesg->content.normal.mac_addr,
                                            tmp, mesg->sizeoftlvs);
                }
@@ -507,13 +487,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
                priv->flush_timeout = (mesg->content.config.flush_timeout * HZ);
                priv->path_switching_delay =
                    (mesg->content.config.path_switching_delay * HZ);
-               priv->lane_version = mesg->content.config.lane_version; /* LANE2 */
+               priv->lane_version = mesg->content.config.lane_version;
+                                       /* LANE2 */
                priv->lane2_ops = NULL;
                if (priv->lane_version > 1)
                        priv->lane2_ops = &lane2_ops;
-               if (dev->change_mtu(dev, mesg->content.config.mtu))
-                       printk("%s: change_mtu to %d failed\n", dev->name,
-                              mesg->content.config.mtu);
+               if (dev_set_mtu(dev, mesg->content.config.mtu))
+                       pr_info("%s: change_mtu to %d failed\n",
+                               dev->name, mesg->content.config.mtu);
                priv->is_proxy = mesg->content.config.is_proxy;
                break;
        case l_flush_tran_id:
@@ -526,54 +507,35 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
                break;
        case l_should_bridge:
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
-               {
-                       struct net_bridge_fdb_entry *f;
-
-                       DPRINTK
-                           ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
-                            dev->name, mesg->content.proxy.mac_addr[0],
-                            mesg->content.proxy.mac_addr[1],
-                            mesg->content.proxy.mac_addr[2],
-                            mesg->content.proxy.mac_addr[3],
-                            mesg->content.proxy.mac_addr[4],
-                            mesg->content.proxy.mac_addr[5]);
-
-                       if (br_fdb_get_hook == NULL || dev->br_port == NULL)
-                               break;
+       {
+               pr_debug("%s: bridge zeppelin asks about %pM\n",
+                        dev->name, mesg->content.proxy.mac_addr);
 
-                       f = br_fdb_get_hook(dev->br_port->br,
-                                           mesg->content.proxy.mac_addr);
-                       if (f != NULL && f->dst->dev != dev
-                           && f->dst->state == BR_STATE_FORWARDING) {
-                               /* hit from bridge table, send LE_ARP_RESPONSE */
-                               struct sk_buff *skb2;
-                               struct sock *sk;
-
-                               DPRINTK
-                                   ("%s: entry found, responding to zeppelin\n",
-                                    dev->name);
-                               skb2 =
-                                   alloc_skb(sizeof(struct atmlec_msg),
-                                             GFP_ATOMIC);
-                               if (skb2 == NULL) {
-                                       br_fdb_put_hook(f);
-                                       break;
-                               }
-                               skb2->len = sizeof(struct atmlec_msg);
-                               memcpy(skb2->data, mesg,
-                                      sizeof(struct atmlec_msg));
-                               atm_force_charge(priv->lecd, skb2->truesize);
-                               sk = sk_atm(priv->lecd);
-                               skb_queue_tail(&sk->sk_receive_queue, skb2);
-                               sk->sk_data_ready(sk, skb2->len);
-                       }
-                       if (f != NULL)
-                               br_fdb_put_hook(f);
+               if (br_fdb_test_addr_hook == NULL)
+                       break;
+
+               if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) {
+                       /* hit from bridge table, send LE_ARP_RESPONSE */
+                       struct sk_buff *skb2;
+                       struct sock *sk;
+
+                       pr_debug("%s: entry found, responding to zeppelin\n",
+                                dev->name);
+                       skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
+                       if (skb2 == NULL)
+                               break;
+                       skb2->len = sizeof(struct atmlec_msg);
+                       skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
+                       atm_force_charge(priv->lecd, skb2->truesize);
+                       sk = sk_atm(priv->lecd);
+                       skb_queue_tail(&sk->sk_receive_queue, skb2);
+                       sk->sk_data_ready(sk, skb2->len);
                }
+       }
 #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
                break;
        default:
-               printk("%s: Unknown message type %d\n", dev->name, mesg->type);
+               pr_info("%s: Unknown message type %d\n", dev->name, mesg->type);
                dev_kfree_skb(skb);
                return -EINVAL;
        }
@@ -585,7 +547,7 @@ static void lec_atm_close(struct atm_vcc *vcc)
 {
        struct sk_buff *skb;
        struct net_device *dev = (struct net_device *)vcc->proto_data;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
 
        priv->lecd = NULL;
        /* Do something needful? */
@@ -594,14 +556,13 @@ static void lec_atm_close(struct atm_vcc *vcc)
        lec_arp_destroy(priv);
 
        if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
-               printk("%s lec_atm_close: closing with messages pending\n",
-                      dev->name);
-       while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) {
+               pr_info("%s closing with messages pending\n", dev->name);
+       while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) {
                atm_return(vcc, skb->truesize);
                dev_kfree_skb(skb);
        }
 
-       printk("%s: Shut down!\n", dev->name);
+       pr_info("%s: Shut down!\n", dev->name);
        module_put(THIS_MODULE);
 }
 
@@ -614,7 +575,7 @@ static struct atm_dev lecatm_dev = {
        .ops = &lecdev_ops,
        .type = "lec",
        .number = 999,          /* dummy device number */
-       .lock = SPIN_LOCK_UNLOCKED
+       .lock = __SPIN_LOCK_UNLOCKED(lecatm_dev.lock)
 };
 
 /*
@@ -623,16 +584,15 @@ static struct atm_dev lecatm_dev = {
  */
 static int
 send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
-            unsigned char *mac_addr, unsigned char *atm_addr,
+            const unsigned char *mac_addr, const unsigned char *atm_addr,
             struct sk_buff *data)
 {
        struct sock *sk;
        struct sk_buff *skb;
        struct atmlec_msg *mesg;
 
-       if (!priv || !priv->lecd) {
+       if (!priv || !priv->lecd)
                return -1;
-       }
        skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
        if (!skb)
                return -1;
@@ -655,7 +615,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
        sk->sk_data_ready(sk, skb->len);
 
        if (data != NULL) {
-               DPRINTK("lec: about to send %d bytes of data\n", data->len);
+               pr_debug("about to send %d bytes of data\n", data->len);
                atm_force_charge(priv->lecd, data->truesize);
                skb_queue_tail(&sk->sk_receive_queue, data);
                sk->sk_data_ready(sk, skb->len);
@@ -682,22 +642,16 @@ static void lec_set_multicast_list(struct net_device *dev)
        return;
 }
 
-static void lec_init(struct net_device *dev)
-{
-       dev->change_mtu = lec_change_mtu;
-       dev->open = lec_open;
-       dev->stop = lec_close;
-       dev->hard_start_xmit = lec_start_xmit;
-       dev->tx_timeout = lec_tx_timeout;
-
-       dev->get_stats = lec_get_stats;
-       dev->set_multicast_list = lec_set_multicast_list;
-       dev->do_ioctl = NULL;
-       printk("%s: Initialized!\n", dev->name);
-       return;
-}
+static const struct net_device_ops lec_netdev_ops = {
+       .ndo_open               = lec_open,
+       .ndo_stop               = lec_close,
+       .ndo_start_xmit         = lec_start_xmit,
+       .ndo_change_mtu         = lec_change_mtu,
+       .ndo_tx_timeout         = lec_tx_timeout,
+       .ndo_set_multicast_list = lec_set_multicast_list,
+};
 
-static unsigned char lec_ctrl_magic[] = {
+static const unsigned char lec_ctrl_magic[] = {
        0xff,
        0x00,
        0x01,
@@ -717,41 +671,33 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
 {
        unsigned long flags;
        struct net_device *dev = (struct net_device *)vcc->proto_data;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
-
-#if DUMP_PACKETS >0
-       int i = 0;
-       char buf[300];
+       struct lec_priv *priv = netdev_priv(dev);
 
-       printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name,
-              vcc->vpi, vcc->vci);
+#if DUMP_PACKETS > 0
+       printk(KERN_DEBUG "%s: vcc vpi:%d vci:%d\n",
+              dev->name, vcc->vpi, vcc->vci);
 #endif
        if (!skb) {
-               DPRINTK("%s: null skb\n", dev->name);
+               pr_debug("%s: null skb\n", dev->name);
                lec_vcc_close(priv, vcc);
                return;
        }
-#if DUMP_PACKETS > 0
-       printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name,
-              skb->len, priv->lecid);
 #if DUMP_PACKETS >= 2
-       for (i = 0; i < skb->len && i < 99; i++) {
-               sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
-       }
+#define MAX_SKB_DUMP 99
 #elif DUMP_PACKETS >= 1
-       for (i = 0; i < skb->len && i < 30; i++) {
-               sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
-       }
-#endif /* DUMP_PACKETS >= 1 */
-       if (i == skb->len)
-               printk("%s\n", buf);
-       else
-               printk("%s...\n", buf);
+#define MAX_SKB_DUMP 30
+#endif
+#if DUMP_PACKETS > 0
+       printk(KERN_DEBUG "%s: rcv datalen:%ld lecid:%4.4x\n",
+              dev->name, skb->len, priv->lecid);
+       print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
+                      skb->data, min(MAX_SKB_DUMP, skb->len), true);
 #endif /* DUMP_PACKETS > 0 */
-       if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) {        /* Control frame, to daemon */
+       if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) {
+                               /* Control frame, to daemon */
                struct sock *sk = sk_atm(vcc);
 
-               DPRINTK("%s: To daemon\n", dev->name);
+               pr_debug("%s: To daemon\n", dev->name);
                skb_queue_tail(&sk->sk_receive_queue, skb);
                sk->sk_data_ready(sk, skb->len);
        } else {                /* Data frame, queue to protocol handlers */
@@ -759,13 +705,13 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                unsigned char *src, *dst;
 
                atm_return(vcc, skb->truesize);
-               if (*(uint16_t *) skb->data == htons(priv->lecid) ||
+               if (*(__be16 *) skb->data == htons(priv->lecid) ||
                    !priv->lecd || !(dev->flags & IFF_UP)) {
                        /*
                         * Probably looping back, or if lecd is missing,
                         * lecd has gone down
                         */
-                       DPRINTK("Ignoring frame...\n");
+                       pr_debug("Ignoring frame...\n");
                        dev_kfree_skb(skb);
                        return;
                }
@@ -795,7 +741,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                        entry = lec_arp_find(priv, src);
                        if (entry && entry->vcc != vcc) {
                                lec_arp_remove(priv, entry);
-                               kfree(entry);
+                               lec_arp_put(entry);
                        }
                }
                spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
@@ -806,10 +752,8 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                        dev_kfree_skb(skb);
                        return;
                }
-               if (priv->lec_arp_empty_ones) {
+               if (!hlist_empty(&priv->lec_arp_empty_ones))
                        lec_arp_check_empties(priv, vcc, skb);
-               }
-               skb->dev = dev;
                skb_pull(skb, 2);       /* skip lec_id */
 #ifdef CONFIG_TR
                if (priv->is_trdev)
@@ -817,8 +761,8 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
                else
 #endif
                        skb->protocol = eth_type_trans(skb, dev);
-               priv->stats.rx_packets++;
-               priv->stats.rx_bytes += skb->len;
+               dev->stats.rx_packets++;
+               dev->stats.rx_bytes += skb->len;
                memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
                netif_rx(skb);
        }
@@ -830,7 +774,7 @@ static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
        struct net_device *dev = skb->dev;
 
        if (vpriv == NULL) {
-               printk("lec_pop(): vpriv = NULL!?!?!?\n");
+               pr_info("vpriv = NULL!?!?!?\n");
                return;
        }
 
@@ -851,21 +795,19 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
 
        /* Lecd must be up in this case */
        bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
-       if (bytes_left != 0) {
-               printk
-                   ("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
-                    bytes_left);
-       }
+       if (bytes_left != 0)
+               pr_info("copy from user failed for %d bytes\n", bytes_left);
        if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF ||
            !dev_lec[ioc_data.dev_num])
                return -EINVAL;
-       if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL)))
+       vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
+       if (!vpriv)
                return -ENOMEM;
        vpriv->xoff = 0;
        vpriv->old_pop = vcc->pop;
        vcc->user_back = vpriv;
        vcc->pop = lec_pop;
-       lec_vcc_added(dev_lec[ioc_data.dev_num]->priv,
+       lec_vcc_added(netdev_priv(dev_lec[ioc_data.dev_num]),
                      &ioc_data, vcc, vcc->push);
        vcc->proto_data = dev_lec[ioc_data.dev_num];
        vcc->push = lec_push;
@@ -877,7 +819,8 @@ static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
        if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
                return -EINVAL;
        vcc->proto_data = dev_lec[arg];
-       return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc));
+       return lec_mcast_make((struct lec_priv *)netdev_priv(dev_lec[arg]),
+                               vcc);
 }
 
 /* Initialize device. */
@@ -913,17 +856,17 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
                        dev_lec[i] = alloc_etherdev(size);
                if (!dev_lec[i])
                        return -ENOMEM;
+               dev_lec[i]->netdev_ops = &lec_netdev_ops;
                snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
                if (register_netdev(dev_lec[i])) {
                        free_netdev(dev_lec[i]);
                        return -EINVAL;
                }
 
-               priv = dev_lec[i]->priv;
+               priv = netdev_priv(dev_lec[i]);
                priv->is_trdev = is_trdev;
-               lec_init(dev_lec[i]);
        } else {
-               priv = dev_lec[i]->priv;
+               priv = netdev_priv(dev_lec[i]);
                if (priv->lecd)
                        return -EADDRINUSE;
        }
@@ -949,17 +892,16 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
        priv->flush_timeout = (4 * HZ);
        priv->path_switching_delay = (6 * HZ);
 
-       if (dev_lec[i]->flags & IFF_UP) {
+       if (dev_lec[i]->flags & IFF_UP)
                netif_start_queue(dev_lec[i]);
-       }
        __module_get(THIS_MODULE);
        return i;
 }
 
 #ifdef CONFIG_PROC_FS
-static char *lec_arp_get_status_string(unsigned char status)
+static const char *lec_arp_get_status_string(unsigned char status)
 {
-       static char *lec_arp_status_string[] = {
+       static const char *const lec_arp_status_string[] = {
                "ESI_UNKNOWN       ",
                "ESI_ARP_PENDING   ",
                "ESI_VC_PENDING    ",
@@ -998,29 +940,32 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
 struct lec_state {
        unsigned long flags;
        struct lec_priv *locked;
-       struct lec_arp_table *entry;
+       struct hlist_node *node;
        struct net_device *dev;
        int itf;
        int arp_table;
        int misc_table;
 };
 
-static void *lec_tbl_walk(struct lec_state *state, struct lec_arp_table *tbl,
+static void *lec_tbl_walk(struct lec_state *state, struct hlist_head *tbl,
                          loff_t *l)
 {
-       struct lec_arp_table *e = state->entry;
+       struct hlist_node *e = state->node;
+       struct lec_arp_table *tmp;
 
        if (!e)
-               e = tbl;
-       if (e == (void *)1) {
-               e = tbl;
+               e = tbl->first;
+       if (e == SEQ_START_TOKEN) {
+               e = tbl->first;
                --*l;
        }
-       for (; e; e = e->next) {
+
+       hlist_for_each_entry_from(tmp, e, next) {
                if (--*l < 0)
                        break;
        }
-       state->entry = e;
+       state->node = e;
+
        return (*l < 0) ? state : NULL;
 }
 
@@ -1031,7 +976,7 @@ static void *lec_arp_walk(struct lec_state *state, loff_t *l,
        int p;
 
        for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) {
-               v = lec_tbl_walk(state, priv->lec_arp_tables[p], l);
+               v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l);
                if (v)
                        break;
        }
@@ -1042,10 +987,10 @@ static void *lec_arp_walk(struct lec_state *state, loff_t *l,
 static void *lec_misc_walk(struct lec_state *state, loff_t *l,
                           struct lec_priv *priv)
 {
-       struct lec_arp_table *lec_misc_tables[] = {
-               priv->lec_arp_empty_ones,
-               priv->lec_no_forward,
-               priv->mcast_fwds
+       struct hlist_head *lec_misc_tables[] = {
+               &priv->lec_arp_empty_ones,
+               &priv->lec_no_forward,
+               &priv->mcast_fwds
        };
        void *v = NULL;
        int q;
@@ -1081,7 +1026,8 @@ static void *lec_itf_walk(struct lec_state *state, loff_t *l)
        void *v;
 
        dev = state->dev ? state->dev : dev_lec[state->itf];
-       v = (dev && dev->priv) ? lec_priv_walk(state, l, dev->priv) : NULL;
+       v = (dev && netdev_priv(dev)) ?
+               lec_priv_walk(state, l, netdev_priv(dev)) : NULL;
        if (!v && dev) {
                dev_put(dev);
                /* Partial state reset for the next time we get called */
@@ -1112,9 +1058,9 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
        state->locked = NULL;
        state->arp_table = 0;
        state->misc_table = 0;
-       state->entry = (void *)1;
+       state->node = SEQ_START_TOKEN;
 
-       return *pos ? lec_get_idx(state, *pos) : (void *)1;
+       return *pos ? lec_get_idx(state, *pos) : SEQ_START_TOKEN;
 }
 
 static void lec_seq_stop(struct seq_file *seq, void *v)
@@ -1139,23 +1085,27 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
 static int lec_seq_show(struct seq_file *seq, void *v)
 {
-       static char lec_banner[] = "Itf  MAC          ATM destination"
+       static const char lec_banner[] =
+           "Itf  MAC          ATM destination"
            "                          Status            Flags "
            "VPI/VCI Recv VPI/VCI\n";
 
-       if (v == (void *)1)
+       if (v == SEQ_START_TOKEN)
                seq_puts(seq, lec_banner);
        else {
                struct lec_state *state = seq->private;
                struct net_device *dev = state->dev;
+               struct lec_arp_table *entry = hlist_entry(state->node,
+                                                         struct lec_arp_table,
+                                                         next);
 
                seq_printf(seq, "%s ", dev->name);
-               lec_info(seq, state->entry);
+               lec_info(seq, entry);
        }
        return 0;
 }
 
-static struct seq_operations lec_seq_ops = {
+static const struct seq_operations lec_seq_ops = {
        .start = lec_seq_start,
        .next = lec_seq_next,
        .stop = lec_seq_stop,
@@ -1164,40 +1114,15 @@ static struct seq_operations lec_seq_ops = {
 
 static int lec_seq_open(struct inode *inode, struct file *file)
 {
-       struct lec_state *state;
-       struct seq_file *seq;
-       int rc = -EAGAIN;
-
-       state = kmalloc(sizeof(*state), GFP_KERNEL);
-       if (!state) {
-               rc = -ENOMEM;
-               goto out;
-       }
-
-       rc = seq_open(file, &lec_seq_ops);
-       if (rc)
-               goto out_kfree;
-       seq = file->private_data;
-       seq->private = state;
-out:
-       return rc;
-
-out_kfree:
-       kfree(state);
-       goto out;
-}
-
-static int lec_seq_release(struct inode *inode, struct file *file)
-{
-       return seq_release_private(inode, file);
+       return seq_open_private(file, &lec_seq_ops, sizeof(struct lec_state));
 }
 
-static struct file_operations lec_seq_fops = {
+static const struct file_operations lec_seq_fops = {
        .owner = THIS_MODULE,
        .open = lec_seq_open,
        .read = seq_read,
        .llseek = seq_lseek,
-       .release = lec_seq_release,
+       .release = seq_release_private,
 };
 #endif
 
@@ -1244,13 +1169,15 @@ static int __init lane_module_init(void)
 #ifdef CONFIG_PROC_FS
        struct proc_dir_entry *p;
 
-       p = create_proc_entry("lec", S_IRUGO, atm_proc_root);
-       if (p)
-               p->proc_fops = &lec_seq_fops;
+       p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops);
+       if (!p) {
+               pr_err("Unable to initialize /proc/net/atm/lec\n");
+               return -ENOMEM;
+       }
 #endif
 
        register_atm_ioctl(&lane_ioctl_ops);
-       printk("lec.c: " __DATE__ " " __TIME__ " initialized\n");
+       pr_info("lec.c: " __DATE__ " " __TIME__ " initialized\n");
        return 0;
 }
 
@@ -1265,7 +1192,7 @@ static void __exit lane_module_cleanup(void)
 
        for (i = 0; i < MAX_LEC_ITF; i++) {
                if (dev_lec[i] != NULL) {
-                       priv = (struct lec_priv *)dev_lec[i]->priv;
+                       priv = netdev_priv(dev_lec[i]);
                        unregister_netdev(dev_lec[i]);
                        free_netdev(dev_lec[i]);
                        dev_lec[i] = NULL;
@@ -1285,11 +1212,11 @@ module_exit(lane_module_cleanup);
  * lec will be used.
  * If dst_mac == NULL, targetless LE_ARP will be sent
  */
-static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
+static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
                         u8 **tlvs, u32 *sizeoftlvs)
 {
        unsigned long flags;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
        struct lec_arp_table *table;
        struct sk_buff *skb;
        int retval;
@@ -1301,11 +1228,10 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
                if (table == NULL)
                        return -1;
 
-               *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC);
+               *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC);
                if (*tlvs == NULL)
                        return -1;
 
-               memcpy(*tlvs, table->tlvs, table->sizeoftlvs);
                *sizeoftlvs = table->sizeoftlvs;
 
                return 0;
@@ -1319,7 +1245,7 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
                if (skb == NULL)
                        return -1;
                skb->len = *sizeoftlvs;
-               memcpy(skb->data, *tlvs, *sizeoftlvs);
+               skb_copy_to_linear_data(skb, *tlvs, *sizeoftlvs);
                retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb);
        }
        return retval;
@@ -1332,50 +1258,49 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
  * Returns 1 for success, 0 for failure (out of memory)
  *
  */
-static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
-                              u8 *tlvs, u32 sizeoftlvs)
+static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
+                              const u8 *tlvs, u32 sizeoftlvs)
 {
        int retval;
        struct sk_buff *skb;
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
 
        if (compare_ether_addr(lan_dst, dev->dev_addr))
-               return (0);     /* not our mac address */
+               return 0;       /* not our mac address */
 
        kfree(priv->tlvs);      /* NULL if there was no previous association */
 
-       priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
+       priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
        if (priv->tlvs == NULL)
-               return (0);
+               return 0;
        priv->sizeoftlvs = sizeoftlvs;
-       memcpy(priv->tlvs, tlvs, sizeoftlvs);
 
        skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
        if (skb == NULL)
                return 0;
        skb->len = sizeoftlvs;
-       memcpy(skb->data, tlvs, sizeoftlvs);
+       skb_copy_to_linear_data(skb, tlvs, sizeoftlvs);
        retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
        if (retval != 0)
-               printk("lec.c: lane2_associate_req() failed\n");
+               pr_info("lec.c: lane2_associate_req() failed\n");
        /*
         * If the previous association has changed we must
         * somehow notify other LANE entities about the change
         */
-       return (1);
+       return 1;
 }
 
 /*
  * LANE2: 3.1.5, LE_ASSOCIATE.indication
  *
  */
-static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
-                               u8 *tlvs, u32 sizeoftlvs)
+static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
+                               const u8 *tlvs, u32 sizeoftlvs)
 {
 #if 0
        int i = 0;
 #endif
-       struct lec_priv *priv = (struct lec_priv *)dev->priv;
+       struct lec_priv *priv = netdev_priv(dev);
 #if 0                          /*
                                 * Why have the TLVs in LE_ARP entries
                                 * since we do not use them? When you
@@ -1389,20 +1314,18 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
 
        kfree(entry->tlvs);
 
-       entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
+       entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
        if (entry->tlvs == NULL)
                return;
-
        entry->sizeoftlvs = sizeoftlvs;
-       memcpy(entry->tlvs, tlvs, sizeoftlvs);
 #endif
 #if 0
-       printk("lec.c: lane2_associate_ind()\n");
-       printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
+       pr_info("\n");
+       pr_info("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
        while (i < sizeoftlvs)
-               printk("%02x ", tlvs[i++]);
+               pr_cont("%02x ", tlvs[i++]);
 
-       printk("\n");
+       pr_cont("\n");
 #endif
 
        /* tell MPOA about the TLVs we saw */
@@ -1421,31 +1344,30 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
  */
 
 #include <linux/types.h>
-#include <linux/sched.h>
 #include <linux/timer.h>
-#include <asm/param.h>
+#include <linux/param.h>
 #include <asm/atomic.h>
 #include <linux/inetdevice.h>
 #include <net/route.h>
 
 #if 0
-#define DPRINTK(format,args...)
+#define pr_debug(format, args...)
 /*
-#define DPRINTK printk
+  #define pr_debug printk
 */
 #endif
 #define DEBUG_ARP_TABLE 0
 
 #define LEC_ARP_REFRESH_INTERVAL (3*HZ)
 
-static void lec_arp_check_expire(unsigned long data);
+static void lec_arp_check_expire(struct work_struct *work);
 static void lec_arp_expire_arp(unsigned long data);
 
-/* 
+/*
  * Arp table funcs
  */
 
-#define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE -1))
+#define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
 
 /*
  * Initialization of arp-cache
@@ -1454,15 +1376,14 @@ static void lec_arp_init(struct lec_priv *priv)
 {
        unsigned short i;
 
-       for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               priv->lec_arp_tables[i] = NULL;
-       }
+       for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
+               INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
+       INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
+       INIT_HLIST_HEAD(&priv->lec_no_forward);
+       INIT_HLIST_HEAD(&priv->mcast_fwds);
        spin_lock_init(&priv->lec_arp_lock);
-       init_timer(&priv->lec_arp_timer);
-       priv->lec_arp_timer.expires = jiffies + LEC_ARP_REFRESH_INTERVAL;
-       priv->lec_arp_timer.data = (unsigned long)priv;
-       priv->lec_arp_timer.function = lec_arp_check_expire;
-       add_timer(&priv->lec_arp_timer);
+       INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
+       schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
 }
 
 static void lec_arp_clear_vccs(struct lec_arp_table *entry)
@@ -1479,7 +1400,7 @@ static void lec_arp_clear_vccs(struct lec_arp_table *entry)
                vcc->user_back = NULL;
                vcc->push = entry->old_push;
                vcc_release_async(vcc, -EPIPE);
-               vcc = NULL;
+               entry->vcc = NULL;
        }
        if (entry->recv_vcc) {
                entry->recv_vcc->push = entry->old_recv_push;
@@ -1493,27 +1414,14 @@ static void lec_arp_clear_vccs(struct lec_arp_table *entry)
  * LANE2: Add to the end of the list to satisfy 8.1.13
  */
 static inline void
-lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add)
+lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry)
 {
-       unsigned short place;
-       struct lec_arp_table *tmp;
+       struct hlist_head *tmp;
 
-       place = HASH(to_add->mac_addr[ETH_ALEN - 1]);
-       tmp = priv->lec_arp_tables[place];
-       to_add->next = NULL;
-       if (tmp == NULL)
-               priv->lec_arp_tables[place] = to_add;
+       tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])];
+       hlist_add_head(&entry->next, tmp);
 
-       else {                  /* add to the end */
-               while (tmp->next)
-                       tmp = tmp->next;
-               tmp->next = to_add;
-       }
-
-       DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
-               0xff & to_add->mac_addr[0], 0xff & to_add->mac_addr[1],
-               0xff & to_add->mac_addr[2], 0xff & to_add->mac_addr[3],
-               0xff & to_add->mac_addr[4], 0xff & to_add->mac_addr[5]);
+       pr_debug("Added entry:%pM\n", entry->mac_addr);
 }
 
 /*
@@ -1522,40 +1430,29 @@ lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add)
 static int
 lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
 {
-       unsigned short place;
-       struct lec_arp_table *tmp;
-       int remove_vcc = 1;
+       struct hlist_node *node;
+       struct lec_arp_table *entry;
+       int i, remove_vcc = 1;
 
-       if (!to_remove) {
+       if (!to_remove)
                return -1;
-       }
-       place = HASH(to_remove->mac_addr[ETH_ALEN - 1]);
-       tmp = priv->lec_arp_tables[place];
-       if (tmp == to_remove) {
-               priv->lec_arp_tables[place] = tmp->next;
-       } else {
-               while (tmp && tmp->next != to_remove) {
-                       tmp = tmp->next;
-               }
-               if (!tmp) {     /* Entry was not found */
-                       return -1;
-               }
-       }
-       tmp->next = to_remove->next;
+
+       hlist_del(&to_remove->next);
        del_timer(&to_remove->timer);
 
-       /* If this is the only MAC connected to this VCC, also tear down
-          the VCC */
+       /*
+        * If this is the only MAC connected to this VCC,
+        * also tear down the VCC
+        */
        if (to_remove->status >= ESI_FLUSH_PENDING) {
                /*
                 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
                 */
-               for (place = 0; place < LEC_ARP_TABLE_SIZE; place++) {
-                       for (tmp = priv->lec_arp_tables[place]; tmp != NULL;
-                            tmp = tmp->next) {
-                               if (memcmp
-                                   (tmp->atm_addr, to_remove->atm_addr,
-                                    ATM_ESA_LEN) == 0) {
+               for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
+                       hlist_for_each_entry(entry, node,
+                                            &priv->lec_arp_tables[i], next) {
+                               if (memcmp(to_remove->atm_addr,
+                                          entry->atm_addr, ATM_ESA_LEN) == 0) {
                                        remove_vcc = 0;
                                        break;
                                }
@@ -1566,15 +1463,12 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
        }
        skb_queue_purge(&to_remove->tx_wait);   /* FIXME: good place for this? */
 
-       DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
-               0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1],
-               0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3],
-               0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]);
+       pr_debug("Removed entry:%pM\n", to_remove->mac_addr);
        return 0;
 }
 
 #if DEBUG_ARP_TABLE
-static char *get_status_string(unsigned char st)
+static const char *get_status_string(unsigned char st)
 {
        switch (st) {
        case ESI_UNKNOWN:
@@ -1587,39 +1481,26 @@ static char *get_status_string(unsigned char st)
                return "ESI_FLUSH_PENDING";
        case ESI_FORWARD_DIRECT:
                return "ESI_FORWARD_DIRECT";
-       default:
-               return "<UNKNOWN>";
        }
+       return "<UNKNOWN>";
 }
-#endif
 
 static void dump_arp_table(struct lec_priv *priv)
 {
-#if DEBUG_ARP_TABLE
-       int i, j, offset;
+       struct hlist_node *node;
        struct lec_arp_table *rulla;
-       char buf[1024];
-       struct lec_arp_table **lec_arp_tables =
-           (struct lec_arp_table **)priv->lec_arp_tables;
-       struct lec_arp_table *lec_arp_empty_ones =
-           (struct lec_arp_table *)priv->lec_arp_empty_ones;
-       struct lec_arp_table *lec_no_forward =
-           (struct lec_arp_table *)priv->lec_no_forward;
-       struct lec_arp_table *mcast_fwds = priv->mcast_fwds;
-
-       printk("Dump %p:\n", priv);
+       char buf[256];
+       int i, j, offset;
+
+       pr_info("Dump %p:\n", priv);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               rulla = lec_arp_tables[i];
-               offset = 0;
-               offset += sprintf(buf, "%d: %p\n", i, rulla);
-               while (rulla) {
-                       offset += sprintf(buf + offset, "Mac:");
-                       for (j = 0; j < ETH_ALEN; j++) {
-                               offset += sprintf(buf + offset,
-                                                 "%2.2x ",
-                                                 rulla->mac_addr[j] & 0xff);
-                       }
-                       offset += sprintf(buf + offset, "Atm:");
+               hlist_for_each_entry(rulla, node,
+                                    &priv->lec_arp_tables[i], next) {
+                       offset = 0;
+                       offset += sprintf(buf, "%d: %p\n", i, rulla);
+                       offset += sprintf(buf + offset, "Mac: %pM",
+                                         rulla->mac_addr);
+                       offset += sprintf(buf + offset, " Atm:");
                        for (j = 0; j < ATM_ESA_LEN; j++) {
                                offset += sprintf(buf + offset,
                                                  "%2.2x ",
@@ -1639,22 +1520,16 @@ static void dump_arp_table(struct lec_priv *priv)
                                    "Flags:%x, Packets_flooded:%x, Status: %s ",
                                    rulla->flags, rulla->packets_flooded,
                                    get_status_string(rulla->status));
-                       offset += sprintf(buf + offset, "->%p\n", rulla->next);
-                       rulla = rulla->next;
+                       pr_info("%s\n", buf);
                }
-               printk("%s", buf);
        }
-       rulla = lec_no_forward;
-       if (rulla)
-               printk("No forward\n");
-       while (rulla) {
+
+       if (!hlist_empty(&priv->lec_no_forward))
+               pr_info("No forward\n");
+       hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) {
                offset = 0;
-               offset += sprintf(buf + offset, "Mac:");
-               for (j = 0; j < ETH_ALEN; j++) {
-                       offset += sprintf(buf + offset, "%2.2x ",
-                                         rulla->mac_addr[j] & 0xff);
-               }
-               offset += sprintf(buf + offset, "Atm:");
+               offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
+               offset += sprintf(buf + offset, " Atm:");
                for (j = 0; j < ATM_ESA_LEN; j++) {
                        offset += sprintf(buf + offset, "%2.2x ",
                                          rulla->atm_addr[j] & 0xff);
@@ -1671,21 +1546,15 @@ static void dump_arp_table(struct lec_priv *priv)
                                  "Flags:%x, Packets_flooded:%x, Status: %s ",
                                  rulla->flags, rulla->packets_flooded,
                                  get_status_string(rulla->status));
-               offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next);
-               rulla = rulla->next;
-               printk("%s", buf);
-       }
-       rulla = lec_arp_empty_ones;
-       if (rulla)
-               printk("Empty ones\n");
-       while (rulla) {
+               pr_info("%s\n", buf);
+       }
+
+       if (!hlist_empty(&priv->lec_arp_empty_ones))
+               pr_info("Empty ones\n");
+       hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) {
                offset = 0;
-               offset += sprintf(buf + offset, "Mac:");
-               for (j = 0; j < ETH_ALEN; j++) {
-                       offset += sprintf(buf + offset, "%2.2x ",
-                                         rulla->mac_addr[j] & 0xff);
-               }
-               offset += sprintf(buf + offset, "Atm:");
+               offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
+               offset += sprintf(buf + offset, " Atm:");
                for (j = 0; j < ATM_ESA_LEN; j++) {
                        offset += sprintf(buf + offset, "%2.2x ",
                                          rulla->atm_addr[j] & 0xff);
@@ -1702,22 +1571,15 @@ static void dump_arp_table(struct lec_priv *priv)
                                  "Flags:%x, Packets_flooded:%x, Status: %s ",
                                  rulla->flags, rulla->packets_flooded,
                                  get_status_string(rulla->status));
-               offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next);
-               rulla = rulla->next;
-               printk("%s", buf);
+               pr_info("%s", buf);
        }
 
-       rulla = mcast_fwds;
-       if (rulla)
-               printk("Multicast Forward VCCs\n");
-       while (rulla) {
+       if (!hlist_empty(&priv->mcast_fwds))
+               pr_info("Multicast Forward VCCs\n");
+       hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) {
                offset = 0;
-               offset += sprintf(buf + offset, "Mac:");
-               for (j = 0; j < ETH_ALEN; j++) {
-                       offset += sprintf(buf + offset, "%2.2x ",
-                                         rulla->mac_addr[j] & 0xff);
-               }
-               offset += sprintf(buf + offset, "Atm:");
+               offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
+               offset += sprintf(buf + offset, " Atm:");
                for (j = 0; j < ATM_ESA_LEN; j++) {
                        offset += sprintf(buf + offset, "%2.2x ",
                                          rulla->atm_addr[j] & 0xff);
@@ -1734,13 +1596,13 @@ static void dump_arp_table(struct lec_priv *priv)
                                  "Flags:%x, Packets_flooded:%x, Status: %s ",
                                  rulla->flags, rulla->packets_flooded,
                                  get_status_string(rulla->status));
-               offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next);
-               rulla = rulla->next;
-               printk("%s", buf);
+               pr_info("%s\n", buf);
        }
 
-#endif
 }
+#else
+#define dump_arp_table(priv) do { } while (0)
+#endif
 
 /*
  * Destruction of arp-cache
@@ -1748,10 +1610,11 @@ static void dump_arp_table(struct lec_priv *priv)
 static void lec_arp_destroy(struct lec_priv *priv)
 {
        unsigned long flags;
-       struct lec_arp_table *entry, *next;
+       struct hlist_node *node, *next;
+       struct lec_arp_table *entry;
        int i;
 
-       del_timer_sync(&priv->lec_arp_timer);
+       cancel_rearming_delayed_work(&priv->lec_arp_work);
 
        /*
         * Remove all entries
@@ -1759,87 +1622,81 @@ static void lec_arp_destroy(struct lec_priv *priv)
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry != NULL;
-                    entry = next) {
-                       next = entry->next;
+               hlist_for_each_entry_safe(entry, node, next,
+                                         &priv->lec_arp_tables[i], next) {
                        lec_arp_remove(priv, entry);
-                       kfree(entry);
+                       lec_arp_put(entry);
                }
+               INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
        }
-       entry = priv->lec_arp_empty_ones;
-       while (entry) {
-               next = entry->next;
+
+       hlist_for_each_entry_safe(entry, node, next,
+                                 &priv->lec_arp_empty_ones, next) {
                del_timer_sync(&entry->timer);
                lec_arp_clear_vccs(entry);
-               kfree(entry);
-               entry = next;
+               hlist_del(&entry->next);
+               lec_arp_put(entry);
        }
-       priv->lec_arp_empty_ones = NULL;
-       entry = priv->lec_no_forward;
-       while (entry) {
-               next = entry->next;
+       INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
+
+       hlist_for_each_entry_safe(entry, node, next,
+                                 &priv->lec_no_forward, next) {
                del_timer_sync(&entry->timer);
                lec_arp_clear_vccs(entry);
-               kfree(entry);
-               entry = next;
+               hlist_del(&entry->next);
+               lec_arp_put(entry);
        }
-       priv->lec_no_forward = NULL;
-       entry = priv->mcast_fwds;
-       while (entry) {
-               next = entry->next;
+       INIT_HLIST_HEAD(&priv->lec_no_forward);
+
+       hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) {
                /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
                lec_arp_clear_vccs(entry);
-               kfree(entry);
-               entry = next;
+               hlist_del(&entry->next);
+               lec_arp_put(entry);
        }
-       priv->mcast_fwds = NULL;
+       INIT_HLIST_HEAD(&priv->mcast_fwds);
        priv->mcast_vcc = NULL;
-       memset(priv->lec_arp_tables, 0,
-              sizeof(struct lec_arp_table *) * LEC_ARP_TABLE_SIZE);
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 }
 
-/* 
+/*
  * Find entry by mac_address
  */
 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
-                                         unsigned char *mac_addr)
+                                         const unsigned char *mac_addr)
 {
-       unsigned short place;
-       struct lec_arp_table *to_return;
+       struct hlist_node *node;
+       struct hlist_head *head;
+       struct lec_arp_table *entry;
 
-       DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
-               mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff,
-               mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff);
-       place = HASH(mac_addr[ETH_ALEN - 1]);
+       pr_debug("%pM\n", mac_addr);
 
-       to_return = priv->lec_arp_tables[place];
-       while (to_return) {
-               if (!compare_ether_addr(mac_addr, to_return->mac_addr)) {
-                       return to_return;
-               }
-               to_return = to_return->next;
+       head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])];
+       hlist_for_each_entry(entry, node, head, next) {
+               if (!compare_ether_addr(mac_addr, entry->mac_addr))
+                       return entry;
        }
        return NULL;
 }
 
 static struct lec_arp_table *make_entry(struct lec_priv *priv,
-                                       unsigned char *mac_addr)
+                                       const unsigned char *mac_addr)
 {
        struct lec_arp_table *to_return;
 
        to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
        if (!to_return) {
-               printk("LEC: Arp entry kmalloc failed\n");
+               pr_info("LEC: Arp entry kmalloc failed\n");
                return NULL;
        }
        memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
-       init_timer(&to_return->timer);
-       to_return->timer.function = lec_arp_expire_arp;
-       to_return->timer.data = (unsigned long)to_return;
+       INIT_HLIST_NODE(&to_return->next);
+       setup_timer(&to_return->timer, lec_arp_expire_arp,
+                       (unsigned long)to_return);
        to_return->last_used = jiffies;
        to_return->priv = priv;
        skb_queue_head_init(&to_return->tx_wait);
+       atomic_set(&to_return->usage, 1);
        return to_return;
 }
 
@@ -1850,7 +1707,7 @@ static void lec_arp_expire_arp(unsigned long data)
 
        entry = (struct lec_arp_table *)data;
 
-       DPRINTK("lec_arp_expire_arp\n");
+       pr_debug("\n");
        if (entry->status == ESI_ARP_PENDING) {
                if (entry->no_tries <= entry->priv->max_retry_count) {
                        if (entry->is_rdesc)
@@ -1871,44 +1728,66 @@ static void lec_arp_expire_vcc(unsigned long data)
        unsigned long flags;
        struct lec_arp_table *to_remove = (struct lec_arp_table *)data;
        struct lec_priv *priv = (struct lec_priv *)to_remove->priv;
-       struct lec_arp_table *entry = NULL;
 
        del_timer(&to_remove->timer);
 
-       DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n",
-               to_remove, priv,
-               to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
-               to_remove->vcc ? to_remove->recv_vcc->vci : 0);
-       DPRINTK("eo:%p nf:%p\n", priv->lec_arp_empty_ones,
-               priv->lec_no_forward);
+       pr_debug("%p %p: vpi:%d vci:%d\n",
+                to_remove, priv,
+                to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
+                to_remove->vcc ? to_remove->recv_vcc->vci : 0);
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
-       if (to_remove == priv->lec_arp_empty_ones)
-               priv->lec_arp_empty_ones = to_remove->next;
-       else {
-               entry = priv->lec_arp_empty_ones;
-               while (entry && entry->next != to_remove)
-                       entry = entry->next;
-               if (entry)
-                       entry->next = to_remove->next;
-       }
-       if (!entry) {
-               if (to_remove == priv->lec_no_forward) {
-                       priv->lec_no_forward = to_remove->next;
-               } else {
-                       entry = priv->lec_no_forward;
-                       while (entry && entry->next != to_remove)
-                               entry = entry->next;
-                       if (entry)
-                               entry->next = to_remove->next;
-               }
-       }
+       hlist_del(&to_remove->next);
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 
        lec_arp_clear_vccs(to_remove);
-       kfree(to_remove);
+       lec_arp_put(to_remove);
 }
 
+static bool __lec_arp_check_expire(struct lec_arp_table *entry,
+                                  unsigned long now,
+                                  struct lec_priv *priv)
+{
+       unsigned long time_to_check;
+
+       if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
+               time_to_check = priv->forward_delay_time;
+       else
+               time_to_check = priv->aging_time;
+
+       pr_debug("About to expire: %lx - %lx > %lx\n",
+                now, entry->last_used, time_to_check);
+       if (time_after(now, entry->last_used + time_to_check) &&
+           !(entry->flags & LEC_PERMANENT_FLAG) &&
+           !(entry->mac_addr[0] & 0x01)) {     /* LANE2: 7.1.20 */
+               /* Remove entry */
+               pr_debug("Entry timed out\n");
+               lec_arp_remove(priv, entry);
+               lec_arp_put(entry);
+       } else {
+               /* Something else */
+               if ((entry->status == ESI_VC_PENDING ||
+                    entry->status == ESI_ARP_PENDING) &&
+                   time_after_eq(now, entry->timestamp +
+                                      priv->max_unknown_frame_time)) {
+                       entry->timestamp = jiffies;
+                       entry->packets_flooded = 0;
+                       if (entry->status == ESI_VC_PENDING)
+                               send_to_lecd(priv, l_svc_setup,
+                                            entry->mac_addr,
+                                            entry->atm_addr,
+                                            NULL);
+               }
+               if (entry->status == ESI_FLUSH_PENDING &&
+                   time_after_eq(now, entry->timestamp +
+                                      priv->path_switching_delay)) {
+                       lec_arp_hold(entry);
+                       return true;
+               }
+       }
+
+       return false;
+}
 /*
  * Expire entries.
  * 1. Re-set timer
@@ -1925,84 +1804,51 @@ static void lec_arp_expire_vcc(unsigned long data)
  *       to ESI_FORWARD_DIRECT. This causes the flush period to end
  *       regardless of the progress of the flush protocol.
  */
-static void lec_arp_check_expire(unsigned long data)
+static void lec_arp_check_expire(struct work_struct *work)
 {
        unsigned long flags;
-       struct lec_priv *priv = (struct lec_priv *)data;
-       struct lec_arp_table *entry, *next;
+       struct lec_priv *priv =
+               container_of(work, struct lec_priv, lec_arp_work.work);
+       struct hlist_node *node, *next;
+       struct lec_arp_table *entry;
        unsigned long now;
-       unsigned long time_to_check;
        int i;
 
-       DPRINTK("lec_arp_check_expire %p\n", priv);
-       DPRINTK("expire: eo:%p nf:%p\n", priv->lec_arp_empty_ones,
-               priv->lec_no_forward);
+       pr_debug("%p\n", priv);
        now = jiffies;
+restart:
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry != NULL;) {
-                       if ((entry->flags) & LEC_REMOTE_FLAG &&
-                           priv->topology_change)
-                               time_to_check = priv->forward_delay_time;
-                       else
-                               time_to_check = priv->aging_time;
-
-                       DPRINTK("About to expire: %lx - %lx > %lx\n",
-                               now, entry->last_used, time_to_check);
-                       if (time_after(now, entry->last_used + time_to_check)
-                           && !(entry->flags & LEC_PERMANENT_FLAG)
-                           && !(entry->mac_addr[0] & 0x01)) {  /* LANE2: 7.1.20 */
-                               /* Remove entry */
-                               DPRINTK("LEC:Entry timed out\n");
-                               next = entry->next;
-                               lec_arp_remove(priv, entry);
-                               kfree(entry);
-                               entry = next;
-                       } else {
-                               /* Something else */
-                               if ((entry->status == ESI_VC_PENDING ||
-                                    entry->status == ESI_ARP_PENDING)
-                                   && time_after_eq(now,
-                                                    entry->timestamp +
-                                                    priv->
-                                                    max_unknown_frame_time)) {
-                                       entry->timestamp = jiffies;
-                                       entry->packets_flooded = 0;
-                                       if (entry->status == ESI_VC_PENDING)
-                                               send_to_lecd(priv, l_svc_setup,
-                                                            entry->mac_addr,
-                                                            entry->atm_addr,
-                                                            NULL);
-                               }
-                               if (entry->status == ESI_FLUSH_PENDING
-                                   &&
-                                   time_after_eq(now, entry->timestamp +
-                                                 priv->path_switching_delay)) {
-                                       struct sk_buff *skb;
-
-                                       while ((skb =
-                                               skb_dequeue(&entry->tx_wait)) !=
-                                              NULL)
-                                               lec_send(entry->vcc, skb,
-                                                        entry->priv);
-                                       entry->last_used = jiffies;
-                                       entry->status = ESI_FORWARD_DIRECT;
-                               }
-                               entry = entry->next;
+               hlist_for_each_entry_safe(entry, node, next,
+                                         &priv->lec_arp_tables[i], next) {
+                       if (__lec_arp_check_expire(entry, now, priv)) {
+                               struct sk_buff *skb;
+                               struct atm_vcc *vcc = entry->vcc;
+
+                               spin_unlock_irqrestore(&priv->lec_arp_lock,
+                                                      flags);
+                               while ((skb = skb_dequeue(&entry->tx_wait)))
+                                       lec_send(vcc, skb);
+                               entry->last_used = jiffies;
+                               entry->status = ESI_FORWARD_DIRECT;
+                               lec_arp_put(entry);
+
+                               goto restart;
                        }
                }
        }
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 
-       mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL);
+       schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
 }
 
 /*
  * Try to find vcc where mac_address is attached.
- * 
+ *
  */
 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
-                                      unsigned char *mac_to_find, int is_rdesc,
+                                      const unsigned char *mac_to_find,
+                                      int is_rdesc,
                                       struct lec_arp_table **ret_entry)
 {
        unsigned long flags;
@@ -2013,7 +1859,6 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                switch (priv->lane_version) {
                case 1:
                        return priv->mcast_vcc;
-                       break;
                case 2: /* LANE2 wants arp for multicast addresses */
                        if (!compare_ether_addr(mac_to_find, bus_mac))
                                return priv->mcast_vcc;
@@ -2030,6 +1875,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                if (entry->status == ESI_FORWARD_DIRECT) {
                        /* Connection Ok */
                        entry->last_used = jiffies;
+                       lec_arp_hold(entry);
                        *ret_entry = entry;
                        found = entry->vcc;
                        goto out;
@@ -2038,9 +1884,8 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                 * If the LE_ARP cache entry is still pending, reset count to 0
                 * so another LE_ARP request can be made for this frame.
                 */
-               if (entry->status == ESI_ARP_PENDING) {
+               if (entry->status == ESI_ARP_PENDING)
                        entry->no_tries = 0;
-               }
                /*
                 * Data direct VC not yet set up, check to see if the unknown
                 * frame count is greater than the limit. If the limit has
@@ -2051,7 +1896,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                    entry->packets_flooded <
                    priv->maximum_unknown_frame_count) {
                        entry->packets_flooded++;
-                       DPRINTK("LEC_ARP: Flooding..\n");
+                       pr_debug("Flooding..\n");
                        found = priv->mcast_vcc;
                        goto out;
                }
@@ -2060,14 +1905,15 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
                 * or BUS flood limit was reached for an entry which is
                 * in ESI_ARP_PENDING or ESI_VC_PENDING state.
                 */
+               lec_arp_hold(entry);
                *ret_entry = entry;
-               DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status,
-                       entry->vcc);
+               pr_debug("entry->status %d entry->vcc %p\n", entry->status,
+                        entry->vcc);
                found = NULL;
        } else {
                /* No matching entry was found */
                entry = make_entry(priv, mac_to_find);
-               DPRINTK("LEC_ARP: Making entry\n");
+               pr_debug("Making entry\n");
                if (!entry) {
                        found = priv->mcast_vcc;
                        goto out;
@@ -2096,24 +1942,24 @@ out:
 }
 
 static int
-lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
+lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
                unsigned long permanent)
 {
        unsigned long flags;
-       struct lec_arp_table *entry, *next;
+       struct hlist_node *node, *next;
+       struct lec_arp_table *entry;
        int i;
 
-       DPRINTK("lec_addr_delete\n");
+       pr_debug("\n");
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry != NULL;
-                    entry = next) {
-                       next = entry->next;
-                       if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)
-                           && (permanent ||
-                               !(entry->flags & LEC_PERMANENT_FLAG))) {
+               hlist_for_each_entry_safe(entry, node, next,
+                                         &priv->lec_arp_tables[i], next) {
+                       if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) &&
+                           (permanent ||
+                            !(entry->flags & LEC_PERMANENT_FLAG))) {
                                lec_arp_remove(priv, entry);
-                               kfree(entry);
+                               lec_arp_put(entry);
                        }
                        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
                        return 0;
@@ -2124,21 +1970,20 @@ lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
 }
 
 /*
- * Notifies:  Response to arp_request (atm_addr != NULL) 
+ * Notifies:  Response to arp_request (atm_addr != NULL)
  */
 static void
-lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
-              unsigned char *atm_addr, unsigned long remoteflag,
+lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
+              const unsigned char *atm_addr, unsigned long remoteflag,
               unsigned int targetless_le_arp)
 {
        unsigned long flags;
+       struct hlist_node *node, *next;
        struct lec_arp_table *entry, *tmp;
        int i;
 
-       DPRINTK("lec:%s", (targetless_le_arp) ? "targetless " : " ");
-       DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
-               mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3],
-               mac_addr[4], mac_addr[5]);
+       pr_debug("%smac:%pM\n",
+                (targetless_le_arp) ? "targetless " : "", mac_addr);
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        entry = lec_arp_find(priv, mac_addr);
@@ -2147,50 +1992,40 @@ lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
                                 * LANE2: ignore targetless LE_ARPs for which
                                 * we have no entry in the cache. 7.1.30
                                 */
-       if (priv->lec_arp_empty_ones) {
-               entry = priv->lec_arp_empty_ones;
-               if (!memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN)) {
-                       priv->lec_arp_empty_ones = entry->next;
-               } else {
-                       while (entry->next && memcmp(entry->next->atm_addr,
-                                                    atm_addr, ATM_ESA_LEN))
-                               entry = entry->next;
-                       if (entry->next) {
-                               tmp = entry;
-                               entry = entry->next;
-                               tmp->next = entry->next;
-                       } else
-                               entry = NULL;
-
-               }
-               if (entry) {
-                       del_timer(&entry->timer);
-                       tmp = lec_arp_find(priv, mac_addr);
-                       if (tmp) {
-                               del_timer(&tmp->timer);
-                               tmp->status = ESI_FORWARD_DIRECT;
-                               memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
-                               tmp->vcc = entry->vcc;
-                               tmp->old_push = entry->old_push;
-                               tmp->last_used = jiffies;
+       if (!hlist_empty(&priv->lec_arp_empty_ones)) {
+               hlist_for_each_entry_safe(entry, node, next,
+                                         &priv->lec_arp_empty_ones, next) {
+                       if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
+                               hlist_del(&entry->next);
                                del_timer(&entry->timer);
-                               kfree(entry);
-                               entry = tmp;
-                       } else {
-                               entry->status = ESI_FORWARD_DIRECT;
-                               memcpy(entry->mac_addr, mac_addr, ETH_ALEN);
-                               entry->last_used = jiffies;
-                               lec_arp_add(priv, entry);
+                               tmp = lec_arp_find(priv, mac_addr);
+                               if (tmp) {
+                                       del_timer(&tmp->timer);
+                                       tmp->status = ESI_FORWARD_DIRECT;
+                                       memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
+                                       tmp->vcc = entry->vcc;
+                                       tmp->old_push = entry->old_push;
+                                       tmp->last_used = jiffies;
+                                       del_timer(&entry->timer);
+                                       lec_arp_put(entry);
+                                       entry = tmp;
+                               } else {
+                                       entry->status = ESI_FORWARD_DIRECT;
+                                       memcpy(entry->mac_addr, mac_addr, ETH_ALEN);
+                                       entry->last_used = jiffies;
+                                       lec_arp_add(priv, entry);
+                               }
+                               if (remoteflag)
+                                       entry->flags |= LEC_REMOTE_FLAG;
+                               else
+                                       entry->flags &= ~LEC_REMOTE_FLAG;
+                               pr_debug("After update\n");
+                               dump_arp_table(priv);
+                               goto out;
                        }
-                       if (remoteflag)
-                               entry->flags |= LEC_REMOTE_FLAG;
-                       else
-                               entry->flags &= ~LEC_REMOTE_FLAG;
-                       DPRINTK("After update\n");
-                       dump_arp_table(priv);
-                       goto out;
                }
        }
+
        entry = lec_arp_find(priv, mac_addr);
        if (!entry) {
                entry = make_entry(priv, mac_addr);
@@ -2203,7 +2038,8 @@ lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
        memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
        del_timer(&entry->timer);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (tmp = priv->lec_arp_tables[i]; tmp; tmp = tmp->next) {
+               hlist_for_each_entry(tmp, node,
+                                    &priv->lec_arp_tables[i], next) {
                        if (entry != tmp &&
                            !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
                                /* Vcc to this host exists */
@@ -2226,36 +2062,35 @@ lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
                entry->flags &= ~LEC_REMOTE_FLAG;
        if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) {
                entry->status = ESI_VC_PENDING;
-               send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr,
-                            NULL);
+               send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
        }
-       DPRINTK("After update2\n");
+       pr_debug("After update2\n");
        dump_arp_table(priv);
 out:
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 }
 
 /*
- * Notifies: Vcc setup ready 
+ * Notifies: Vcc setup ready
  */
 static void
-lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
+lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
              struct atm_vcc *vcc,
              void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb))
 {
        unsigned long flags;
+       struct hlist_node *node;
        struct lec_arp_table *entry;
        int i, found_entry = 0;
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
+       /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
        if (ioc_data->receive == 2) {
-               /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
-
-               DPRINTK("LEC_ARP: Attaching mcast forward\n");
+               pr_debug("LEC_ARP: Attaching mcast forward\n");
 #if 0
                entry = lec_arp_find(priv, bus_mac);
                if (!entry) {
-                       printk("LEC_ARP: Multicast entry not found!\n");
+                       pr_info("LEC_ARP: Multicast entry not found!\n");
                        goto out;
                }
                memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
@@ -2269,27 +2104,24 @@ lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
                memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
                entry->recv_vcc = vcc;
                entry->old_recv_push = old_push;
-               entry->next = priv->mcast_fwds;
-               priv->mcast_fwds = entry;
+               hlist_add_head(&entry->next, &priv->mcast_fwds);
                goto out;
        } else if (ioc_data->receive == 1) {
                /*
                 * Vcc which we don't want to make default vcc,
                 * attach it anyway.
                 */
-               DPRINTK
-                   ("LEC_ARP:Attaching data direct, not default: "
-                    "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
-                    ioc_data->atm_addr[0], ioc_data->atm_addr[1],
-                    ioc_data->atm_addr[2], ioc_data->atm_addr[3],
-                    ioc_data->atm_addr[4], ioc_data->atm_addr[5],
-                    ioc_data->atm_addr[6], ioc_data->atm_addr[7],
-                    ioc_data->atm_addr[8], ioc_data->atm_addr[9],
-                    ioc_data->atm_addr[10], ioc_data->atm_addr[11],
-                    ioc_data->atm_addr[12], ioc_data->atm_addr[13],
-                    ioc_data->atm_addr[14], ioc_data->atm_addr[15],
-                    ioc_data->atm_addr[16], ioc_data->atm_addr[17],
-                    ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
+               pr_debug("LEC_ARP:Attaching data direct, not default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
+                        ioc_data->atm_addr[0], ioc_data->atm_addr[1],
+                        ioc_data->atm_addr[2], ioc_data->atm_addr[3],
+                        ioc_data->atm_addr[4], ioc_data->atm_addr[5],
+                        ioc_data->atm_addr[6], ioc_data->atm_addr[7],
+                        ioc_data->atm_addr[8], ioc_data->atm_addr[9],
+                        ioc_data->atm_addr[10], ioc_data->atm_addr[11],
+                        ioc_data->atm_addr[12], ioc_data->atm_addr[13],
+                        ioc_data->atm_addr[14], ioc_data->atm_addr[15],
+                        ioc_data->atm_addr[16], ioc_data->atm_addr[17],
+                        ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
                entry = make_entry(priv, bus_mac);
                if (entry == NULL)
                        goto out;
@@ -2300,36 +2132,33 @@ lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
                entry->status = ESI_UNKNOWN;
                entry->timer.expires = jiffies + priv->vcc_timeout_period;
                entry->timer.function = lec_arp_expire_vcc;
+               hlist_add_head(&entry->next, &priv->lec_no_forward);
                add_timer(&entry->timer);
-               entry->next = priv->lec_no_forward;
-               priv->lec_no_forward = entry;
                dump_arp_table(priv);
                goto out;
        }
-       DPRINTK
-           ("LEC_ARP:Attaching data direct, default: "
-            "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
-            ioc_data->atm_addr[0], ioc_data->atm_addr[1],
-            ioc_data->atm_addr[2], ioc_data->atm_addr[3],
-            ioc_data->atm_addr[4], ioc_data->atm_addr[5],
-            ioc_data->atm_addr[6], ioc_data->atm_addr[7],
-            ioc_data->atm_addr[8], ioc_data->atm_addr[9],
-            ioc_data->atm_addr[10], ioc_data->atm_addr[11],
-            ioc_data->atm_addr[12], ioc_data->atm_addr[13],
-            ioc_data->atm_addr[14], ioc_data->atm_addr[15],
-            ioc_data->atm_addr[16], ioc_data->atm_addr[17],
-            ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
+       pr_debug("LEC_ARP:Attaching data direct, default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
+                ioc_data->atm_addr[0], ioc_data->atm_addr[1],
+                ioc_data->atm_addr[2], ioc_data->atm_addr[3],
+                ioc_data->atm_addr[4], ioc_data->atm_addr[5],
+                ioc_data->atm_addr[6], ioc_data->atm_addr[7],
+                ioc_data->atm_addr[8], ioc_data->atm_addr[9],
+                ioc_data->atm_addr[10], ioc_data->atm_addr[11],
+                ioc_data->atm_addr[12], ioc_data->atm_addr[13],
+                ioc_data->atm_addr[14], ioc_data->atm_addr[15],
+                ioc_data->atm_addr[16], ioc_data->atm_addr[17],
+                ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry;
-                    entry = entry->next) {
+               hlist_for_each_entry(entry, node,
+                                    &priv->lec_arp_tables[i], next) {
                        if (memcmp
                            (ioc_data->atm_addr, entry->atm_addr,
                             ATM_ESA_LEN) == 0) {
-                               DPRINTK("LEC_ARP: Attaching data direct\n");
-                               DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n",
-                                       entry->vcc ? entry->vcc->vci : 0,
-                                       entry->recv_vcc ? entry->recv_vcc->
-                                       vci : 0);
+                               pr_debug("LEC_ARP: Attaching data direct\n");
+                               pr_debug("Currently -> Vcc: %d, Rvcc:%d\n",
+                                        entry->vcc ? entry->vcc->vci : 0,
+                                        entry->recv_vcc ? entry->recv_vcc->
+                                        vci : 0);
                                found_entry = 1;
                                del_timer(&entry->timer);
                                entry->vcc = vcc;
@@ -2368,7 +2197,7 @@ lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
                }
        }
        if (found_entry) {
-               DPRINTK("After vcc was added\n");
+               pr_debug("After vcc was added\n");
                dump_arp_table(priv);
                goto out;
        }
@@ -2384,12 +2213,11 @@ lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
        memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
        memset(entry->mac_addr, 0, ETH_ALEN);
        entry->status = ESI_UNKNOWN;
-       entry->next = priv->lec_arp_empty_ones;
-       priv->lec_arp_empty_ones = entry;
+       hlist_add_head(&entry->next, &priv->lec_arp_empty_ones);
        entry->timer.expires = jiffies + priv->vcc_timeout_period;
        entry->timer.function = lec_arp_expire_vcc;
        add_timer(&entry->timer);
-       DPRINTK("After vcc was added\n");
+       pr_debug("After vcc was added\n");
        dump_arp_table(priv);
 out:
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
@@ -2398,23 +2226,31 @@ out:
 static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
 {
        unsigned long flags;
+       struct hlist_node *node;
        struct lec_arp_table *entry;
        int i;
 
-       DPRINTK("LEC:lec_flush_complete %lx\n", tran_id);
+       pr_debug("%lx\n", tran_id);
+restart:
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry;
-                    entry = entry->next) {
-                       if (entry->flush_tran_id == tran_id
-                           && entry->status == ESI_FLUSH_PENDING) {
+               hlist_for_each_entry(entry, node,
+                                    &priv->lec_arp_tables[i], next) {
+                       if (entry->flush_tran_id == tran_id &&
+                           entry->status == ESI_FLUSH_PENDING) {
                                struct sk_buff *skb;
+                               struct atm_vcc *vcc = entry->vcc;
 
-                               while ((skb =
-                                       skb_dequeue(&entry->tx_wait)) != NULL)
-                                       lec_send(entry->vcc, skb, entry->priv);
+                               lec_arp_hold(entry);
+                               spin_unlock_irqrestore(&priv->lec_arp_lock,
+                                                      flags);
+                               while ((skb = skb_dequeue(&entry->tx_wait)))
+                                       lec_send(vcc, skb);
+                               entry->last_used = jiffies;
                                entry->status = ESI_FORWARD_DIRECT;
-                               DPRINTK("LEC_ARP: Flushed\n");
+                               lec_arp_put(entry);
+                               pr_debug("LEC_ARP: Flushed\n");
+                               goto restart;
                        }
                }
        }
@@ -2424,22 +2260,23 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
 
 static void
 lec_set_flush_tran_id(struct lec_priv *priv,
-                     unsigned char *atm_addr, unsigned long tran_id)
+                     const unsigned char *atm_addr, unsigned long tran_id)
 {
        unsigned long flags;
+       struct hlist_node *node;
        struct lec_arp_table *entry;
        int i;
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
-               for (entry = priv->lec_arp_tables[i]; entry;
-                    entry = entry->next)
+               hlist_for_each_entry(entry, node,
+                                    &priv->lec_arp_tables[i], next) {
                        if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
                                entry->flush_tran_id = tran_id;
-                               DPRINTK
-                                   ("Set flush transaction id to %lx for %p\n",
-                                    tran_id, entry);
+                               pr_debug("Set flush transaction id to %lx for %p\n",
+                                        tran_id, entry);
                        }
+               }
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 }
 
@@ -2453,7 +2290,8 @@ static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
        struct lec_vcc_priv *vpriv;
        int err = 0;
 
-       if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL)))
+       vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
+       if (!vpriv)
                return -ENOMEM;
        vpriv->xoff = 0;
        vpriv->old_pop = vcc->pop;
@@ -2483,68 +2321,54 @@ out:
 static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
 {
        unsigned long flags;
-       struct lec_arp_table *entry, *next;
+       struct hlist_node *node, *next;
+       struct lec_arp_table *entry;
        int i;
 
-       DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
+       pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
        dump_arp_table(priv);
+
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
+
        for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
-               for (entry = priv->lec_arp_tables[i]; entry; entry = next) {
-                       next = entry->next;
+               hlist_for_each_entry_safe(entry, node, next,
+                                         &priv->lec_arp_tables[i], next) {
                        if (vcc == entry->vcc) {
                                lec_arp_remove(priv, entry);
-                               kfree(entry);
-                               if (priv->mcast_vcc == vcc) {
+                               lec_arp_put(entry);
+                               if (priv->mcast_vcc == vcc)
                                        priv->mcast_vcc = NULL;
-                               }
                        }
                }
        }
 
-       entry = priv->lec_arp_empty_ones;
-       priv->lec_arp_empty_ones = NULL;
-       while (entry != NULL) {
-               next = entry->next;
-               if (entry->vcc == vcc) {        /* leave it out from the list */
+       hlist_for_each_entry_safe(entry, node, next,
+                                 &priv->lec_arp_empty_ones, next) {
+               if (entry->vcc == vcc) {
                        lec_arp_clear_vccs(entry);
                        del_timer(&entry->timer);
-                       kfree(entry);
-               } else {                        /* put it back to the list */
-                       entry->next = priv->lec_arp_empty_ones;
-                       priv->lec_arp_empty_ones = entry;
+                       hlist_del(&entry->next);
+                       lec_arp_put(entry);
                }
-               entry = next;
        }
 
-       entry = priv->lec_no_forward;
-       priv->lec_no_forward = NULL;
-       while (entry != NULL) {
-               next = entry->next;
+       hlist_for_each_entry_safe(entry, node, next,
+                                 &priv->lec_no_forward, next) {
                if (entry->recv_vcc == vcc) {
                        lec_arp_clear_vccs(entry);
                        del_timer(&entry->timer);
-                       kfree(entry);
-               } else {
-                       entry->next = priv->lec_no_forward;
-                       priv->lec_no_forward = entry;
+                       hlist_del(&entry->next);
+                       lec_arp_put(entry);
                }
-               entry = next;
        }
 
-       entry = priv->mcast_fwds;
-       priv->mcast_fwds = NULL;
-       while (entry != NULL) {
-               next = entry->next;
+       hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) {
                if (entry->recv_vcc == vcc) {
                        lec_arp_clear_vccs(entry);
                        /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
-                       kfree(entry);
-               } else {
-                       entry->next = priv->mcast_fwds;
-                       priv->mcast_fwds = entry;
+                       hlist_del(&entry->next);
+                       lec_arp_put(entry);
                }
-               entry = next;
        }
 
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
@@ -2556,7 +2380,8 @@ lec_arp_check_empties(struct lec_priv *priv,
                      struct atm_vcc *vcc, struct sk_buff *skb)
 {
        unsigned long flags;
-       struct lec_arp_table *entry, *prev;
+       struct hlist_node *node, *next;
+       struct lec_arp_table *entry, *tmp;
        struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
        unsigned char *src;
 #ifdef CONFIG_TR
@@ -2569,41 +2394,25 @@ lec_arp_check_empties(struct lec_priv *priv,
                src = hdr->h_source;
 
        spin_lock_irqsave(&priv->lec_arp_lock, flags);
-       entry = priv->lec_arp_empty_ones;
-       if (vcc == entry->vcc) {
-               del_timer(&entry->timer);
-               memcpy(entry->mac_addr, src, ETH_ALEN);
-               entry->status = ESI_FORWARD_DIRECT;
-               entry->last_used = jiffies;
-               priv->lec_arp_empty_ones = entry->next;
-               /* We might have got an entry */
-               if ((prev = lec_arp_find(priv, src))) {
-                       lec_arp_remove(priv, prev);
-                       kfree(prev);
+       hlist_for_each_entry_safe(entry, node, next,
+                                 &priv->lec_arp_empty_ones, next) {
+               if (vcc == entry->vcc) {
+                       del_timer(&entry->timer);
+                       memcpy(entry->mac_addr, src, ETH_ALEN);
+                       entry->status = ESI_FORWARD_DIRECT;
+                       entry->last_used = jiffies;
+                       /* We might have got an entry */
+                       tmp = lec_arp_find(priv, src);
+                       if (tmp) {
+                               lec_arp_remove(priv, tmp);
+                               lec_arp_put(tmp);
+                       }
+                       hlist_del(&entry->next);
+                       lec_arp_add(priv, entry);
+                       goto out;
                }
-               lec_arp_add(priv, entry);
-               goto out;
-       }
-       prev = entry;
-       entry = entry->next;
-       while (entry && entry->vcc != vcc) {
-               prev = entry;
-               entry = entry->next;
-       }
-       if (!entry) {
-               DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n");
-               goto out;
        }
-       del_timer(&entry->timer);
-       memcpy(entry->mac_addr, src, ETH_ALEN);
-       entry->status = ESI_FORWARD_DIRECT;
-       entry->last_used = jiffies;
-       prev->next = entry->next;
-       if ((prev = lec_arp_find(priv, src))) {
-               lec_arp_remove(priv, prev);
-               kfree(prev);
-       }
-       lec_arp_add(priv, entry);
+       pr_debug("LEC_ARP: Arp_check_empties: entry not found!\n");
 out:
        spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
 }