arcnet: Remove unnecessary OOM messages
[cascardo/linux.git] / drivers / net / arcnet / capmode.c
index 02815ff..de80d9e 100644 (file)
@@ -26,6 +26,8 @@
  * **********************
  */
 
+#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/gfp.h>
 #include <linux/init.h>
@@ -35,8 +37,6 @@
 #include <linux/skbuff.h>
 #include <linux/arcdevice.h>
 
-#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
-
 /* packet receiver */
 static void rx(struct net_device *dev, int bufnum,
               struct archdr *pkthdr, int length)
@@ -47,7 +47,8 @@ static void rx(struct net_device *dev, int bufnum,
        char *pktbuf, *pkthdrbuf;
        int ofs;
 
-       BUGMSG(D_DURING, "it's a raw(cap) packet (length=%d)\n", length);
+       arc_printk(D_DURING, dev, "it's a raw(cap) packet (length=%d)\n",
+                  length);
 
        if (length >= MinTU)
                ofs = 512 - length;
@@ -56,7 +57,6 @@ static void rx(struct net_device *dev, int bufnum,
 
        skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
        if (skb == NULL) {
-               BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
                dev->stats.rx_dropped++;
                return;
        }
@@ -66,11 +66,11 @@ static void rx(struct net_device *dev, int bufnum,
        pkt = (struct archdr *)skb_mac_header(skb);
        skb_pull(skb, ARC_HDR_SIZE);
 
-       /* up to sizeof(pkt->soft) has already been copied from the card */
-       /* squeeze in an int for the cap encapsulation */
-
-       /* use these variables to be sure we count in bytes, not in
-          sizeof(struct archdr) */
+       /* up to sizeof(pkt->soft) has already been copied from the card
+        * squeeze in an int for the cap encapsulation
+        * use these variables to be sure we count in bytes, not in
+        * sizeof(struct archdr)
+        */
        pktbuf = (char *)pkt;
        pkthdrbuf = (char *)pkthdr;
        memcpy(pktbuf, pkthdrbuf, ARC_HDR_SIZE + sizeof(pkt->soft.cap.proto));
@@ -84,14 +84,14 @@ static void rx(struct net_device *dev, int bufnum,
                                      + sizeof(int),
                                      length - sizeof(pkt->soft));
 
-       BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
+       if (BUGLVL(D_SKB))
+               arcnet_dump_skb(dev, skb, "rx");
 
        skb->protocol = cpu_to_be16(ETH_P_ARCNET);
        netif_rx(skb);
 }
 
-/*
- * Create the ARCnet hard/soft headers for cap mode.
+/* Create the ARCnet hard/soft headers for cap mode.
  * There aren't any soft headers in cap mode - not even the protocol id.
  */
 static int build_header(struct sk_buff *skb,
@@ -102,10 +102,10 @@ static int build_header(struct sk_buff *skb,
        int hdr_size = ARC_HDR_SIZE;
        struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
 
-       BUGMSG(D_PROTO, "Preparing header for cap packet %x.\n",
-              *((int *)&pkt->soft.cap.cookie[0]));
-       /*
-        * Set the source hardware address.
+       arc_printk(D_PROTO, dev, "Preparing header for cap packet %x.\n",
+                  *((int *)&pkt->soft.cap.cookie[0]));
+
+       /* Set the source hardware address.
         *
         * This is pretty pointless for most purposes, but it can help in
         * debugging.  ARCnet does not allow us to change the source address in
@@ -116,9 +116,8 @@ static int build_header(struct sk_buff *skb,
        /* see linux/net/ethernet/eth.c to see where I got the following */
 
        if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
-               /*
-                * FIXME: fill in the last byte of the dest ipaddr here to better
-                * comply with RFC1051 in "noarp" mode.
+               /* FIXME: fill in the last byte of the dest ipaddr here to
+                * better comply with RFC1051 in "noarp" mode.
                 */
                pkt->hard.dest = 0;
                return hdr_size;
@@ -141,16 +140,16 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
        /* And neither is the cookie field */
        length -= sizeof(int);
 
-       BUGMSG(D_DURING, "prepare_tx: txbufs=%d/%d/%d\n",
-              lp->next_tx, lp->cur_tx, bufnum);
+       arc_printk(D_DURING, dev, "prepare_tx: txbufs=%d/%d/%d\n",
+                  lp->next_tx, lp->cur_tx, bufnum);
 
-       BUGMSG(D_PROTO, "Sending for cap packet %x.\n",
-              *((int *)&pkt->soft.cap.cookie[0]));
+       arc_printk(D_PROTO, dev, "Sending for cap packet %x.\n",
+                  *((int *)&pkt->soft.cap.cookie[0]));
 
        if (length > XMTU) {
                /* should never happen! other people already check for this. */
-               BUGMSG(D_NORMAL, "Bug!  prepare_tx with size %d (> %d)\n",
-                      length, XMTU);
+               arc_printk(D_NORMAL, dev, "Bug!  prepare_tx with size %d (> %d)\n",
+                          length, XMTU);
                length = XMTU;
        }
        if (length > MinTU) {
@@ -159,11 +158,12 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
        } else if (length > MTU) {
                hard->offset[0] = 0;
                hard->offset[1] = ofs = 512 - length - 3;
-       } else
+       } else {
                hard->offset[0] = ofs = 256 - length;
+       }
 
-       BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
-              length, ofs);
+       arc_printk(D_DURING, dev, "prepare_tx: length=%d ofs=%d\n",
+                  length, ofs);
 
        /* Copy the arcnet-header + the protocol byte down: */
        lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
@@ -171,7 +171,8 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
                            sizeof(pkt->soft.cap.proto));
 
        /* Skip the extra integer we have written into it as a cookie
-          but write the rest of the message: */
+        * but write the rest of the message:
+        */
        lp->hw.copy_to_card(dev, bufnum, ofs + 1,
                            ((unsigned char *)&pkt->soft.cap.mes), length - 1);
 
@@ -187,17 +188,16 @@ static int ack_tx(struct net_device *dev, int acked)
        struct archdr *ackpkt;
        int length = sizeof(struct arc_cap);
 
-       BUGMSG(D_DURING, "capmode: ack_tx: protocol: %x: result: %d\n",
-              lp->outgoing.skb->protocol, acked);
+       arc_printk(D_DURING, dev, "capmode: ack_tx: protocol: %x: result: %d\n",
+                  lp->outgoing.skb->protocol, acked);
 
-       BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");
+       if (BUGLVL(D_SKB))
+               arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");
 
        /* Now alloc a skb to send back up through the layers: */
        ackskb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
-       if (ackskb == NULL) {
-               BUGMSG(D_NORMAL, "Memory squeeze, can't acknowledge.\n");
+       if (ackskb == NULL)
                goto free_outskb;
-       }
 
        skb_put(ackskb, length + ARC_HDR_SIZE);
        ackskb->dev = dev;
@@ -211,12 +211,13 @@ static int ack_tx(struct net_device *dev, int acked)
        ackpkt->soft.cap.proto = 0; /* using protocol 0 for acknowledge */
        ackpkt->soft.cap.mes.ack = acked;
 
-       BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
-              *((int *)&ackpkt->soft.cap.cookie[0]));
+       arc_printk(D_PROTO, dev, "Ackknowledge for cap packet %x.\n",
+                  *((int *)&ackpkt->soft.cap.cookie[0]));
 
        ackskb->protocol = cpu_to_be16(ETH_P_ARCNET);
 
-       BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
+       if (BUGLVL(D_SKB))
+               arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
        netif_rx(ackskb);
 
 free_outskb:
@@ -226,8 +227,7 @@ free_outskb:
        return 0;
 }
 
-static struct ArcProto capmode_proto =
-{
+static struct ArcProto capmode_proto = {
        'r',
        XMTU,
        0,
@@ -256,7 +256,7 @@ static void arcnet_cap_init(void)
 
 static int __init capmode_module_init(void)
 {
-       printk(VERSION);
+       pr_info("%s\n", "cap mode (`c') encapsulation support loaded");
        arcnet_cap_init();
        return 0;
 }