From 6e4b36131844e7b41e4b800612156e908203dd8d Mon Sep 17 00:00:00 2001
From: Antti Palosaari <antti@RH-LinuX.(none)>
Date: Fri, 8 Mar 2013 18:06:41 +0100
Subject: [PATCH 1/3] em28xx: add USB message debug dump

---
 drivers/media/usb/em28xx/em28xx-core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index 0c5fdba..f7c9527 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -67,6 +67,17 @@ MODULE_PARM_DESC(disable_vbi, "disable vbi support");
 		printk(KERN_INFO "%s %s :"fmt, \
 			 dev->name, __func__ , ##arg); } while (0)
 
+#define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \
+	char *direction; \
+	if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
+		direction = ">>>"; \
+	else \
+		direction = "<<<"; \
+	dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \
+			"%s %*ph\n",  "em28xx", t, r, v & 0xff, v >> 8, \
+			i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \
+}
+
 /*
  * em28xx_read_reg_req()
  * reads data from the usb device specifying bRequest
@@ -97,6 +108,10 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
 	ret = usb_control_msg(dev->udev, pipe, req,
 			      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 			      0x0000, reg, dev->urb_buf, len, HZ);
+	dvb_usb_dbg_usb_control_msg(dev->udev, req,
+			(USB_DIR_IN | USB_TYPE_VENDOR), 0x0000, reg,
+			dev->urb_buf, len);
+
 	if (ret < 0) {
 		if (reg_debug)
 			printk(" failed!\n");
@@ -180,6 +195,9 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
 	ret = usb_control_msg(dev->udev, pipe, req,
 			      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 			      0x0000, reg, dev->urb_buf, len, HZ);
+	dvb_usb_dbg_usb_control_msg(dev->udev, req,
+			(USB_DIR_OUT | USB_TYPE_VENDOR), 0x0000, reg,
+			dev->urb_buf, len);
 	mutex_unlock(&dev->ctrl_urb_lock);
 
 	if (ret < 0)
-- 
1.7.11.7

