aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-11-26 07:58:48 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:14 -0500
commit9e5d6760c28409dd4ebd1cbafee77e5f58d6d574 (patch)
tree2ff3dede7d294059e5789678e9b47679e35a9e1a /drivers/media
parentdff65740e0c3a18cf56b2e3cbeebd9e9cfa7ac0d (diff)
V4L/DVB (9756): em28xx: Improve register log format
Change log format to look more like URB transactions. In fact, setup and IN/OUT transactions are merged. This helps to debug the driver. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index c3ff8ad416e6..f515f8791251 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -66,7 +66,8 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
66int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, 66int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
67 char *buf, int len) 67 char *buf, int len)
68{ 68{
69 int ret, byte; 69 int ret;
70 int pipe = usb_rcvctrlpipe(dev->udev, 0);
70 71
71 if (dev->state & DEV_DISCONNECTED) 72 if (dev->state & DEV_DISCONNECTED)
72 return -ENODEV; 73 return -ENODEV;
@@ -74,10 +75,18 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
74 if (len > URB_MAX_CTRL_SIZE) 75 if (len > URB_MAX_CTRL_SIZE)
75 return -EINVAL; 76 return -EINVAL;
76 77
77 em28xx_regdbg("req=%02x, reg=%02x ", req, reg); 78 if (reg_debug) {
79 printk( KERN_DEBUG "(pipe 0x%08x): "
80 "IN: %02x %02x %02x %02x %02x %02x %02x %02x ",
81 pipe,
82 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
83 req, 0, 0,
84 reg & 0xff, reg >> 8,
85 len & 0xff, len >> 8);
86 }
78 87
79 mutex_lock(&dev->ctrl_urb_lock); 88 mutex_lock(&dev->ctrl_urb_lock);
80 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 89 ret = usb_control_msg(dev->udev, pipe, req,
81 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 90 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
82 0x0000, reg, dev->urb_buf, len, HZ); 91 0x0000, reg, dev->urb_buf, len, HZ);
83 if (ret < 0) { 92 if (ret < 0) {
@@ -93,7 +102,9 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
93 mutex_unlock(&dev->ctrl_urb_lock); 102 mutex_unlock(&dev->ctrl_urb_lock);
94 103
95 if (reg_debug) { 104 if (reg_debug) {
96 printk("%02x values: ", ret); 105 int byte;
106
107 printk("<<<");
97 for (byte = 0; byte < len; byte++) 108 for (byte = 0; byte < len; byte++)
98 printk(" %02x", (unsigned char)buf[byte]); 109 printk(" %02x", (unsigned char)buf[byte]);
99 printk("\n"); 110 printk("\n");
@@ -108,28 +119,12 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
108 */ 119 */
109int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg) 120int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
110{ 121{
111 u8 val;
112 int ret; 122 int ret;
123 u8 val;
113 124
114 if (dev->state & DEV_DISCONNECTED) 125 ret = em28xx_read_reg_req_len(dev, req, reg, &val, 1);
115 return(-ENODEV); 126 if (ret < 0)
116
117 em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
118
119 mutex_lock(&dev->ctrl_urb_lock);
120 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
121 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
122 0x0000, reg, dev->urb_buf, 1, HZ);
123 val = dev->urb_buf[0];
124 mutex_unlock(&dev->ctrl_urb_lock);
125
126 if (ret < 0) {
127 printk(" failed!\n");
128 return ret; 127 return ret;
129 }
130
131 if (reg_debug)
132 printk("%02x\n", (unsigned char) val);
133 128
134 return val; 129 return val;
135} 130}
@@ -147,6 +142,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
147 int len) 142 int len)
148{ 143{
149 int ret; 144 int ret;
145 int pipe = usb_sndctrlpipe(dev->udev, 0);
150 146
151 if (dev->state & DEV_DISCONNECTED) 147 if (dev->state & DEV_DISCONNECTED)
152 return -ENODEV; 148 return -ENODEV;
@@ -154,17 +150,25 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
154 if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) 150 if ((len < 1) || (len > URB_MAX_CTRL_SIZE))
155 return -EINVAL; 151 return -EINVAL;
156 152
157 em28xx_regdbg("req=%02x reg=%02x:", req, reg);
158 if (reg_debug) { 153 if (reg_debug) {
159 int i; 154 int byte;
160 for (i = 0; i < len; ++i) 155
161 printk(" %02x", (unsigned char)buf[i]); 156 printk( KERN_DEBUG "(pipe 0x%08x): "
157 "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>",
158 pipe,
159 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
160 req, 0, 0,
161 reg & 0xff, reg >> 8,
162 len & 0xff, len >> 8);
163
164 for (byte = 0; byte < len; byte++)
165 printk(" %02x", (unsigned char)buf[byte]);
162 printk("\n"); 166 printk("\n");
163 } 167 }
164 168
165 mutex_lock(&dev->ctrl_urb_lock); 169 mutex_lock(&dev->ctrl_urb_lock);
166 memcpy(dev->urb_buf, buf, len); 170 memcpy(dev->urb_buf, buf, len);
167 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, 171 ret = usb_control_msg(dev->udev, pipe, req,
168 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 172 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
169 0x0000, reg, dev->urb_buf, len, HZ); 173 0x0000, reg, dev->urb_buf, len, HZ);
170 mutex_unlock(&dev->ctrl_urb_lock); 174 mutex_unlock(&dev->ctrl_urb_lock);