staging: gdm72xx: use print_hex_dump_debug and remove debug macros
authorKristina Martšenko <kristina.martsenko@gmail.com>
Fri, 14 Mar 2014 23:10:04 +0000 (01:10 +0200)
committerPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Mon, 17 Mar 2014 02:53:58 +0000 (19:53 -0700)
Since the kernel already has a function for hex dumps, use that instead
of the driver's own versions. The function supports dynamic debugging,
so also remove some unnecessary debug macros.

Signed-off-by: Kristina Martšenko <kristina.martsenko@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
drivers/staging/gdm72xx/gdm_sdio.c
drivers/staging/gdm72xx/gdm_usb.c
drivers/staging/gdm72xx/gdm_wimax.c
drivers/staging/gdm72xx/gdm_wimax.h

index 047a4d7..e469881 100644 (file)
 static int init_sdio(struct sdiowm_dev *sdev);
 static void release_sdio(struct sdiowm_dev *sdev);
 
-#ifdef DEBUG
-static void hexdump(char *title, u8 *data, int len)
-{
-       int i;
-
-       printk(KERN_DEBUG "%s: length = %d\n", title, len);
-       for (i = 0; i < len; i++) {
-               printk(KERN_DEBUG "%02x ", data[i]);
-               if ((i & 0xf) == 0xf)
-                       printk(KERN_DEBUG "\n");
-       }
-       printk(KERN_DEBUG "\n");
-}
-#endif
-
 static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx)
 {
        struct sdio_tx *t = kzalloc(sizeof(*t), GFP_ATOMIC);
@@ -297,10 +282,9 @@ static void send_sdu(struct sdio_func *func, struct tx_cxt *tx)
 
        spin_unlock_irqrestore(&tx->lock, flags);
 
-#ifdef DEBUG
-       hexdump("sdio_send", tx->sdu_buf + TYPE_A_HEADER_SIZE,
-               aggr_len - TYPE_A_HEADER_SIZE);
-#endif
+       print_hex_dump_debug("sdio_send: ", DUMP_PREFIX_NONE, 16, 1,
+                            tx->sdu_buf + TYPE_A_HEADER_SIZE,
+                            aggr_len - TYPE_A_HEADER_SIZE, false);
 
        for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) {
                len = aggr_len - pos;
@@ -335,10 +319,9 @@ static void send_hci(struct sdio_func *func, struct tx_cxt *tx,
 {
        unsigned long flags;
 
-#ifdef DEBUG
-       hexdump("sdio_send", t->buf + TYPE_A_HEADER_SIZE,
-               t->len - TYPE_A_HEADER_SIZE);
-#endif
+       print_hex_dump_debug("sdio_send: ", DUMP_PREFIX_NONE, 16, 1,
+                            t->buf + TYPE_A_HEADER_SIZE,
+                            t->len - TYPE_A_HEADER_SIZE, false);
        send_sdio_pkt(func, t->buf, t->len);
 
        spin_lock_irqsave(&tx->lock, flags);
@@ -579,9 +562,8 @@ static void gdm_sdio_irq(struct sdio_func *func)
        }
 
 end_io:
-#ifdef DEBUG
-       hexdump("sdio_receive", rx->rx_buf, len);
-#endif
+       print_hex_dump_debug("sdio_receive: ", DUMP_PREFIX_NONE, 16, 1,
+                            rx->rx_buf, len, false);
        len = control_sdu_tx_flow(sdev, rx->rx_buf, len);
 
        spin_lock_irqsave(&rx->lock, flags);
index cdeffe7..ff0e573 100644 (file)
@@ -56,20 +56,6 @@ static int init_usb(struct usbwm_dev *udev);
 static void release_usb(struct usbwm_dev *udev);
 
 /*#define DEBUG */
-#ifdef DEBUG
-static void hexdump(char *title, u8 *data, int len)
-{
-       int i;
-
-       printk(KERN_DEBUG "%s: length = %d\n", title, len);
-       for (i = 0; i < len; i++) {
-               printk(KERN_DEBUG "%02x ", data[i]);
-               if ((i & 0xf) == 0xf)
-                       printk(KERN_DEBUG "\n");
-       }
-       printk(KERN_DEBUG "\n");
-}
-#endif
 
 static struct usb_tx *alloc_tx_struct(struct tx_cxt *tx)
 {
@@ -368,9 +354,8 @@ static int gdm_usb_send(void *priv_dev, void *data, int len,
                        gdm_usb_send_complete,
                        t);
 
-#ifdef DEBUG
-       hexdump("usb_send", t->buf, len + padding);
-#endif
+       print_hex_dump_debug("usb_send: ", DUMP_PREFIX_NONE, 16, 1,
+                            t->buf, len + padding, false);
 #ifdef CONFIG_WIMAX_GDM72XX_USB_PM
        if (usbdev->state & USB_STATE_SUSPENDED) {
                list_add_tail(&t->p_list, &tx->pending_list);
@@ -451,9 +436,8 @@ static void gdm_usb_rcv_complete(struct urb *urb)
 
        if (!urb->status) {
                cmd_evt = (r->buf[0] << 8) | (r->buf[1]);
-#ifdef DEBUG
-               hexdump("usb_receive", r->buf, urb->actual_length);
-#endif
+               print_hex_dump_debug("usb_receive: ", DUMP_PREFIX_NONE, 16, 1,
+                                    r->buf, urb->actual_length, false);
                if (cmd_evt == WIMAX_SDU_TX_FLOW) {
                        if (r->buf[4] == 0) {
 #ifdef DEBUG
index df93a73..dd2d807 100644 (file)
@@ -63,20 +63,6 @@ static void gdm_wimax_ind_fsm_update(struct net_device *dev, struct fsm_s *fsm);
 static void gdm_wimax_ind_if_updown(struct net_device *dev, int if_up);
 
 #if defined(DEBUG_SDU)
-static void printk_hex(u8 *buf, u32 size)
-{
-       int i;
-
-       for (i = 0; i < size; i++) {
-               if (i && i % 16 == 0)
-                       printk(KERN_DEBUG "\n%02x ", *buf++);
-               else
-                       printk(KERN_DEBUG "%02x ", *buf++);
-       }
-
-       printk(KERN_DEBUG "\n");
-}
-
 static const char *get_protocol_name(u16 protocol)
 {
        static char buf[32];
@@ -175,31 +161,7 @@ static void dump_eth_packet(const char *title, u8 *data, int len)
                        printk(KERN_DEBUG "     src=%pI6\n", &ih->saddr);
        }
 
-       #if (DUMP_PACKET & DUMP_SDU_ALL)
-       printk_hex(data, len);
-       #else
-               #if (DUMP_PACKET & DUMP_SDU_ARP)
-               if (protocol == ETH_P_ARP)
-                       printk_hex(data, len);
-               #endif
-               #if (DUMP_PACKET & DUMP_SDU_IP)
-               if (protocol == ETH_P_IP || protocol == ETH_P_IPV6)
-                       printk_hex(data, len);
-               #else
-                       #if (DUMP_PACKET & DUMP_SDU_IP_TCP)
-                       if (ip_protocol == IPPROTO_TCP)
-                               printk_hex(data, len);
-                       #endif
-                       #if (DUMP_PACKET & DUMP_SDU_IP_UDP)
-                       if (ip_protocol == IPPROTO_UDP)
-                               printk_hex(data, len);
-                       #endif
-                       #if (DUMP_PACKET & DUMP_SDU_IP_ICMP)
-                       if (ip_protocol == IPPROTO_ICMP)
-                               printk_hex(data, len);
-                       #endif
-               #endif
-       #endif
+       print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, data, len, false);
 }
 #endif
 
index 6ec0ab4..7b603f8 100644 (file)
@@ -62,23 +62,7 @@ struct nic {
 
 };
 
-
-#if 0
-#define dprintk(fmt, args ...) printk(KERN_DEBUG " [GDM] " fmt, ## args)
-#else
-#define dprintk(...)
-#endif
-
 /*#define DEBUG_SDU */
-#if defined(DEBUG_SDU)
-#define DUMP_SDU_ALL           (1<<0)
-#define DUMP_SDU_ARP           (1<<1)
-#define DUMP_SDU_IP                    (1<<2)
-#define DUMP_SDU_IP_TCP                (1<<8)
-#define DUMP_SDU_IP_UDP                (1<<9)
-#define DUMP_SDU_IP_ICMP       (1<<10)
-#define DUMP_PACKET                    (DUMP_SDU_ALL)
-#endif
 
 /*#define DEBUG_HCI */