Skip to contentSkip to conversation

6lowpan: fix/move/cleanup debug functions

PATCH In review Alexander Aring 2 participants 2 messages Dec 12, 2013

Subsystems (4)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/1 6lowpan: fix/move/cleanup debug functions

There are several issues on current debug behaviour. This patch fix the following issues:

- Fix debug printout only if DEBUG is defined.
- Move debug functions of 6LoWPAN code into 6lowpan header.
- Cleanup codestyle of debug functions.

---
 net/bluetooth/6lowpan.c       | 27 ---------------------------
 net/ieee802154/6lowpan.c      | 43 +++++--------------------------------------
 net/ieee802154/6lowpan.h      | 32 ++++++++++++++++++++++++++++++++
 net/ieee802154/6lowpan_iphc.c | 26 --------------------------
 4 files changed, 37 insertions(+), 91 deletions(-)
net/bluetooth/6lowpan.c +0 -27
index 5ad8b48..37239db 100644
@@ -167,33 +167,6 @@ static struct lowpan_dev *lookup_dev(struct l2cap_conn *conn)
 	return dev;
 }
 
-/* print data in line */
-static inline void raw_dump_inline(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s: ", caller, msg);
-
-	print_hex_dump_debug("", DUMP_PREFIX_NONE,
-			     16, 1, buf, len, false);
-}
-
-/* print data in a table format:
- *
- * addr: xx xx xx xx xx xx
- * addr: xx xx xx xx xx xx
- * ...
- */
-static inline void raw_dump_table(const char *caller, char *msg,
-				  unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s:\n", caller, msg);
-
-	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET,
-			     16, 1, buf, len, false);
-}
-
 static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
 {
 	struct sk_buff *skb_cp;
net/ieee802154/6lowpan.c +5 -38

73 lines not on this page · raw message

net/ieee802154/6lowpan.h +32 -0
index 535606d..10909e5 100644
@@ -232,6 +232,38 @@
 					dest = 16 bit inline */
 #define LOWPAN_NHC_UDP_CS_P_11	0xF3 /* source & dest = 0xF0B + 4bit inline */
 
+#ifdef DEBUG
+/* print data in line */
+static inline void raw_dump_inline(const char *caller, char *msg,
+				   unsigned char *buf, int len)
+{
+	if (msg)
+		pr_debug("%s():%s: ", caller, msg);
+
+	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, buf, len, false);
+}
+
+/* print data in a table format:
+ *
+ * addr: xx xx xx xx xx xx
+ * addr: xx xx xx xx xx xx
+ * ...
+ */
+static inline void raw_dump_table(const char *caller, char *msg,
+				  unsigned char *buf, int len)
+{
+	if (msg)
+		pr_debug("%s():%s:\n", caller, msg);
+
+	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET, 16, 1, buf, len, false);
+}
+#else
+static inline void raw_dump_table(const char *caller, char *msg,
+				  unsigned char *buf, int len) { }
+static inline void raw_dump_inline(const char *caller, char *msg,
+				   unsigned char *buf, int len) { }
+#endif
+
 static inline int lowpan_fetch_skb_u8(struct sk_buff *skb, u8 *val)
 {
 	if (unlikely(!pskb_may_pull(skb, 1)))
net/ieee802154/6lowpan_iphc.c +0 -26
index 57c0b7a..88e7da5 100644
@@ -58,32 +58,6 @@
 
 #include "6lowpan.h"
 
-/* print data in line */
-static inline void raw_dump_inline(const char *caller, char *msg,
-				   unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s: ", caller, msg);
-	print_hex_dump_debug("", DUMP_PREFIX_NONE,
-		       16, 1, buf, len, false);
-}
-
-/*
- * print data in a table format:
- *
- * addr: xx xx xx xx xx xx
- * addr: xx xx xx xx xx xx
- * ...
- */
-static inline void raw_dump_table(const char *caller, char *msg,
-				unsigned char *buf, int len)
-{
-	if (msg)
-		pr_debug("%s():%s:\n", caller, msg);
-	print_hex_dump_debug("\t", DUMP_PREFIX_OFFSET,
-		       16, 1, buf, len, false);
-}
-
 /*
  * Uncompress address function for source and
  * destination address(non-multicast).
Signature · 1 line
1.8.5.1
maintainer
#1 lore raw

Hi Alex,

Quoted 7 lines

There are several issues on current debug behaviour. This patch fix the following issues:

- Fix debug printout only if DEBUG is defined.
- Move debug functions of 6LoWPAN code into 6lowpan header.
- Cleanup codestyle of debug functions.

Quoted 7 lines

---

net/bluetooth/6lowpan.c       | 27 ---------------------------
net/ieee802154/6lowpan.c      | 43 +++++--------------------------------------
net/ieee802154/6lowpan.h      | 32 ++++++++++++++++++++++++++++++++
net/ieee802154/6lowpan_iphc.c | 26 --------------------------
4 files changed, 37 insertions(+), 91 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel