arcnet: Expand odd BUGLVL macro with if and uses
[cascardo/linux.git] / drivers / net / arcnet / arcnet.c
index 10f71c7..7a90b8a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Linux ARCnet driver - device-independent routines
- * 
+ *
  * Written 1997 by David Woodhouse.
  * Written 1994-1999 by Avery Pennarun.
  * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
  * modified by SRC, incorporated herein by reference.
  *
  * **********************
- * 
+ *
  * The change log is now in a file called ChangeLog in this directory.
  *
  * Sources:
  *  - Crynwr arcnet.com/arcether.com packet drivers.
- *  - arcnet.c v0.00 dated 1/1/94 and apparently by 
+ *  - arcnet.c v0.00 dated 1/1/94 and apparently by
  *     Donald Becker - it didn't work :)
  *  - skeleton.c v0.05 dated 11/16/93 by Donald Becker
  *     (from Linux Kernel 1.1.45)
@@ -63,17 +63,15 @@ static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
 
 static void arcnet_rx(struct net_device *dev, int bufnum);
 
-/*
- * one ArcProto per possible proto ID.  None of the elements of
+/* one ArcProto per possible proto ID.  None of the elements of
  * arc_proto_map are allowed to be NULL; they will get set to
  * arc_proto_default instead.  It also must not be NULL; if you would like
  * to set it to NULL, set it to &arc_proto_null instead.
  */
- struct ArcProto *arc_proto_map[256], *arc_proto_default,
-   *arc_bcast_proto, *arc_raw_proto;
+struct ArcProto *arc_proto_map[256], *arc_proto_default,
+       *arc_bcast_proto, *arc_raw_proto;
 
-static struct ArcProto arc_proto_null =
-{
+static struct ArcProto arc_proto_null = {
        .suffix         = '?',
        .mtu            = XMTU,
        .is_ip          = 0,
@@ -119,7 +117,7 @@ static int __init arcnet_init(void)
        printk("arcnet loaded.\n");
 
 #ifdef ALPHA_WARNING
-       BUGLVL(D_EXTRA) {
+       if (BUGLVL(D_EXTRA)) {
                printk("arcnet: ***\n"
                "arcnet: * Read arcnet.txt for important release notes!\n"
                       "arcnet: *\n"
@@ -134,11 +132,11 @@ static int __init arcnet_init(void)
        for (count = 0; count < 256; count++)
                arc_proto_map[count] = arc_proto_default;
 
-       BUGLVL(D_DURING)
-           printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
-                sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
-               sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
-                  sizeof(struct archdr));
+       if (BUGLVL(D_DURING))
+               printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
+                      sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
+                      sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
+                      sizeof(struct archdr));
 
        return 0;
 }
@@ -150,9 +148,7 @@ static void __exit arcnet_exit(void)
 module_init(arcnet_init);
 module_exit(arcnet_exit);
 
-/*
- * Dump the contents of an sk_buff
- */
+/* Dump the contents of an sk_buff */
 #if ARCNET_DEBUG_MAX & D_SKB
 void arcnet_dump_skb(struct net_device *dev,
                     struct sk_buff *skb, char *desc)
@@ -168,10 +164,7 @@ void arcnet_dump_skb(struct net_device *dev,
 EXPORT_SYMBOL(arcnet_dump_skb);
 #endif
 
-
-/*
- * Dump the contents of an ARCnet buffer
- */
+/* Dump the contents of an ARCnet buffer */
 #if (ARCNET_DEBUG_MAX & (D_RX | D_TX))
 static void arcnet_dump_packet(struct net_device *dev, int bufnum,
                               char *desc, int take_arcnet_lock)
@@ -183,12 +176,13 @@ static void arcnet_dump_packet(struct net_device *dev, int bufnum,
        char hdr[32];
 
        /* hw.copy_from_card expects IRQ context so take the IRQ lock
-          to keep it single threaded */
-       if(take_arcnet_lock)
+        * to keep it single threaded
+        */
+       if (take_arcnet_lock)
                spin_lock_irqsave(&lp->lock, flags);
 
        lp->hw.copy_from_card(dev, bufnum, 0, buf, 512);
-       if(take_arcnet_lock)
+       if (take_arcnet_lock)
                spin_unlock_irqrestore(&lp->lock, flags);
 
        /* if the offset[0] byte is nonzero, this is a 256-byte packet */
@@ -202,13 +196,11 @@ static void arcnet_dump_packet(struct net_device *dev, int bufnum,
 
 #else
 
-#define arcnet_dump_packet(dev, bufnum, desc,take_arcnet_lock) do { } while (0)
+#define arcnet_dump_packet(dev, bufnum, desc, take_arcnet_lock) do { } while (0)
 
 #endif
 
-
-/*
- * Unregister a protocol driver from the arc_proto_map.  Protocol drivers
+/* Unregister a protocol driver from the arc_proto_map.  Protocol drivers
  * are responsible for registering themselves, but the unregister routine
  * is pretty generic so we'll do it here.
  */
@@ -229,11 +221,9 @@ void arcnet_unregister_proto(struct ArcProto *proto)
        }
 }
 
-
-/*
- * Add a buffer to the queue.  Only the interrupt handler is allowed to do
+/* Add a buffer to the queue.  Only the interrupt handler is allowed to do
  * this, unless interrupts are disabled.
- * 
+ *
  * Note: we don't check for a full queue, since there aren't enough buffers
  * to more than fill it.
  */
@@ -245,19 +235,17 @@ static void release_arcbuf(struct net_device *dev, int bufnum)
        lp->buf_queue[lp->first_free_buf++] = bufnum;
        lp->first_free_buf %= 5;
 
-       BUGLVL(D_DURING) {
+       if (BUGLVL(D_DURING)) {
                BUGMSG(D_DURING, "release_arcbuf: freed #%d; buffer queue is now: ",
                       bufnum);
-               for (i = lp->next_buf; i != lp->first_free_buf; i = (i+1) % 5)
+               for (i = lp->next_buf; i != lp->first_free_buf; i = (i + 1) % 5)
                        BUGMSG2(D_DURING, "#%d ", lp->buf_queue[i]);
                BUGMSG2(D_DURING, "\n");
        }
 }
 
-
-/*
- * Get a buffer from the queue.  If this returns -1, there are no buffers
- * available.
+/* Get a buffer from the queue.
+ * If this returns -1, there are no buffers available.
  */
 static int get_arcbuf(struct net_device *dev)
 {
@@ -268,23 +256,21 @@ static int get_arcbuf(struct net_device *dev)
                /* already in this function */
                BUGMSG(D_NORMAL, "get_arcbuf: overlap (%d)!\n",
                       lp->buf_lock.counter);
-       }
-       else {                  /* we can continue */
+       } else {                        /* we can continue */
                if (lp->next_buf >= 5)
                        lp->next_buf -= 5;
 
-               if (lp->next_buf == lp->first_free_buf)
+               if (lp->next_buf == lp->first_free_buf) {
                        BUGMSG(D_NORMAL, "get_arcbuf: BUG: no buffers are available??\n");
-               else {
+               else {
                        buf = lp->buf_queue[lp->next_buf++];
                        lp->next_buf %= 5;
                }
        }
 
-
-       BUGLVL(D_DURING) {
+       if (BUGLVL(D_DURING)) {
                BUGMSG(D_DURING, "get_arcbuf: got #%d; buffer queue is now: ", buf);
-               for (i = lp->next_buf; i != lp->first_free_buf; i = (i+1) % 5)
+               for (i = lp->next_buf; i != lp->first_free_buf; i = (i + 1) % 5)
                        BUGMSG2(D_DURING, "#%d ", lp->buf_queue[i]);
                BUGMSG2(D_DURING, "\n");
        }
@@ -293,7 +279,6 @@ static int get_arcbuf(struct net_device *dev)
        return buf;
 }
 
-
 static int choose_mtu(void)
 {
        int count, mtu = 65535;
@@ -336,7 +321,6 @@ static void arcdev_setup(struct net_device *dev)
 
        /* New-style flags. */
        dev->flags = IFF_BROADCAST;
-
 }
 
 struct net_device *alloc_arcdev(const char *name)
@@ -346,16 +330,16 @@ struct net_device *alloc_arcdev(const char *name)
        dev = alloc_netdev(sizeof(struct arcnet_local),
                           name && *name ? name : "arc%d", NET_NAME_UNKNOWN,
                           arcdev_setup);
-       if(dev) {
+       if (dev) {
                struct arcnet_local *lp = netdev_priv(dev);
+
                spin_lock_init(&lp->lock);
        }
 
        return dev;
 }
 
-/*
- * Open/initialize the board.  This is called sometime after booting when
+/* Open/initialize the board.  This is called sometime after booting when
  * the 'ifconfig' program is run.
  *
  * This routine should set everything up anew at each open, even registers
@@ -367,12 +351,12 @@ int arcnet_open(struct net_device *dev)
        struct arcnet_local *lp = netdev_priv(dev);
        int count, newmtu, error;
 
-       BUGMSG(D_INIT,"opened.");
+       BUGMSG(D_INIT, "opened.");
 
        if (!try_module_get(lp->hw.owner))
                return -ENODEV;
 
-       BUGLVL(D_PROTO) {
+       if (BUGLVL(D_PROTO)) {
                BUGMSG(D_PROTO, "protocol map (default is '%c'): ",
                       arc_proto_default->suffix);
                for (count = 0; count < 256; count++)
@@ -380,7 +364,6 @@ int arcnet_open(struct net_device *dev)
                BUGMSG2(D_PROTO, "\n");
        }
 
-
        BUGMSG(D_INIT, "arcnet_open: resetting card.\n");
 
        /* try to put the card in a defined state - if it fails the first
@@ -425,30 +408,27 @@ int arcnet_open(struct net_device *dev)
                lp->hw.open(dev);
 
        if (dev->dev_addr[0] == 0)
-               BUGMSG(D_NORMAL, "WARNING!  Station address 00 is reserved "
-                      "for broadcasts!\n");
+               BUGMSG(D_NORMAL, "WARNING!  Station address 00 is reserved for broadcasts!\n");
        else if (dev->dev_addr[0] == 255)
-               BUGMSG(D_NORMAL, "WARNING!  Station address FF may confuse "
-                      "DOS networking programs!\n");
+               BUGMSG(D_NORMAL, "WARNING!  Station address FF may confuse DOS networking programs!\n");
 
-       BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+       BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
        if (ASTATUS() & RESETflag) {
-               BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+               BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
                ACOMMAND(CFLAGScmd | RESETclear);
        }
 
-
-       BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+       BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
        /* make sure we're ready to receive IRQ's. */
        AINTMASK(0);
        udelay(1);              /* give it time to set the mask before
                                 * we reset it again. (may not even be
                                 * necessary)
                                 */
-       BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+       BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
        lp->intmask = NORXflag | RECONflag;
        AINTMASK(lp->intmask);
-       BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+       BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
 
        netif_start_queue(dev);
 
@@ -459,7 +439,6 @@ int arcnet_open(struct net_device *dev)
        return error;
 }
 
-
 /* The inverse routine to arcnet_open - shuts down the card. */
 int arcnet_close(struct net_device *dev)
 {
@@ -479,7 +458,6 @@ int arcnet_close(struct net_device *dev)
        return 0;
 }
 
-
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
                         unsigned short type, const void *daddr,
                         const void *saddr, unsigned len)
@@ -489,40 +467,35 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
        struct ArcProto *proto;
 
        BUGMSG(D_DURING,
-           "create header from %d to %d; protocol %d (%Xh); size %u.\n",
-              saddr ? *(uint8_t *) saddr : -1,
-              daddr ? *(uint8_t *) daddr : -1,
+              "create header from %d to %d; protocol %d (%Xh); size %u.\n",
+              saddr ? *(uint8_t *)saddr : -1,
+              daddr ? *(uint8_t *)daddr : -1,
               type, type, len);
 
-       if (skb->len!=0 && len != skb->len)
+       if (skb->len != 0 && len != skb->len)
                BUGMSG(D_NORMAL, "arcnet_header: Yikes!  skb->len(%d) != len(%d)!\n",
                       skb->len, len);
 
-
-       /* Type is host order - ? */
-       if(type == ETH_P_ARCNET) {
-               proto = arc_raw_proto;
-               BUGMSG(D_DEBUG, "arc_raw_proto used. proto='%c'\n",proto->suffix);
-               _daddr = daddr ? *(uint8_t *) daddr : 0;
-       }
-       else if (!daddr) {
-               /*
-                * if the dest addr isn't provided, we can't choose an encapsulation!
-                * Store the packet type (eg. ETH_P_IP) for now, and we'll push on a
-                * real header when we do rebuild_header.
-                */
-               *(uint16_t *) skb_push(skb, 2) = type;
-               /*
-                * XXX: Why not use skb->mac_len?
+       /* Type is host order - ? */
+       if (type == ETH_P_ARCNET) {
+               proto = arc_raw_proto;
+               BUGMSG(D_DEBUG, "arc_raw_proto used. proto='%c'\n", proto->suffix);
+               _daddr = daddr ? *(uint8_t *)daddr : 0;
+       } else if (!daddr) {
+               /* if the dest addr isn't provided, we can't choose an
+                * encapsulation!  Store the packet type (eg. ETH_P_IP)
+                * for now, and we'll push on a real header when we do
+                * rebuild_header.
                 */
+               *(uint16_t *)skb_push(skb, 2) = type;
+               /* XXX: Why not use skb->mac_len? */
                if (skb->network_header - skb->mac_header != 2)
                        BUGMSG(D_NORMAL, "arcnet_header: Yikes!  diff (%d) is not 2!\n",
                               (int)(skb->network_header - skb->mac_header));
                return -2;      /* return error -- can't transmit yet! */
-       }
-       else {
+       } else {
                /* otherwise, we can just add the header as usual. */
-               _daddr = *(uint8_t *) daddr;
+               _daddr = *(uint8_t *)daddr;
                proto_num = lp->default_proto[_daddr];
                proto = arc_proto_map[proto_num];
                BUGMSG(D_DURING, "building header for %02Xh using protocol '%c'\n",
@@ -538,7 +511,7 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
 
 /* Called by the kernel in order to transmit a packet. */
 netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
-                                    struct net_device *dev)
+                              struct net_device *dev)
 {
        struct arcnet_local *lp = netdev_priv(dev);
        struct archdr *pkt;
@@ -550,15 +523,16 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 
        BUGMSG(D_DURING,
               "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, protocol %x)\n",
-              ASTATUS(), lp->cur_tx, lp->next_tx, skb->len,skb->protocol);
+              ASTATUS(), lp->cur_tx, lp->next_tx, skb->len, skb->protocol);
 
-       pkt = (struct archdr *) skb->data;
+       pkt = (struct archdr *)skb->data;
        soft = &pkt->soft.rfc1201;
        proto = arc_proto_map[soft->proto];
 
        BUGMSG(D_SKB_SIZE, "skb: transmitting %d bytes to %02X\n",
-               skb->len, pkt->hard.dest);
-       BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "tx");
+              skb->len, pkt->hard.dest);
+       if (BUGLVL(D_SKB))
+               arcnet_dump_skb(dev, skb, "tx");
 
        /* fits in one packet? */
        if (skb->len - ARC_HDR_SIZE > XMTU && !proto->continue_tx) {
@@ -572,16 +546,17 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 
        spin_lock_irqsave(&lp->lock, flags);
        AINTMASK(0);
-       if(lp->next_tx == -1)
+       if (lp->next_tx == -1)
                txbuf = get_arcbuf(dev);
-       else {
+       else
                txbuf = -1;
-       }
+
        if (txbuf != -1) {
                if (proto->prepare_tx(dev, pkt, skb->len, txbuf) &&
                    !proto->ack_tx) {
                        /* done right away and we don't want to acknowledge
-                          the package later - forget about it now */
+                        *  the package later - forget about it now
+                        */
                        dev->stats.tx_bytes += skb->len;
                        freeskb = 1;
                } else {
@@ -594,9 +569,9 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
 
                        if (proto->continue_tx &&
                            proto->continue_tx(dev, txbuf)) {
-                         BUGMSG(D_NORMAL,
-                                "bug! continue_tx finished the first time! "
-                                "(proto='%c')\n", proto->suffix);
+                               BUGMSG(D_NORMAL,
+                                      "bug! continue_tx finished the first time! (proto='%c')\n",
+                                      proto->suffix);
                        }
                }
                retval = NETDEV_TX_OK;
@@ -606,25 +581,23 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
                freeskb = 0;
        }
 
-       BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());
+       BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n", __FILE__, __LINE__, __func__, ASTATUS());
        /* make sure we didn't ignore a TX IRQ while we were in here */
        AINTMASK(0);
 
-       BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
-       lp->intmask |= TXFREEflag|EXCNAKflag;
+       BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
+       lp->intmask |= TXFREEflag | EXCNAKflag;
        AINTMASK(lp->intmask);
-       BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());
+       BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n", __FILE__, __LINE__, __func__, ASTATUS());
 
        spin_unlock_irqrestore(&lp->lock, flags);
-       if (freeskb) {
+       if (freeskb)
                dev_kfree_skb(skb);
-       }
+
        return retval;          /* no need to try again */
 }
 
-
-/*
- * Actually start transmitting a packet that was loaded into a buffer
+/* Actually start transmitting a packet that was loaded into a buffer
  * by prepare_tx.  This should _only_ be called by the interrupt handler.
  */
 static int go_tx(struct net_device *dev)
@@ -637,7 +610,8 @@ static int go_tx(struct net_device *dev)
        if (lp->cur_tx != -1 || lp->next_tx == -1)
                return 0;
 
-       BUGLVL(D_TX) arcnet_dump_packet(dev, lp->next_tx, "go_tx", 0);
+       if (BUGLVL(D_TX))
+               arcnet_dump_packet(dev, lp->next_tx, "go_tx", 0);
 
        lp->cur_tx = lp->next_tx;
        lp->next_tx = -1;
@@ -649,12 +623,11 @@ static int go_tx(struct net_device *dev)
        lp->lasttrans_dest = lp->lastload_dest;
        lp->lastload_dest = 0;
        lp->excnak_pending = 0;
-       lp->intmask |= TXFREEflag|EXCNAKflag;
+       lp->intmask |= TXFREEflag | EXCNAKflag;
 
        return 1;
 }
 
-
 /* Called by the kernel when transmit times out */
 void arcnet_timeout(struct net_device *dev)
 {
@@ -676,12 +649,12 @@ void arcnet_timeout(struct net_device *dev)
 
        /* make sure we didn't miss a TX or a EXC NAK IRQ */
        AINTMASK(0);
-       lp->intmask |= TXFREEflag|EXCNAKflag;
+       lp->intmask |= TXFREEflag | EXCNAKflag;
        AINTMASK(lp->intmask);
-       
+
        spin_unlock_irqrestore(&lp->lock, flags);
 
-       if (time_after(jiffies, lp->last_timeout + 10*HZ)) {
+       if (time_after(jiffies, lp->last_timeout + 10 * HZ)) {
                BUGMSG(D_EXTRA, "tx timed out%s (status=%Xh, intmask=%Xh, dest=%02Xh)\n",
                       msg, status, lp->intmask, lp->lasttrans_dest);
                lp->last_timeout = jiffies;
@@ -691,9 +664,7 @@ void arcnet_timeout(struct net_device *dev)
                netif_wake_queue(dev);
 }
 
-
-/*
- * The typical workload of the driver: Handle the network interface
+/* The typical workload of the driver: Handle the network interface
  * interrupts. Establish which device needs attention, and call the correct
  * chipset interrupt handler.
  */
@@ -710,12 +681,11 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
        lp = netdev_priv(dev);
        BUG_ON(!lp);
-               
+
        spin_lock(&lp->lock);
 
-       /*
-        * RESET flag was enabled - if device is not running, we must clear it right
-        * away (but nothing else).
+       /* RESET flag was enabled - if device is not running, we must
+        * clear it right away (but nothing else).
         */
        if (!netif_running(dev)) {
                if (ASTATUS() & RESETflag)
@@ -731,17 +701,17 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
        boguscount = 5;
        do {
                status = ASTATUS();
-                diagstatus = (status >> 8) & 0xFF;
+               diagstatus = (status >> 8) & 0xFF;
 
                BUGMSG(D_DEBUG, "%s: %d: %s: status=%x\n",
-                       __FILE__,__LINE__,__func__,status);
+                      __FILE__, __LINE__, __func__, status);
                didsomething = 0;
 
-               /*
-                * RESET flag was enabled - card is resetting and if RX is
+               /* RESET flag was enabled - card is resetting and if RX is
                 * disabled, it's NOT because we just got a packet.
-                * 
-                * The card is in an undefined state.  Clear it out and start over.
+                *
+                * The card is in an undefined state.
+                * Clear it out and start over.
                 */
                if (status & RESETflag) {
                        BUGMSG(D_NORMAL, "spurious reset (status=%Xh)\n", status);
@@ -751,14 +721,13 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                        /* get out of the interrupt handler! */
                        break;
                }
-               /* 
-                * RX is inhibited - we must have received something. Prepare to
-                * receive into the next buffer.
-                * 
-                * We don't actually copy the received packet from the card until
-                * after the transmit handler runs (and possibly launches the next
-                * tx); this should improve latency slightly if we get both types
-                * of interrupts at once. 
+               /* RX is inhibited - we must have received something.
+                * Prepare to receive into the next buffer.
+                *
+                * We don't actually copy the received packet from the card
+                * until after the transmit handler runs (and possibly
+                * launches the next tx); this should improve latency slightly
+                * if we get both types of interrupts at once.
                 */
                recbuf = -1;
                if (status & lp->intmask & NORXflag) {
@@ -775,54 +744,52 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                        didsomething++;
                }
 
-               if((diagstatus & EXCNAKflag)) {
+               if ((diagstatus & EXCNAKflag)) {
                        BUGMSG(D_DURING, "EXCNAK IRQ (diagstat=%Xh)\n",
                               diagstatus);
 
-                        ACOMMAND(NOTXcmd);      /* disable transmit */
-                        lp->excnak_pending = 1;
+                       ACOMMAND(NOTXcmd);      /* disable transmit */
+                       lp->excnak_pending = 1;
 
-                        ACOMMAND(EXCNAKclear);
+                       ACOMMAND(EXCNAKclear);
                        lp->intmask &= ~(EXCNAKflag);
-                        didsomething++;
-                }
-
+                       didsomething++;
+               }
 
                /* a transmit finished, and we're interested in it. */
                if ((status & lp->intmask & TXFREEflag) || lp->timed_out) {
-                       lp->intmask &= ~(TXFREEflag|EXCNAKflag);
+                       lp->intmask &= ~(TXFREEflag | EXCNAKflag);
 
                        BUGMSG(D_DURING, "TX IRQ (stat=%Xh)\n", status);
 
                        if (lp->cur_tx != -1 && !lp->timed_out) {
-                               if(!(status & TXACKflag)) {
+                               if (!(status & TXACKflag)) {
                                        if (lp->lasttrans_dest != 0) {
                                                BUGMSG(D_EXTRA,
-                                                      "transmit was not acknowledged! "
-                                                      "(status=%Xh, dest=%02Xh)\n",
+                                                      "transmit was not acknowledged! (status=%Xh, dest=%02Xh)\n",
                                                       status, lp->lasttrans_dest);
                                                dev->stats.tx_errors++;
                                                dev->stats.tx_carrier_errors++;
                                        } else {
                                                BUGMSG(D_DURING,
-                                                      "broadcast was not acknowledged; that's normal "
-                                                      "(status=%Xh, dest=%02Xh)\n",
+                                                      "broadcast was not acknowledged; that's normal (status=%Xh, dest=%02Xh)\n",
                                                       status, lp->lasttrans_dest);
                                        }
                                }
 
                                if (lp->outgoing.proto &&
                                    lp->outgoing.proto->ack_tx) {
-                                 int ackstatus;
-                                 if(status & TXACKflag)
-                                    ackstatus=2;
-                                  else if(lp->excnak_pending)
-                                    ackstatus=1;
-                                  else
-                                    ackstatus=0;
-
-                                  lp->outgoing.proto
-                                    ->ack_tx(dev, ackstatus);
+                                       int ackstatus;
+
+                                       if (status & TXACKflag)
+                                               ackstatus = 2;
+                                       else if (lp->excnak_pending)
+                                               ackstatus = 1;
+                                       else
+                                               ackstatus = 0;
+
+                                       lp->outgoing.proto
+                                               ->ack_tx(dev, ackstatus);
                                }
                        }
                        if (lp->cur_tx != -1)
@@ -838,15 +805,15 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                        /* continue a split packet, if any */
                        if (lp->outgoing.proto && lp->outgoing.proto->continue_tx) {
                                int txbuf = get_arcbuf(dev);
+
                                if (txbuf != -1) {
                                        if (lp->outgoing.proto->continue_tx(dev, txbuf)) {
                                                /* that was the last segment */
                                                dev->stats.tx_bytes += lp->outgoing.skb->len;
-                                               if(!lp->outgoing.proto->ack_tx)
-                                                 {
-                                                   dev_kfree_skb_irq(lp->outgoing.skb);
-                                                   lp->outgoing.proto = NULL;
-                                                 }
+                                               if (!lp->outgoing.proto->ack_tx) {
+                                                       dev_kfree_skb_irq(lp->outgoing.skb);
+                                                       lp->outgoing.proto = NULL;
+                                               }
                                        }
                                        lp->next_tx = txbuf;
                                }
@@ -857,7 +824,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                }
                /* now process the received packet, if any */
                if (recbuf != -1) {
-                       BUGLVL(D_RX) arcnet_dump_packet(dev, recbuf, "rx irq", 0);
+                       if (BUGLVL(D_RX))
+                               arcnet_dump_packet(dev, recbuf, "rx irq", 0);
 
                        arcnet_rx(dev, recbuf);
                        release_arcbuf(dev, recbuf);
@@ -871,8 +839,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                        BUGMSG(D_RECON, "Network reconfiguration detected (status=%Xh)\n",
                               status);
                        /* MYRECON bit is at bit 7 of diagstatus */
-                       if(diagstatus & 0x80)
-                               BUGMSG(D_RECON,"Put out that recon myself\n");
+                       if (diagstatus & 0x80)
+                               BUGMSG(D_RECON, "Put out that recon myself\n");
 
                        /* is the RECON info empty or old? */
                        if (!lp->first_recon || !lp->last_recon ||
@@ -889,7 +857,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
 
                                BUGMSG(D_DURING, "recon: counter=%d, time=%lds, net=%d\n",
                                       lp->num_recons,
-                                (lp->last_recon - lp->first_recon) / HZ,
+                                      (lp->last_recon - lp->first_recon) / HZ,
                                       lp->network_down);
 
                                /* if network is marked up;
@@ -911,7 +879,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                                }
                        }
                } else if (lp->network_down &&
-                               time_after(jiffies, lp->last_recon + HZ * 10)) {
+                          time_after(jiffies, lp->last_recon + HZ * 10)) {
                        if (lp->network_down)
                                BUGMSG(D_NORMAL, "cabling restored?\n");
                        lp->first_recon = lp->last_recon = 0;
@@ -920,28 +888,23 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
                        BUGMSG(D_DURING, "not recon: clearing counters anyway.\n");
                }
 
-               if(didsomething) {
+               if (didsomething)
                        retval |= IRQ_HANDLED;
-               }
-       }
-       while (--boguscount && didsomething);
+       } while (--boguscount && didsomething);
 
        BUGMSG(D_DURING, "arcnet_interrupt complete (status=%Xh, count=%d)\n",
               ASTATUS(), boguscount);
        BUGMSG(D_DURING, "\n");
 
-
        AINTMASK(0);
        udelay(1);
        AINTMASK(lp->intmask);
-       
+
        spin_unlock(&lp->lock);
        return retval;
 }
 
-
-/*
- * This is a generic packet receiver that calls arcnet??_rx depending on the
+/* This is a generic packet receiver that calls arcnet??_rx depending on the
  * protocol ID found.
  */
 static void arcnet_rx(struct net_device *dev, int bufnum)
@@ -963,15 +926,14 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
        }
 
        /* get the full header, if possible */
-       if (sizeof(pkt.soft) <= length)
+       if (sizeof(pkt.soft) <= length) {
                lp->hw.copy_from_card(dev, bufnum, ofs, soft, sizeof(pkt.soft));
-       else {
+       else {
                memset(&pkt.soft, 0, sizeof(pkt.soft));
                lp->hw.copy_from_card(dev, bufnum, ofs, soft, length);
        }
 
-       BUGMSG(D_DURING, "Buffer #%d: received packet from %02Xh to %02Xh "
-              "(%d+4 bytes)\n",
+       BUGMSG(D_DURING, "Buffer #%d: received packet from %02Xh to %02Xh (%d+4 bytes)\n",
               bufnum, pkt.hard.source, pkt.hard.dest, length);
 
        dev->stats.rx_packets++;
@@ -979,15 +941,15 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
 
        /* call the right receiver for the protocol */
        if (arc_proto_map[soft->proto]->is_ip) {
-               BUGLVL(D_PROTO) {
+               if (BUGLVL(D_PROTO)) {
                        struct ArcProto
                        *oldp = arc_proto_map[lp->default_proto[pkt.hard.source]],
                        *newp = arc_proto_map[soft->proto];
 
                        if (oldp != newp) {
                                BUGMSG(D_PROTO,
-                                      "got protocol %02Xh; encap for host %02Xh is now '%c'"
-                                      " (was '%c')\n", soft->proto, pkt.hard.source,
+                                      "got protocol %02Xh; encap for host %02Xh is now '%c' (was '%c')\n",
+                                      soft->proto, pkt.hard.source,
                                       newp->suffix, oldp->suffix);
                        }
                }
@@ -1002,16 +964,14 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
        arc_proto_map[soft->proto]->rx(dev, bufnum, &pkt, length);
 }
 
-
 static void null_rx(struct net_device *dev, int bufnum,
                    struct archdr *pkthdr, int length)
 {
        BUGMSG(D_PROTO,
-       "rx: don't know how to deal with proto %02Xh from host %02Xh.\n",
+              "rx: don't know how to deal with proto %02Xh from host %02Xh.\n",
               pkthdr->soft.rfc1201.proto, pkthdr->hard.source);
 }
 
-
 static int null_build_header(struct sk_buff *skb, struct net_device *dev,
                             unsigned short type, uint8_t daddr)
 {
@@ -1025,7 +985,6 @@ static int null_build_header(struct sk_buff *skb, struct net_device *dev,
        return 0;
 }
 
-
 /* the "do nothing" prepare_tx function warns that there's nothing to do. */
 static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
                           int length, int bufnum)