arcnet: Convert BUGMSG and BUGMSG2 to arc_prink and arc_cont
[cascardo/linux.git] / drivers / net / arcnet / rfc1201.c
index 4abb20e..97af7d9 100644 (file)
@@ -81,8 +81,7 @@ static void __exit arcnet_rfc1201_exit(void)
 module_init(arcnet_rfc1201_init);
 module_exit(arcnet_rfc1201_exit);
 
-/*
- * Determine a packet's protocol ID.
+/* Determine a packet's protocol ID.
  *
  * With ARCnet we have to convert everything to Ethernet-style stuff.
  */
@@ -137,7 +136,8 @@ static void rx(struct net_device *dev, int bufnum,
        int saddr = pkt->hard.source, ofs;
        struct Incoming *in = &lp->rfc1201.incoming[saddr];
 
-       BUGMSG(D_DURING, "it's an RFC1201 packet (length=%d)\n", length);
+       arc_printk(D_DURING, dev, "it's an RFC1201 packet (length=%d)\n",
+                  length);
 
        if (length >= MinTU)
                ofs = 512 - length;
@@ -146,10 +146,10 @@ static void rx(struct net_device *dev, int bufnum,
 
        if (soft->split_flag == 0xFF) {         /* Exception Packet */
                if (length >= 4 + RFC1201_HDR_SIZE) {
-                       BUGMSG(D_DURING, "compensating for exception packet\n");
+                       arc_printk(D_DURING, dev, "compensating for exception packet\n");
                } else {
-                       BUGMSG(D_EXTRA, "short RFC1201 exception packet from %02Xh",
-                              saddr);
+                       arc_printk(D_EXTRA, dev, "short RFC1201 exception packet from %02Xh",
+                                  saddr);
                        return;
                }
 
@@ -160,12 +160,13 @@ static void rx(struct net_device *dev, int bufnum,
                                      soft, sizeof(pkt->soft));
        }
        if (!soft->split_flag) {        /* not split */
-               BUGMSG(D_RX, "incoming is not split (splitflag=%d)\n",
-                      soft->split_flag);
+               arc_printk(D_RX, dev, "incoming is not split (splitflag=%d)\n",
+                          soft->split_flag);
 
                if (in->skb) {  /* already assembling one! */
-                       BUGMSG(D_EXTRA, "aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
-                              in->sequence, soft->split_flag, soft->sequence);
+                       arc_printk(D_EXTRA, dev, "aborting assembly (seq=%d) for unsplit packet (splitflag=%d, seq=%d)\n",
+                                  in->sequence, soft->split_flag,
+                                  soft->sequence);
                        lp->rfc1201.aborted_seq = soft->sequence;
                        dev_kfree_skb_irq(in->skb);
                        dev->stats.rx_errors++;
@@ -176,7 +177,7 @@ static void rx(struct net_device *dev, int bufnum,
 
                skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
                if (skb == NULL) {
-                       BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
+                       arc_printk(D_NORMAL, dev, "Memory squeeze, dropping packet\n");
                        dev->stats.rx_dropped++;
                        return;
                }
@@ -193,10 +194,10 @@ static void rx(struct net_device *dev, int bufnum,
                                       pkt->soft.raw + sizeof(pkt->soft),
                                              length - sizeof(pkt->soft));
 
-               /*
-                * ARP packets have problems when sent from some DOS systems: the
-                * source address is always 0!  So we take the hardware source addr
-                * (which is impossible to fumble) and insert it ourselves.
+               /* ARP packets have problems when sent from some DOS systems:
+                * the source address is always 0!
+                * So we take the hardware source addr (which is impossible
+                * to fumble) and insert it ourselves.
                 */
                if (soft->proto == ARC_P_ARP) {
                        struct arphdr *arp = (struct arphdr *)soft->payload;
@@ -206,51 +207,53 @@ static void rx(struct net_device *dev, int bufnum,
                                uint8_t *cptr = (uint8_t *)arp + sizeof(struct arphdr);
 
                                if (!*cptr) {   /* is saddr = 00? */
-                                       BUGMSG(D_EXTRA,
-                                              "ARP source address was 00h, set to %02Xh.\n",
-                                              saddr);
+                                       arc_printk(D_EXTRA, dev,
+                                                  "ARP source address was 00h, set to %02Xh\n",
+                                                  saddr);
                                        dev->stats.rx_crc_errors++;
                                        *cptr = saddr;
                                } else {
-                                       BUGMSG(D_DURING, "ARP source address (%Xh) is fine.\n",
-                                              *cptr);
+                                       arc_printk(D_DURING, dev, "ARP source address (%Xh) is fine.\n",
+                                                  *cptr);
                                }
                        } else {
-                               BUGMSG(D_NORMAL, "funny-shaped ARP packet. (%Xh, %Xh)\n",
-                                      arp->ar_hln, arp->ar_pln);
+                               arc_printk(D_NORMAL, dev, "funny-shaped ARP packet. (%Xh, %Xh)\n",
+                                          arp->ar_hln, arp->ar_pln);
                                dev->stats.rx_errors++;
                                dev->stats.rx_crc_errors++;
                        }
                }
-               BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
+               if (BUGLVL(D_SKB))
+                       arcnet_dump_skb(dev, skb, "rx");
 
                skb->protocol = type_trans(skb, dev);
                netif_rx(skb);
        } else {                /* split packet */
-               /*
-                * NOTE: MSDOS ARP packet correction should only need to apply to
-                * unsplit packets, since ARP packets are so short.
+               /* NOTE: MSDOS ARP packet correction should only need to
+                * apply to unsplit packets, since ARP packets are so short.
                 *
-                * My interpretation of the RFC1201 document is that if a packet is
-                * received out of order, the entire assembly process should be
-                * aborted.
+                * My interpretation of the RFC1201 document is that if a
+                * packet is received out of order, the entire assembly
+                * process should be aborted.
                 *
-                * The RFC also mentions "it is possible for successfully received
-                * packets to be retransmitted." As of 0.40 all previously received
-                * packets are allowed, not just the most recent one.
+                * The RFC also mentions "it is possible for successfully
+                * received packets to be retransmitted." As of 0.40 all
+                * previously received packets are allowed, not just the
+                * most recent one.
                 *
-                * We allow multiple assembly processes, one for each ARCnet card
-                * possible on the network.  Seems rather like a waste of memory,
-                * but there's no other way to be reliable.
+                * We allow multiple assembly processes, one for each
+                * ARCnet card possible on the network.
+                * Seems rather like a waste of memory, but there's no
+                * other way to be reliable.
                 */
 
-               BUGMSG(D_RX, "packet is split (splitflag=%d, seq=%d)\n",
-                      soft->split_flag, in->sequence);
+               arc_printk(D_RX, dev, "packet is split (splitflag=%d, seq=%d)\n",
+                          soft->split_flag, in->sequence);
 
                if (in->skb && in->sequence != soft->sequence) {
-                       BUGMSG(D_EXTRA, "wrong seq number (saddr=%d, expected=%d, seq=%d, splitflag=%d)\n",
-                              saddr, in->sequence, soft->sequence,
-                              soft->split_flag);
+                       arc_printk(D_EXTRA, dev, "wrong seq number (saddr=%d, expected=%d, seq=%d, splitflag=%d)\n",
+                                  saddr, in->sequence, soft->sequence,
+                                  soft->split_flag);
                        dev_kfree_skb_irq(in->skb);
                        in->skb = NULL;
                        dev->stats.rx_errors++;
@@ -258,13 +261,12 @@ static void rx(struct net_device *dev, int bufnum,
                        in->lastpacket = in->numpackets = 0;
                }
                if (soft->split_flag & 1) {     /* first packet in split */
-                       BUGMSG(D_RX, "brand new splitpacket (splitflag=%d)\n",
-                              soft->split_flag);
+                       arc_printk(D_RX, dev, "brand new splitpacket (splitflag=%d)\n",
+                                  soft->split_flag);
                        if (in->skb) {  /* already assembling one! */
-                               BUGMSG(D_EXTRA, "aborting previous (seq=%d) assembly "
-                                      "(splitflag=%d, seq=%d)\n",
-                                      in->sequence, soft->split_flag,
-                                      soft->sequence);
+                               arc_printk(D_EXTRA, dev, "aborting previous (seq=%d) assembly (splitflag=%d, seq=%d)\n",
+                                          in->sequence, soft->split_flag,
+                                          soft->sequence);
                                dev->stats.rx_errors++;
                                dev->stats.rx_missed_errors++;
                                dev_kfree_skb_irq(in->skb);
@@ -274,8 +276,8 @@ static void rx(struct net_device *dev, int bufnum,
                        in->lastpacket = 1;
 
                        if (in->numpackets > 16) {
-                               BUGMSG(D_EXTRA, "incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
-                                      soft->split_flag);
+                               arc_printk(D_EXTRA, dev, "incoming packet more than 16 segments; dropping. (splitflag=%d)\n",
+                                          soft->split_flag);
                                lp->rfc1201.aborted_seq = soft->sequence;
                                dev->stats.rx_errors++;
                                dev->stats.rx_length_errors++;
@@ -284,7 +286,7 @@ static void rx(struct net_device *dev, int bufnum,
                        in->skb = skb = alloc_skb(508 * in->numpackets + ARC_HDR_SIZE,
                                                  GFP_ATOMIC);
                        if (skb == NULL) {
-                               BUGMSG(D_NORMAL, "(split) memory squeeze, dropping packet.\n");
+                               arc_printk(D_NORMAL, dev, "(split) memory squeeze, dropping packet.\n");
                                lp->rfc1201.aborted_seq = soft->sequence;
                                dev->stats.rx_dropped++;
                                return;
@@ -300,16 +302,15 @@ static void rx(struct net_device *dev, int bufnum,
                } else {        /* not first packet */
                        int packetnum = ((unsigned)soft->split_flag >> 1) + 1;
 
-                       /*
-                        * if we're not assembling, there's no point trying to
+                       /* if we're not assembling, there's no point trying to
                         * continue.
                         */
                        if (!in->skb) {
                                if (lp->rfc1201.aborted_seq != soft->sequence) {
-                                       BUGMSG(D_EXTRA, "can't continue split without starting "
-                                              "first! (splitflag=%d, seq=%d, aborted=%d)\n",
-                                       soft->split_flag, soft->sequence,
-                                              lp->rfc1201.aborted_seq);
+                                       arc_printk(D_EXTRA, dev, "can't continue split without starting first! (splitflag=%d, seq=%d, aborted=%d)\n",
+                                                  soft->split_flag,
+                                                  soft->sequence,
+                                                  lp->rfc1201.aborted_seq);
                                        dev->stats.rx_errors++;
                                        dev->stats.rx_missed_errors++;
                                }
@@ -319,16 +320,16 @@ static void rx(struct net_device *dev, int bufnum,
                        if (packetnum != in->lastpacket) {      /* not the right flag! */
                                /* harmless duplicate? ignore. */
                                if (packetnum <= in->lastpacket - 1) {
-                                       BUGMSG(D_EXTRA, "duplicate splitpacket ignored! (splitflag=%d)\n",
-                                              soft->split_flag);
+                                       arc_printk(D_EXTRA, dev, "duplicate splitpacket ignored! (splitflag=%d)\n",
+                                                  soft->split_flag);
                                        dev->stats.rx_errors++;
                                        dev->stats.rx_frame_errors++;
                                        return;
                                }
                                /* "bad" duplicate, kill reassembly */
-                               BUGMSG(D_EXTRA, "out-of-order splitpacket, reassembly "
-                                      "(seq=%d) aborted (splitflag=%d, seq=%d)\n",
-                                      in->sequence, soft->split_flag, soft->sequence);
+                               arc_printk(D_EXTRA, dev, "out-of-order splitpacket, reassembly (seq=%d) aborted (splitflag=%d, seq=%d)\n",
+                                          in->sequence, soft->split_flag,
+                                          soft->sequence);
                                lp->rfc1201.aborted_seq = soft->sequence;
                                dev_kfree_skb_irq(in->skb);
                                in->skb = NULL;
@@ -353,11 +354,12 @@ static void rx(struct net_device *dev, int bufnum,
                        in->skb = NULL;
                        in->lastpacket = in->numpackets = 0;
 
-                       BUGMSG(D_SKB_SIZE, "skb: received %d bytes from %02X (unsplit)\n",
-                              skb->len, pkt->hard.source);
-                       BUGMSG(D_SKB_SIZE, "skb: received %d bytes from %02X (split)\n",
-                              skb->len, pkt->hard.source);
-                       BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
+                       arc_printk(D_SKB_SIZE, dev, "skb: received %d bytes from %02X (unsplit)\n",
+                                  skb->len, pkt->hard.source);
+                       arc_printk(D_SKB_SIZE, dev, "skb: received %d bytes from %02X (split)\n",
+                                  skb->len, pkt->hard.source);
+                       if (BUGLVL(D_SKB))
+                               arcnet_dump_skb(dev, skb, "rx");
 
                        skb->protocol = type_trans(skb, dev);
                        netif_rx(skb);
@@ -397,19 +399,18 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
                soft->proto = ARC_P_ATALK;
                break;
        default:
-               BUGMSG(D_NORMAL, "RFC1201: I don't understand protocol %d (%Xh)\n",
-                      type, type);
+               arc_printk(D_NORMAL, dev, "RFC1201: I don't understand protocol %d (%Xh)\n",
+                          type, type);
                dev->stats.tx_errors++;
                dev->stats.tx_aborted_errors++;
                return 0;
        }
 
-       /*
-        * Set the source hardware address.
+       /* 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
-        * the actual packet sent)
+        * debugging.  ARCnet does not allow us to change the source address
+        * in the actual packet sent.
         */
        pkt->hard.source = *dev->dev_addr;
 
@@ -419,10 +420,10 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
        /* 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.  For now, always broadcasting
-                * will probably at least get packets sent out :)
+               /* FIXME: fill in the last byte of the dest ipaddr here
+                * to better comply with RFC1051 in "noarp" mode.
+                * For now, always broadcasting will probably at least get
+                * packets sent out :)
                 */
                pkt->hard.dest = 0;
                return hdr_size;
@@ -472,8 +473,8 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
        const int maxsegsize = XMTU - RFC1201_HDR_SIZE;
        struct Outgoing *out;
 
-       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);
 
        length -= ARC_HDR_SIZE; /* hard header is not included in packet length */
        pkt->soft.rfc1201.split_flag = 0;
@@ -487,9 +488,9 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
                out->numsegs = (out->dataleft + maxsegsize - 1) / maxsegsize;
                out->segnum = 0;
 
-               BUGMSG(D_DURING, "rfc1201 prep_tx: ready for %d-segment split "
-                      "(%d bytes, seq=%d)\n", out->numsegs, out->length,
-                      pkt->soft.rfc1201.sequence);
+               arc_printk(D_DURING, dev, "rfc1201 prep_tx: ready for %d-segment split (%d bytes, seq=%d)\n",
+                          out->numsegs, out->length,
+                          pkt->soft.rfc1201.sequence);
 
                return 0;       /* not done */
        }
@@ -508,9 +509,9 @@ static int continue_tx(struct net_device *dev, int bufnum)
        int maxsegsize = XMTU - RFC1201_HDR_SIZE;
        int seglen;
 
-       BUGMSG(D_DURING,
-              "rfc1201 continue_tx: loading segment %d(+1) of %d (seq=%d)\n",
-              out->segnum, out->numsegs, soft->sequence);
+       arc_printk(D_DURING, dev,
+                  "rfc1201 continue_tx: loading segment %d(+1) of %d (seq=%d)\n",
+                  out->segnum, out->numsegs, soft->sequence);
 
        /* the "new" soft header comes right before the data chunk */
        newsoft = (struct arc_rfc1201 *)