aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Kilgore <kilgota@banach.math.auburn.edu>2013-02-04 11:17:55 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 13:13:48 -0500
commitc93396e13576928a073154b5715761ff8a998368 (patch)
tree2ef9873a27412fe6d5dbe361d7298301510573f6
parent70c8ecf54bf735f300f86bde562420af90bf9db4 (diff)
[media] gspca: Remove gspca-specific debug magic
Instead use v4l2_dbg and v4l2_err. Note that the PDEBUG macro is kept to make this patch-set less invasive, but it is simply a wrapper around v4l2_dbg now. Most of the other changes are there to make the dev parameter for the v4l2_xxx macros available everywhere we do logging. Signed-off-by: Theodore Kilgore <kilgota@auburn.edu> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/gspca/benq.c2
-rw-r--r--drivers/media/usb/gspca/conex.c12
-rw-r--r--drivers/media/usb/gspca/cpia1.c33
-rw-r--r--drivers/media/usb/gspca/etoms.c10
-rw-r--r--drivers/media/usb/gspca/gl860/gl860.c2
-rw-r--r--drivers/media/usb/gspca/gspca.c69
-rw-r--r--drivers/media/usb/gspca/gspca.h40
-rw-r--r--drivers/media/usb/gspca/jeilinj.c2
-rw-r--r--drivers/media/usb/gspca/konica.c28
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_core.c6
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_mt9m111.c18
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_ov7660.c10
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_ov9650.c26
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_po1030.c21
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_s5k4aa.c16
-rw-r--r--drivers/media/usb/gspca/m5602/m5602_s5k83a.c1
-rw-r--r--drivers/media/usb/gspca/mr97310a.c8
-rw-r--r--drivers/media/usb/gspca/ov519.c81
-rw-r--r--drivers/media/usb/gspca/ov534.c2
-rw-r--r--drivers/media/usb/gspca/pac207.c2
-rw-r--r--drivers/media/usb/gspca/pac7302.c7
-rw-r--r--drivers/media/usb/gspca/pac7311.c5
-rw-r--r--drivers/media/usb/gspca/pac_common.h2
-rw-r--r--drivers/media/usb/gspca/sn9c2028.c4
-rw-r--r--drivers/media/usb/gspca/sonixj.c11
-rw-r--r--drivers/media/usb/gspca/spca1528.c4
-rw-r--r--drivers/media/usb/gspca/spca500.c36
-rw-r--r--drivers/media/usb/gspca/spca501.c44
-rw-r--r--drivers/media/usb/gspca/spca505.c42
-rw-r--r--drivers/media/usb/gspca/spca508.c41
-rw-r--r--drivers/media/usb/gspca/spca561.c70
-rw-r--r--drivers/media/usb/gspca/sq905.c2
-rw-r--r--drivers/media/usb/gspca/sq905c.c6
-rw-r--r--drivers/media/usb/gspca/sq930x.c4
-rw-r--r--drivers/media/usb/gspca/stv0680.c14
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx.c17
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c8
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c14
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c2
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c10
-rw-r--r--drivers/media/usb/gspca/sunplus.c27
-rw-r--r--drivers/media/usb/gspca/vc032x.c9
-rw-r--r--drivers/media/usb/gspca/w996Xcf.c5
-rw-r--r--drivers/media/usb/gspca/zc3xx.c3
44 files changed, 373 insertions, 403 deletions
diff --git a/drivers/media/usb/gspca/benq.c b/drivers/media/usb/gspca/benq.c
index 352f32190e68..05f406deae13 100644
--- a/drivers/media/usb/gspca/benq.c
+++ b/drivers/media/usb/gspca/benq.c
@@ -186,7 +186,7 @@ static void sd_isoc_irq(struct urb *urb)
186 /* check the packet status and length */ 186 /* check the packet status and length */
187 if (urb0->iso_frame_desc[i].actual_length != SD_PKT_SZ 187 if (urb0->iso_frame_desc[i].actual_length != SD_PKT_SZ
188 || urb->iso_frame_desc[i].actual_length != SD_PKT_SZ) { 188 || urb->iso_frame_desc[i].actual_length != SD_PKT_SZ) {
189 PDEBUG(D_ERR, "ISOC bad lengths %d / %d", 189 PERR("ISOC bad lengths %d / %d",
190 urb0->iso_frame_desc[i].actual_length, 190 urb0->iso_frame_desc[i].actual_length,
191 urb->iso_frame_desc[i].actual_length); 191 urb->iso_frame_desc[i].actual_length);
192 gspca_dev->last_packet_type = DISCARD_PACKET; 192 gspca_dev->last_packet_type = DISCARD_PACKET;
diff --git a/drivers/media/usb/gspca/conex.c b/drivers/media/usb/gspca/conex.c
index c9052f20435e..38714df31ac4 100644
--- a/drivers/media/usb/gspca/conex.c
+++ b/drivers/media/usb/gspca/conex.c
@@ -73,12 +73,11 @@ static void reg_r(struct gspca_dev *gspca_dev,
73{ 73{
74 struct usb_device *dev = gspca_dev->dev; 74 struct usb_device *dev = gspca_dev->dev;
75 75
76#ifdef GSPCA_DEBUG
77 if (len > USB_BUF_SZ) { 76 if (len > USB_BUF_SZ) {
78 pr_err("reg_r: buffer overflow\n"); 77 PERR("reg_r: buffer overflow\n");
79 return; 78 return;
80 } 79 }
81#endif 80
82 usb_control_msg(dev, 81 usb_control_msg(dev,
83 usb_rcvctrlpipe(dev, 0), 82 usb_rcvctrlpipe(dev, 0),
84 0, 83 0,
@@ -113,13 +112,12 @@ static void reg_w(struct gspca_dev *gspca_dev,
113{ 112{
114 struct usb_device *dev = gspca_dev->dev; 113 struct usb_device *dev = gspca_dev->dev;
115 114
116#ifdef GSPCA_DEBUG
117 if (len > USB_BUF_SZ) { 115 if (len > USB_BUF_SZ) {
118 pr_err("reg_w: buffer overflow\n"); 116 PERR("reg_w: buffer overflow\n");
119 return; 117 return;
120 } 118 }
121 PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); 119 PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
122#endif 120
123 memcpy(gspca_dev->usb_buf, buffer, len); 121 memcpy(gspca_dev->usb_buf, buffer, len);
124 usb_control_msg(dev, 122 usb_control_msg(dev,
125 usb_sndctrlpipe(dev, 0), 123 usb_sndctrlpipe(dev, 0),
@@ -689,7 +687,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
689 reg_w_val(gspca_dev, 0x0053, 0x00); 687 reg_w_val(gspca_dev, 0x0053, 0x00);
690 } while (--retry); 688 } while (--retry);
691 if (retry == 0) 689 if (retry == 0)
692 PDEBUG(D_ERR, "Damned Errors sending jpeg Table"); 690 PERR("Damned Errors sending jpeg Table");
693 /* send the qtable now */ 691 /* send the qtable now */
694 reg_r(gspca_dev, 0x0001, 1); /* -> 0x18 */ 692 reg_r(gspca_dev, 0x0001, 1); /* -> 0x18 */
695 length = 8; 693 length = 8;
diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
index 1dcdd9f95f1c..064b53043b15 100644
--- a/drivers/media/usb/gspca/cpia1.c
+++ b/drivers/media/usb/gspca/cpia1.c
@@ -421,8 +421,7 @@ static int cpia_usb_transferCmd(struct gspca_dev *gspca_dev, u8 *command)
421 pipe = usb_sndctrlpipe(gspca_dev->dev, 0); 421 pipe = usb_sndctrlpipe(gspca_dev->dev, 0);
422 requesttype = USB_TYPE_VENDOR | USB_RECIP_DEVICE; 422 requesttype = USB_TYPE_VENDOR | USB_RECIP_DEVICE;
423 } else { 423 } else {
424 PDEBUG(D_ERR, "Unexpected first byte of command: %x", 424 PERR("Unexpected first byte of command: %x", command[0]);
425 command[0]);
426 return -EINVAL; 425 return -EINVAL;
427 } 426 }
428 427
@@ -701,7 +700,7 @@ static void reset_camera_params(struct gspca_dev *gspca_dev)
701 params->qx3.cradled = 0; 700 params->qx3.cradled = 0;
702} 701}
703 702
704static void printstatus(struct cam_params *params) 703static void printstatus(struct gspca_dev *gspca_dev, struct cam_params *params)
705{ 704{
706 PDEBUG(D_PROBE, "status: %02x %02x %02x %02x %02x %02x %02x %02x", 705 PDEBUG(D_PROBE, "status: %02x %02x %02x %02x %02x %02x %02x %02x",
707 params->status.systemState, params->status.grabState, 706 params->status.systemState, params->status.grabState,
@@ -725,10 +724,9 @@ static int goto_low_power(struct gspca_dev *gspca_dev)
725 724
726 if (sd->params.status.systemState != LO_POWER_STATE) { 725 if (sd->params.status.systemState != LO_POWER_STATE) {
727 if (sd->params.status.systemState != WARM_BOOT_STATE) { 726 if (sd->params.status.systemState != WARM_BOOT_STATE) {
728 PDEBUG(D_ERR, 727 PERR("unexpected state after lo power cmd: %02x",
729 "unexpected state after lo power cmd: %02x", 728 sd->params.status.systemState);
730 sd->params.status.systemState); 729 printstatus(gspca_dev, &sd->params);
731 printstatus(&sd->params);
732 } 730 }
733 return -EIO; 731 return -EIO;
734 } 732 }
@@ -756,9 +754,9 @@ static int goto_high_power(struct gspca_dev *gspca_dev)
756 return ret; 754 return ret;
757 755
758 if (sd->params.status.systemState != HI_POWER_STATE) { 756 if (sd->params.status.systemState != HI_POWER_STATE) {
759 PDEBUG(D_ERR, "unexpected state after hi power cmd: %02x", 757 PERR("unexpected state after hi power cmd: %02x",
760 sd->params.status.systemState); 758 sd->params.status.systemState);
761 printstatus(&sd->params); 759 printstatus(gspca_dev, &sd->params);
762 return -EIO; 760 return -EIO;
763 } 761 }
764 762
@@ -1449,8 +1447,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1449 sd->params.version.firmwareVersion = 0; 1447 sd->params.version.firmwareVersion = 0;
1450 get_version_information(gspca_dev); 1448 get_version_information(gspca_dev);
1451 if (sd->params.version.firmwareVersion != 1) { 1449 if (sd->params.version.firmwareVersion != 1) {
1452 PDEBUG(D_ERR, "only firmware version 1 is supported (got: %d)", 1450 PERR("only firmware version 1 is supported (got: %d)",
1453 sd->params.version.firmwareVersion); 1451 sd->params.version.firmwareVersion);
1454 return -ENODEV; 1452 return -ENODEV;
1455 } 1453 }
1456 1454
@@ -1475,9 +1473,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1475 /* Start the camera in low power mode */ 1473 /* Start the camera in low power mode */
1476 if (goto_low_power(gspca_dev)) { 1474 if (goto_low_power(gspca_dev)) {
1477 if (sd->params.status.systemState != WARM_BOOT_STATE) { 1475 if (sd->params.status.systemState != WARM_BOOT_STATE) {
1478 PDEBUG(D_ERR, "unexpected systemstate: %02x", 1476 PERR("unexpected systemstate: %02x",
1479 sd->params.status.systemState); 1477 sd->params.status.systemState);
1480 printstatus(&sd->params); 1478 printstatus(gspca_dev, &sd->params);
1481 return -ENODEV; 1479 return -ENODEV;
1482 } 1480 }
1483 1481
@@ -1523,9 +1521,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
1523 return ret; 1521 return ret;
1524 1522
1525 if (sd->params.status.fatalError) { 1523 if (sd->params.status.fatalError) {
1526 PDEBUG(D_ERR, "fatal_error: %04x, vp_status: %04x", 1524 PERR("fatal_error: %04x, vp_status: %04x",
1527 sd->params.status.fatalError, 1525 sd->params.status.fatalError, sd->params.status.vpStatus);
1528 sd->params.status.vpStatus);
1529 return -EIO; 1526 return -EIO;
1530 } 1527 }
1531 1528
diff --git a/drivers/media/usb/gspca/etoms.c b/drivers/media/usb/gspca/etoms.c
index 38f68e11c3a2..948a6357573d 100644
--- a/drivers/media/usb/gspca/etoms.c
+++ b/drivers/media/usb/gspca/etoms.c
@@ -163,12 +163,11 @@ static void reg_r(struct gspca_dev *gspca_dev,
163{ 163{
164 struct usb_device *dev = gspca_dev->dev; 164 struct usb_device *dev = gspca_dev->dev;
165 165
166#ifdef GSPCA_DEBUG
167 if (len > USB_BUF_SZ) { 166 if (len > USB_BUF_SZ) {
168 pr_err("reg_r: buffer overflow\n"); 167 PERR("reg_r: buffer overflow\n");
169 return; 168 return;
170 } 169 }
171#endif 170
172 usb_control_msg(dev, 171 usb_control_msg(dev,
173 usb_rcvctrlpipe(dev, 0), 172 usb_rcvctrlpipe(dev, 0),
174 0, 173 0,
@@ -201,13 +200,12 @@ static void reg_w(struct gspca_dev *gspca_dev,
201{ 200{
202 struct usb_device *dev = gspca_dev->dev; 201 struct usb_device *dev = gspca_dev->dev;
203 202
204#ifdef GSPCA_DEBUG
205 if (len > USB_BUF_SZ) { 203 if (len > USB_BUF_SZ) {
206 pr_err("reg_w: buffer overflow\n"); 204 pr_err("reg_w: buffer overflow\n");
207 return; 205 return;
208 } 206 }
209 PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); 207 PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
210#endif 208
211 memcpy(gspca_dev->usb_buf, buffer, len); 209 memcpy(gspca_dev->usb_buf, buffer, len);
212 usb_control_msg(dev, 210 usb_control_msg(dev,
213 usb_sndctrlpipe(dev, 0), 211 usb_sndctrlpipe(dev, 0),
@@ -274,7 +272,7 @@ static int et_video(struct gspca_dev *gspca_dev,
274 : 0); /* stopvideo */ 272 : 0); /* stopvideo */
275 ret = Et_WaitStatus(gspca_dev); 273 ret = Et_WaitStatus(gspca_dev);
276 if (ret != 0) 274 if (ret != 0)
277 PDEBUG(D_ERR, "timeout video on/off"); 275 PERR("timeout video on/off");
278 return ret; 276 return ret;
279} 277}
280 278
diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c
index 96d9c28a748c..cb1e64ca59c9 100644
--- a/drivers/media/usb/gspca/gl860/gl860.c
+++ b/drivers/media/usb/gspca/gl860/gl860.c
@@ -582,7 +582,7 @@ int gl860_RTx(struct gspca_dev *gspca_dev,
582 pr_err("ctrl transfer failed %4d [p%02x r%d v%04x i%04x len%d]\n", 582 pr_err("ctrl transfer failed %4d [p%02x r%d v%04x i%04x len%d]\n",
583 r, pref, req, val, index, len); 583 r, pref, req, val, index, len);
584 else if (len > 1 && r < len) 584 else if (len > 1 && r < len)
585 PDEBUG(D_ERR, "short ctrl transfer %d/%d", r, len); 585 PERR("short ctrl transfer %d/%d", r, len);
586 586
587 msleep(1); 587 msleep(1);
588 588
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 5784ff4e1b2f..5800d65f9144 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -60,14 +60,14 @@ MODULE_DESCRIPTION("GSPCA USB Camera Driver");
60MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
61MODULE_VERSION(GSPCA_VERSION); 61MODULE_VERSION(GSPCA_VERSION);
62 62
63#ifdef GSPCA_DEBUG 63int gspca_debug;
64int gspca_debug = D_ERR | D_PROBE;
65EXPORT_SYMBOL(gspca_debug); 64EXPORT_SYMBOL(gspca_debug);
66 65
67static void PDEBUG_MODE(char *txt, __u32 pixfmt, int w, int h) 66static void PDEBUG_MODE(struct gspca_dev *gspca_dev, int debug, char *txt,
67 __u32 pixfmt, int w, int h)
68{ 68{
69 if ((pixfmt >> 24) >= '0' && (pixfmt >> 24) <= 'z') { 69 if ((pixfmt >> 24) >= '0' && (pixfmt >> 24) <= 'z') {
70 PDEBUG(D_CONF|D_STREAM, "%s %c%c%c%c %dx%d", 70 PDEBUG(debug, "%s %c%c%c%c %dx%d",
71 txt, 71 txt,
72 pixfmt & 0xff, 72 pixfmt & 0xff,
73 (pixfmt >> 8) & 0xff, 73 (pixfmt >> 8) & 0xff,
@@ -75,15 +75,12 @@ static void PDEBUG_MODE(char *txt, __u32 pixfmt, int w, int h)
75 pixfmt >> 24, 75 pixfmt >> 24,
76 w, h); 76 w, h);
77 } else { 77 } else {
78 PDEBUG(D_CONF|D_STREAM, "%s 0x%08x %dx%d", 78 PDEBUG(debug, "%s 0x%08x %dx%d",
79 txt, 79 txt,
80 pixfmt, 80 pixfmt,
81 w, h); 81 w, h);
82 } 82 }
83} 83}
84#else
85#define PDEBUG_MODE(txt, pixfmt, w, h)
86#endif
87 84
88/* specific memory types - !! should be different from V4L2_MEMORY_xxx */ 85/* specific memory types - !! should be different from V4L2_MEMORY_xxx */
89#define GSPCA_MEMORY_NO 0 /* V4L2_MEMORY_xxx starts from 1 */ 86#define GSPCA_MEMORY_NO 0 /* V4L2_MEMORY_xxx starts from 1 */
@@ -129,7 +126,7 @@ static void int_irq(struct urb *urb)
129 case 0: 126 case 0:
130 if (gspca_dev->sd_desc->int_pkt_scan(gspca_dev, 127 if (gspca_dev->sd_desc->int_pkt_scan(gspca_dev,
131 urb->transfer_buffer, urb->actual_length) < 0) { 128 urb->transfer_buffer, urb->actual_length) < 0) {
132 PDEBUG(D_ERR, "Unknown packet received"); 129 PERR("Unknown packet received");
133 } 130 }
134 break; 131 break;
135 132
@@ -143,7 +140,7 @@ static void int_irq(struct urb *urb)
143 break; 140 break;
144 141
145 default: 142 default:
146 PDEBUG(D_ERR, "URB error %i, resubmitting", urb->status); 143 PERR("URB error %i, resubmitting", urb->status);
147 urb->status = 0; 144 urb->status = 0;
148 ret = 0; 145 ret = 0;
149 } 146 }
@@ -229,7 +226,7 @@ static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev,
229 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 226 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
230 ret = usb_submit_urb(urb, GFP_KERNEL); 227 ret = usb_submit_urb(urb, GFP_KERNEL);
231 if (ret < 0) { 228 if (ret < 0) {
232 PDEBUG(D_ERR, "submit int URB failed with error %i", ret); 229 PERR("submit int URB failed with error %i", ret);
233 goto error_submit; 230 goto error_submit;
234 } 231 }
235 gspca_dev->int_urb = urb; 232 gspca_dev->int_urb = urb;
@@ -315,7 +312,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
315 if (gspca_dev->frozen) 312 if (gspca_dev->frozen)
316 return; 313 return;
317#endif 314#endif
318 PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status); 315 PERR("urb status: %d", urb->status);
319 urb->status = 0; 316 urb->status = 0;
320 goto resubmit; 317 goto resubmit;
321 } 318 }
@@ -388,7 +385,7 @@ static void bulk_irq(struct urb *urb)
388 if (gspca_dev->frozen) 385 if (gspca_dev->frozen)
389 return; 386 return;
390#endif 387#endif
391 PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status); 388 PERR("urb status: %d", urb->status);
392 urb->status = 0; 389 urb->status = 0;
393 goto resubmit; 390 goto resubmit;
394 } 391 }
@@ -460,7 +457,7 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
460 /* append the packet to the frame buffer */ 457 /* append the packet to the frame buffer */
461 if (len > 0) { 458 if (len > 0) {
462 if (gspca_dev->image_len + len > gspca_dev->frsz) { 459 if (gspca_dev->image_len + len > gspca_dev->frsz) {
463 PDEBUG(D_ERR|D_PACK, "frame overflow %d > %d", 460 PERR("frame overflow %d > %d",
464 gspca_dev->image_len + len, 461 gspca_dev->image_len + len,
465 gspca_dev->frsz); 462 gspca_dev->frsz);
466 packet_type = DISCARD_PACKET; 463 packet_type = DISCARD_PACKET;
@@ -960,9 +957,7 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
960 /* the bandwidth is not wide enough 957 /* the bandwidth is not wide enough
961 * negotiate or try a lower alternate setting */ 958 * negotiate or try a lower alternate setting */
962retry: 959retry:
963 PDEBUG(D_ERR|D_STREAM, 960 PERR("alt %d - bandwidth not wide enough, trying again", alt);
964 "alt %d - bandwidth not wide enough - trying again",
965 alt);
966 msleep(20); /* wait for kill complete */ 961 msleep(20); /* wait for kill complete */
967 if (gspca_dev->sd_desc->isoc_nego) { 962 if (gspca_dev->sd_desc->isoc_nego) {
968 ret = gspca_dev->sd_desc->isoc_nego(gspca_dev); 963 ret = gspca_dev->sd_desc->isoc_nego(gspca_dev);
@@ -1127,10 +1122,9 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
1127 w = fmt->fmt.pix.width; 1122 w = fmt->fmt.pix.width;
1128 h = fmt->fmt.pix.height; 1123 h = fmt->fmt.pix.height;
1129 1124
1130#ifdef GSPCA_DEBUG 1125 PDEBUG_MODE(gspca_dev, D_CONF, "try fmt cap",
1131 if (gspca_debug & D_CONF) 1126 fmt->fmt.pix.pixelformat, w, h);
1132 PDEBUG_MODE("try fmt cap", fmt->fmt.pix.pixelformat, w, h); 1127
1133#endif
1134 /* search the closest mode for width and height */ 1128 /* search the closest mode for width and height */
1135 mode = wxh_to_mode(gspca_dev, w, h); 1129 mode = wxh_to_mode(gspca_dev, w, h);
1136 1130
@@ -1143,8 +1137,6 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
1143 fmt->fmt.pix.pixelformat); 1137 fmt->fmt.pix.pixelformat);
1144 if (mode2 >= 0) 1138 if (mode2 >= 0)
1145 mode = mode2; 1139 mode = mode2;
1146/* else
1147 ; * no chance, return this mode */
1148 } 1140 }
1149 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode]; 1141 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode];
1150 /* some drivers use priv internally, zero it before giving it to 1142 /* some drivers use priv internally, zero it before giving it to
@@ -1280,15 +1272,6 @@ static int dev_open(struct file *file)
1280 if (!try_module_get(gspca_dev->module)) 1272 if (!try_module_get(gspca_dev->module))
1281 return -ENODEV; 1273 return -ENODEV;
1282 1274
1283#ifdef GSPCA_DEBUG
1284 /* activate the v4l2 debug */
1285 if (gspca_debug & D_V4L2)
1286 gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL
1287 | V4L2_DEBUG_IOCTL_ARG;
1288 else
1289 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL
1290 | V4L2_DEBUG_IOCTL_ARG);
1291#endif
1292 return v4l2_fh_open(file); 1275 return v4l2_fh_open(file);
1293} 1276}
1294 1277
@@ -1483,14 +1466,8 @@ static int vidioc_streamon(struct file *file, void *priv,
1483 if (ret < 0) 1466 if (ret < 0)
1484 goto out; 1467 goto out;
1485 } 1468 }
1486#ifdef GSPCA_DEBUG 1469 PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK", gspca_dev->pixfmt,
1487 if (gspca_debug & D_STREAM) { 1470 gspca_dev->width, gspca_dev->height);
1488 PDEBUG_MODE("stream on OK",
1489 gspca_dev->pixfmt,
1490 gspca_dev->width,
1491 gspca_dev->height);
1492 }
1493#endif
1494 ret = 0; 1471 ret = 0;
1495out: 1472out:
1496 mutex_unlock(&gspca_dev->queue_lock); 1473 mutex_unlock(&gspca_dev->queue_lock);
@@ -1741,8 +1718,7 @@ static int vidioc_dqbuf(struct file *file, void *priv,
1741 if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, 1718 if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr,
1742 frame->data, 1719 frame->data,
1743 frame->v4l2_buf.bytesused)) { 1720 frame->v4l2_buf.bytesused)) {
1744 PDEBUG(D_ERR|D_STREAM, 1721 PERR("dqbuf cp to user failed");
1745 "dqbuf cp to user failed");
1746 ret = -EFAULT; 1722 ret = -EFAULT;
1747 } 1723 }
1748 } 1724 }
@@ -1954,8 +1930,7 @@ static ssize_t dev_read(struct file *file, char __user *data,
1954 count = frame->v4l2_buf.bytesused; 1930 count = frame->v4l2_buf.bytesused;
1955 ret = copy_to_user(data, frame->data, count); 1931 ret = copy_to_user(data, frame->data, count);
1956 if (ret != 0) { 1932 if (ret != 0) {
1957 PDEBUG(D_ERR|D_STREAM, 1933 PERR("read cp to user lack %d / %zd", ret, count);
1958 "read cp to user lack %d / %zd", ret, count);
1959 ret = -EFAULT; 1934 ret = -EFAULT;
1960 goto out; 1935 goto out;
1961 } 1936 }
@@ -2290,10 +2265,6 @@ static void __exit gspca_exit(void)
2290module_init(gspca_init); 2265module_init(gspca_init);
2291module_exit(gspca_exit); 2266module_exit(gspca_exit);
2292 2267
2293#ifdef GSPCA_DEBUG
2294module_param_named(debug, gspca_debug, int, 0644); 2268module_param_named(debug, gspca_debug, int, 0644);
2295MODULE_PARM_DESC(debug, 2269MODULE_PARM_DESC(debug,
2296 "Debug (bit) 0x01:error 0x02:probe 0x04:config" 2270 "1:probe 2:config 3:stream 4:frame 5:packet 6:usbi 7:usbo");
2297 " 0x08:stream 0x10:frame 0x20:packet"
2298 " 0x0100: v4l2");
2299#endif
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index ac62cd3b590e..c3af3212d51e 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -10,30 +10,26 @@
10#include <media/v4l2-device.h> 10#include <media/v4l2-device.h>
11#include <linux/mutex.h> 11#include <linux/mutex.h>
12 12
13/* compilation option */
14/*#define GSPCA_DEBUG 1*/
15 13
16#ifdef GSPCA_DEBUG 14
17/* GSPCA our debug messages */ 15/* GSPCA debug codes */
16
17#define D_PROBE 1
18#define D_CONF 2
19#define D_STREAM 3
20#define D_FRAM 4
21#define D_PACK 5
22#define D_USBI 6
23#define D_USBO 7
24
18extern int gspca_debug; 25extern int gspca_debug;
19#define PDEBUG(level, fmt, ...) \ 26
20do { \ 27
21 if (gspca_debug & (level)) \ 28#define PDEBUG(level, fmt, ...) \
22 pr_info(fmt, ##__VA_ARGS__); \ 29 v4l2_dbg(level, gspca_debug, &gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__)
23} while (0) 30
24 31#define PERR(fmt, ...) \
25#define D_ERR 0x01 32 v4l2_err(&gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__)
26#define D_PROBE 0x02
27#define D_CONF 0x04
28#define D_STREAM 0x08
29#define D_FRAM 0x10
30#define D_PACK 0x20
31#define D_USBI 0x00
32#define D_USBO 0x00
33#define D_V4L2 0x0100
34#else
35#define PDEBUG(level, fmt, ...) do {} while(0)
36#endif
37 33
38#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */ 34#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
39/* image transfers */ 35/* image transfers */
diff --git a/drivers/media/usb/gspca/jeilinj.c b/drivers/media/usb/gspca/jeilinj.c
index 1ba29fe7fada..8da3dde38385 100644
--- a/drivers/media/usb/gspca/jeilinj.c
+++ b/drivers/media/usb/gspca/jeilinj.c
@@ -266,7 +266,7 @@ static int jlj_start(struct gspca_dev *gspca_dev)
266 msleep(2); 266 msleep(2);
267 setfreq(gspca_dev, v4l2_ctrl_g_ctrl(sd->freq)); 267 setfreq(gspca_dev, v4l2_ctrl_g_ctrl(sd->freq));
268 if (gspca_dev->usb_err < 0) 268 if (gspca_dev->usb_err < 0)
269 PDEBUG(D_ERR, "Start streaming command failed"); 269 PERR("Start streaming command failed");
270 return gspca_dev->usb_err; 270 return gspca_dev->usb_err;
271} 271}
272 272
diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c
index 61e25dbf2447..39c96bb4c985 100644
--- a/drivers/media/usb/gspca/konica.c
+++ b/drivers/media/usb/gspca/konica.c
@@ -277,7 +277,7 @@ static void sd_isoc_irq(struct urb *urb)
277 if (gspca_dev->frozen) 277 if (gspca_dev->frozen)
278 return; 278 return;
279#endif 279#endif
280 PDEBUG(D_ERR, "urb status: %d", urb->status); 280 PERR("urb status: %d", urb->status);
281 st = usb_submit_urb(urb, GFP_ATOMIC); 281 st = usb_submit_urb(urb, GFP_ATOMIC);
282 if (st < 0) 282 if (st < 0)
283 pr_err("resubmit urb error %d\n", st); 283 pr_err("resubmit urb error %d\n", st);
@@ -295,33 +295,30 @@ static void sd_isoc_irq(struct urb *urb)
295 sd->last_data_urb = NULL; 295 sd->last_data_urb = NULL;
296 296
297 if (!data_urb || data_urb->start_frame != status_urb->start_frame) { 297 if (!data_urb || data_urb->start_frame != status_urb->start_frame) {
298 PDEBUG(D_ERR|D_PACK, "lost sync on frames"); 298 PERR("lost sync on frames");
299 goto resubmit; 299 goto resubmit;
300 } 300 }
301 301
302 if (data_urb->number_of_packets != status_urb->number_of_packets) { 302 if (data_urb->number_of_packets != status_urb->number_of_packets) {
303 PDEBUG(D_ERR|D_PACK, 303 PERR("no packets does not match, data: %d, status: %d",
304 "no packets does not match, data: %d, status: %d", 304 data_urb->number_of_packets,
305 data_urb->number_of_packets, 305 status_urb->number_of_packets);
306 status_urb->number_of_packets);
307 goto resubmit; 306 goto resubmit;
308 } 307 }
309 308
310 for (i = 0; i < status_urb->number_of_packets; i++) { 309 for (i = 0; i < status_urb->number_of_packets; i++) {
311 if (data_urb->iso_frame_desc[i].status || 310 if (data_urb->iso_frame_desc[i].status ||
312 status_urb->iso_frame_desc[i].status) { 311 status_urb->iso_frame_desc[i].status) {
313 PDEBUG(D_ERR|D_PACK, 312 PERR("pkt %d data-status %d, status-status %d", i,
314 "pkt %d data-status %d, status-status %d", i, 313 data_urb->iso_frame_desc[i].status,
315 data_urb->iso_frame_desc[i].status, 314 status_urb->iso_frame_desc[i].status);
316 status_urb->iso_frame_desc[i].status);
317 gspca_dev->last_packet_type = DISCARD_PACKET; 315 gspca_dev->last_packet_type = DISCARD_PACKET;
318 continue; 316 continue;
319 } 317 }
320 318
321 if (status_urb->iso_frame_desc[i].actual_length != 1) { 319 if (status_urb->iso_frame_desc[i].actual_length != 1) {
322 PDEBUG(D_ERR|D_PACK, 320 PERR("bad status packet length %d",
323 "bad status packet length %d", 321 status_urb->iso_frame_desc[i].actual_length);
324 status_urb->iso_frame_desc[i].actual_length);
325 gspca_dev->last_packet_type = DISCARD_PACKET; 322 gspca_dev->last_packet_type = DISCARD_PACKET;
326 continue; 323 continue;
327 } 324 }
@@ -366,12 +363,11 @@ resubmit:
366 if (data_urb) { 363 if (data_urb) {
367 st = usb_submit_urb(data_urb, GFP_ATOMIC); 364 st = usb_submit_urb(data_urb, GFP_ATOMIC);
368 if (st < 0) 365 if (st < 0)
369 PDEBUG(D_ERR|D_PACK, 366 PERR("usb_submit_urb(data_urb) ret %d", st);
370 "usb_submit_urb(data_urb) ret %d", st);
371 } 367 }
372 st = usb_submit_urb(status_urb, GFP_ATOMIC); 368 st = usb_submit_urb(status_urb, GFP_ATOMIC);
373 if (st < 0) 369 if (st < 0)
374 pr_err("usb_submit_urb(status_urb) ret %d\n", st); 370 PERR("usb_submit_urb(status_urb) ret %d\n", st);
375} 371}
376 372
377static int sd_s_ctrl(struct v4l2_ctrl *ctrl) 373static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
diff --git a/drivers/media/usb/gspca/m5602/m5602_core.c b/drivers/media/usb/gspca/m5602/m5602_core.c
index 907a968f474d..d926e62cb80b 100644
--- a/drivers/media/usb/gspca/m5602/m5602_core.c
+++ b/drivers/media/usb/gspca/m5602/m5602_core.c
@@ -41,6 +41,7 @@ MODULE_DEVICE_TABLE(usb, m5602_table);
41int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data) 41int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data)
42{ 42{
43 int err; 43 int err;
44 struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
44 struct usb_device *udev = sd->gspca_dev.dev; 45 struct usb_device *udev = sd->gspca_dev.dev;
45 __u8 *buf = sd->gspca_dev.usb_buf; 46 __u8 *buf = sd->gspca_dev.usb_buf;
46 47
@@ -62,6 +63,7 @@ int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data)
62int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data) 63int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data)
63{ 64{
64 int err; 65 int err;
66 struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
65 struct usb_device *udev = sd->gspca_dev.dev; 67 struct usb_device *udev = sd->gspca_dev.dev;
66 __u8 *buf = sd->gspca_dev.usb_buf; 68 __u8 *buf = sd->gspca_dev.usb_buf;
67 69
@@ -98,6 +100,7 @@ int m5602_read_sensor(struct sd *sd, const u8 address,
98 u8 *i2c_data, const u8 len) 100 u8 *i2c_data, const u8 len)
99{ 101{
100 int err, i; 102 int err, i;
103 struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
101 104
102 if (!len || len > sd->sensor->i2c_regW) 105 if (!len || len > sd->sensor->i2c_regW)
103 return -EINVAL; 106 return -EINVAL;
@@ -147,6 +150,7 @@ int m5602_write_sensor(struct sd *sd, const u8 address,
147{ 150{
148 int err, i; 151 int err, i;
149 u8 *p; 152 u8 *p;
153 struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
150 struct usb_device *udev = sd->gspca_dev.dev; 154 struct usb_device *udev = sd->gspca_dev.dev;
151 __u8 *buf = sd->gspca_dev.usb_buf; 155 __u8 *buf = sd->gspca_dev.usb_buf;
152 156
@@ -378,7 +382,7 @@ static int m5602_configure(struct gspca_dev *gspca_dev,
378 return 0; 382 return 0;
379 383
380fail: 384fail:
381 PDEBUG(D_ERR, "ALi m5602 webcam failed"); 385 PERR("ALi m5602 webcam failed");
382 cam->cam_mode = NULL; 386 cam->cam_mode = NULL;
383 cam->nmodes = 0; 387 cam->nmodes = 0;
384 388
diff --git a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
index b5f66921b3eb..cfa4663f8934 100644
--- a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
@@ -56,6 +56,7 @@ int mt9m111_probe(struct sd *sd)
56{ 56{
57 u8 data[2] = {0x00, 0x00}; 57 u8 data[2] = {0x00, 0x00};
58 int i; 58 int i;
59 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
59 60
60 if (force_sensor) { 61 if (force_sensor) {
61 if (force_sensor == MT9M111_SENSOR) { 62 if (force_sensor == MT9M111_SENSOR) {
@@ -169,6 +170,7 @@ int mt9m111_start(struct sd *sd)
169 int i, err = 0; 170 int i, err = 0;
170 u8 data[2]; 171 u8 data[2];
171 struct cam *cam = &sd->gspca_dev.cam; 172 struct cam *cam = &sd->gspca_dev.cam;
173 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
172 174
173 int width = cam->cam_mode[sd->gspca_dev.curr_mode].width - 1; 175 int width = cam->cam_mode[sd->gspca_dev.curr_mode].width - 1;
174 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; 176 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
@@ -229,11 +231,11 @@ int mt9m111_start(struct sd *sd)
229 231
230 switch (width) { 232 switch (width) {
231 case 640: 233 case 640:
232 PDEBUG(D_V4L2, "Configuring camera for VGA mode"); 234 PDEBUG(D_CONF, "Configuring camera for VGA mode");
233 break; 235 break;
234 236
235 case 320: 237 case 320:
236 PDEBUG(D_V4L2, "Configuring camera for QVGA mode"); 238 PDEBUG(D_CONF, "Configuring camera for QVGA mode");
237 break; 239 break;
238 } 240 }
239 return err; 241 return err;
@@ -252,7 +254,7 @@ static int mt9m111_set_hvflip(struct gspca_dev *gspca_dev)
252 int hflip; 254 int hflip;
253 int vflip; 255 int vflip;
254 256
255 PDEBUG(D_V4L2, "Set hvflip to %d %d", sd->hflip->val, sd->vflip->val); 257 PDEBUG(D_CONF, "Set hvflip to %d %d", sd->hflip->val, sd->vflip->val);
256 258
257 /* The mt9m111 is flipped by default */ 259 /* The mt9m111 is flipped by default */
258 hflip = !sd->hflip->val; 260 hflip = !sd->hflip->val;
@@ -293,7 +295,7 @@ static int mt9m111_set_auto_white_balance(struct gspca_dev *gspca_dev,
293 295
294 err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2); 296 err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
295 297
296 PDEBUG(D_V4L2, "Set auto white balance %d", val); 298 PDEBUG(D_CONF, "Set auto white balance %d", val);
297 return err; 299 return err;
298} 300}
299 301
@@ -326,7 +328,7 @@ static int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
326 328
327 data[1] = (tmp & 0xff); 329 data[1] = (tmp & 0xff);
328 data[0] = (tmp & 0xff00) >> 8; 330 data[0] = (tmp & 0xff00) >> 8;
329 PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 331 PDEBUG(D_CONF, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
330 data[1], data[0]); 332 data[1], data[0]);
331 333
332 err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, 334 err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN,
@@ -344,7 +346,7 @@ static int mt9m111_set_green_balance(struct gspca_dev *gspca_dev, __s32 val)
344 data[1] = (val & 0xff); 346 data[1] = (val & 0xff);
345 data[0] = (val & 0xff00) >> 8; 347 data[0] = (val & 0xff00) >> 8;
346 348
347 PDEBUG(D_V4L2, "Set green balance %d", val); 349 PDEBUG(D_CONF, "Set green balance %d", val);
348 err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN, 350 err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN,
349 data, 2); 351 data, 2);
350 if (err < 0) 352 if (err < 0)
@@ -362,7 +364,7 @@ static int mt9m111_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
362 data[1] = (val & 0xff); 364 data[1] = (val & 0xff);
363 data[0] = (val & 0xff00) >> 8; 365 data[0] = (val & 0xff00) >> 8;
364 366
365 PDEBUG(D_V4L2, "Set blue balance %d", val); 367 PDEBUG(D_CONF, "Set blue balance %d", val);
366 368
367 return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN, 369 return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN,
368 data, 2); 370 data, 2);
@@ -376,7 +378,7 @@ static int mt9m111_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
376 data[1] = (val & 0xff); 378 data[1] = (val & 0xff);
377 data[0] = (val & 0xff00) >> 8; 379 data[0] = (val & 0xff00) >> 8;
378 380
379 PDEBUG(D_V4L2, "Set red balance %d", val); 381 PDEBUG(D_CONF, "Set red balance %d", val);
380 382
381 return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN, 383 return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN,
382 data, 2); 384 data, 2);
diff --git a/drivers/media/usb/gspca/m5602/m5602_ov7660.c b/drivers/media/usb/gspca/m5602/m5602_ov7660.c
index 3bbe3ad5d4a9..4ac78893cc5f 100644
--- a/drivers/media/usb/gspca/m5602/m5602_ov7660.c
+++ b/drivers/media/usb/gspca/m5602/m5602_ov7660.c
@@ -175,7 +175,7 @@ static int ov7660_set_gain(struct gspca_dev *gspca_dev, __s32 val)
175 u8 i2c_data = val; 175 u8 i2c_data = val;
176 struct sd *sd = (struct sd *) gspca_dev; 176 struct sd *sd = (struct sd *) gspca_dev;
177 177
178 PDEBUG(D_V4L2, "Setting gain to %d", val); 178 PDEBUG(D_CONF, "Setting gain to %d", val);
179 179
180 err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1); 180 err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1);
181 return err; 181 return err;
@@ -188,7 +188,7 @@ static int ov7660_set_auto_white_balance(struct gspca_dev *gspca_dev,
188 u8 i2c_data; 188 u8 i2c_data;
189 struct sd *sd = (struct sd *) gspca_dev; 189 struct sd *sd = (struct sd *) gspca_dev;
190 190
191 PDEBUG(D_V4L2, "Set auto white balance to %d", val); 191 PDEBUG(D_CONF, "Set auto white balance to %d", val);
192 192
193 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); 193 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
194 if (err < 0) 194 if (err < 0)
@@ -206,7 +206,7 @@ static int ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
206 u8 i2c_data; 206 u8 i2c_data;
207 struct sd *sd = (struct sd *) gspca_dev; 207 struct sd *sd = (struct sd *) gspca_dev;
208 208
209 PDEBUG(D_V4L2, "Set auto gain control to %d", val); 209 PDEBUG(D_CONF, "Set auto gain control to %d", val);
210 210
211 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); 211 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
212 if (err < 0) 212 if (err < 0)
@@ -224,7 +224,7 @@ static int ov7660_set_auto_exposure(struct gspca_dev *gspca_dev,
224 u8 i2c_data; 224 u8 i2c_data;
225 struct sd *sd = (struct sd *) gspca_dev; 225 struct sd *sd = (struct sd *) gspca_dev;
226 226
227 PDEBUG(D_V4L2, "Set auto exposure control to %d", val); 227 PDEBUG(D_CONF, "Set auto exposure control to %d", val);
228 228
229 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1); 229 err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
230 if (err < 0) 230 if (err < 0)
@@ -242,7 +242,7 @@ static int ov7660_set_hvflip(struct gspca_dev *gspca_dev)
242 u8 i2c_data; 242 u8 i2c_data;
243 struct sd *sd = (struct sd *) gspca_dev; 243 struct sd *sd = (struct sd *) gspca_dev;
244 244
245 PDEBUG(D_V4L2, "Set hvflip to %d, %d", sd->hflip->val, sd->vflip->val); 245 PDEBUG(D_CONF, "Set hvflip to %d, %d", sd->hflip->val, sd->vflip->val);
246 246
247 i2c_data = (sd->hflip->val << 5) | (sd->vflip->val << 4); 247 i2c_data = (sd->hflip->val << 5) | (sd->vflip->val << 4);
248 248
diff --git a/drivers/media/usb/gspca/m5602/m5602_ov9650.c b/drivers/media/usb/gspca/m5602/m5602_ov9650.c
index e2fe2f942fe6..59bc62bfae26 100644
--- a/drivers/media/usb/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/usb/gspca/m5602/m5602_ov9650.c
@@ -147,6 +147,7 @@ int ov9650_probe(struct sd *sd)
147{ 147{
148 int err = 0; 148 int err = 0;
149 u8 prod_id = 0, ver_id = 0, i; 149 u8 prod_id = 0, ver_id = 0, i;
150 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
150 151
151 if (force_sensor) { 152 if (force_sensor) {
152 if (force_sensor == OV9650_SENSOR) { 153 if (force_sensor == OV9650_SENSOR) {
@@ -268,6 +269,7 @@ int ov9650_start(struct sd *sd)
268 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; 269 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
269 int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv; 270 int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
270 int hor_offs = OV9650_LEFT_OFFSET; 271 int hor_offs = OV9650_LEFT_OFFSET;
272 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
271 273
272 if ((!dmi_check_system(ov9650_flip_dmi_table) && 274 if ((!dmi_check_system(ov9650_flip_dmi_table) &&
273 sd->vflip->val) || 275 sd->vflip->val) ||
@@ -351,7 +353,7 @@ int ov9650_start(struct sd *sd)
351 353
352 switch (width) { 354 switch (width) {
353 case 640: 355 case 640:
354 PDEBUG(D_V4L2, "Configuring camera for VGA mode"); 356 PDEBUG(D_CONF, "Configuring camera for VGA mode");
355 357
356 data = OV9650_VGA_SELECT | OV9650_RGB_SELECT | 358 data = OV9650_VGA_SELECT | OV9650_RGB_SELECT |
357 OV9650_RAW_RGB_SELECT; 359 OV9650_RAW_RGB_SELECT;
@@ -359,7 +361,7 @@ int ov9650_start(struct sd *sd)
359 break; 361 break;
360 362
361 case 352: 363 case 352:
362 PDEBUG(D_V4L2, "Configuring camera for CIF mode"); 364 PDEBUG(D_CONF, "Configuring camera for CIF mode");
363 365
364 data = OV9650_CIF_SELECT | OV9650_RGB_SELECT | 366 data = OV9650_CIF_SELECT | OV9650_RGB_SELECT |
365 OV9650_RAW_RGB_SELECT; 367 OV9650_RAW_RGB_SELECT;
@@ -367,7 +369,7 @@ int ov9650_start(struct sd *sd)
367 break; 369 break;
368 370
369 case 320: 371 case 320:
370 PDEBUG(D_V4L2, "Configuring camera for QVGA mode"); 372 PDEBUG(D_CONF, "Configuring camera for QVGA mode");
371 373
372 data = OV9650_QVGA_SELECT | OV9650_RGB_SELECT | 374 data = OV9650_QVGA_SELECT | OV9650_RGB_SELECT |
373 OV9650_RAW_RGB_SELECT; 375 OV9650_RAW_RGB_SELECT;
@@ -375,7 +377,7 @@ int ov9650_start(struct sd *sd)
375 break; 377 break;
376 378
377 case 176: 379 case 176:
378 PDEBUG(D_V4L2, "Configuring camera for QCIF mode"); 380 PDEBUG(D_CONF, "Configuring camera for QCIF mode");
379 381
380 data = OV9650_QCIF_SELECT | OV9650_RGB_SELECT | 382 data = OV9650_QCIF_SELECT | OV9650_RGB_SELECT |
381 OV9650_RAW_RGB_SELECT; 383 OV9650_RAW_RGB_SELECT;
@@ -404,7 +406,7 @@ static int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
404 u8 i2c_data; 406 u8 i2c_data;
405 int err; 407 int err;
406 408
407 PDEBUG(D_V4L2, "Set exposure to %d", val); 409 PDEBUG(D_CONF, "Set exposure to %d", val);
408 410
409 /* The 6 MSBs */ 411 /* The 6 MSBs */
410 i2c_data = (val >> 10) & 0x3f; 412 i2c_data = (val >> 10) & 0x3f;
@@ -432,7 +434,7 @@ static int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
432 u8 i2c_data; 434 u8 i2c_data;
433 struct sd *sd = (struct sd *) gspca_dev; 435 struct sd *sd = (struct sd *) gspca_dev;
434 436
435 PDEBUG(D_V4L2, "Setting gain to %d", val); 437 PDEBUG(D_CONF, "Setting gain to %d", val);
436 438
437 /* The 2 MSB */ 439 /* The 2 MSB */
438 /* Read the OV9650_VREF register first to avoid 440 /* Read the OV9650_VREF register first to avoid
@@ -460,7 +462,7 @@ static int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
460 u8 i2c_data; 462 u8 i2c_data;
461 struct sd *sd = (struct sd *) gspca_dev; 463 struct sd *sd = (struct sd *) gspca_dev;
462 464
463 PDEBUG(D_V4L2, "Set red gain to %d", val); 465 PDEBUG(D_CONF, "Set red gain to %d", val);
464 466
465 i2c_data = val & 0xff; 467 i2c_data = val & 0xff;
466 err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1); 468 err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1);
@@ -473,7 +475,7 @@ static int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
473 u8 i2c_data; 475 u8 i2c_data;
474 struct sd *sd = (struct sd *) gspca_dev; 476 struct sd *sd = (struct sd *) gspca_dev;
475 477
476 PDEBUG(D_V4L2, "Set blue gain to %d", val); 478 PDEBUG(D_CONF, "Set blue gain to %d", val);
477 479
478 i2c_data = val & 0xff; 480 i2c_data = val & 0xff;
479 err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); 481 err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1);
@@ -488,7 +490,7 @@ static int ov9650_set_hvflip(struct gspca_dev *gspca_dev)
488 int hflip = sd->hflip->val; 490 int hflip = sd->hflip->val;
489 int vflip = sd->vflip->val; 491 int vflip = sd->vflip->val;
490 492
491 PDEBUG(D_V4L2, "Set hvflip to %d %d", hflip, vflip); 493 PDEBUG(D_CONF, "Set hvflip to %d %d", hflip, vflip);
492 494
493 if (dmi_check_system(ov9650_flip_dmi_table)) 495 if (dmi_check_system(ov9650_flip_dmi_table))
494 vflip = !vflip; 496 vflip = !vflip;
@@ -512,7 +514,7 @@ static int ov9650_set_auto_exposure(struct gspca_dev *gspca_dev,
512 u8 i2c_data; 514 u8 i2c_data;
513 struct sd *sd = (struct sd *) gspca_dev; 515 struct sd *sd = (struct sd *) gspca_dev;
514 516
515 PDEBUG(D_V4L2, "Set auto exposure control to %d", val); 517 PDEBUG(D_CONF, "Set auto exposure control to %d", val);
516 518
517 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 519 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
518 if (err < 0) 520 if (err < 0)
@@ -531,7 +533,7 @@ static int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev,
531 u8 i2c_data; 533 u8 i2c_data;
532 struct sd *sd = (struct sd *) gspca_dev; 534 struct sd *sd = (struct sd *) gspca_dev;
533 535
534 PDEBUG(D_V4L2, "Set auto white balance to %d", val); 536 PDEBUG(D_CONF, "Set auto white balance to %d", val);
535 537
536 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 538 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
537 if (err < 0) 539 if (err < 0)
@@ -549,7 +551,7 @@ static int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
549 u8 i2c_data; 551 u8 i2c_data;
550 struct sd *sd = (struct sd *) gspca_dev; 552 struct sd *sd = (struct sd *) gspca_dev;
551 553
552 PDEBUG(D_V4L2, "Set auto gain control to %d", val); 554 PDEBUG(D_CONF, "Set auto gain control to %d", val);
553 555
554 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 556 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
555 if (err < 0) 557 if (err < 0)
diff --git a/drivers/media/usb/gspca/m5602/m5602_po1030.c b/drivers/media/usb/gspca/m5602/m5602_po1030.c
index 189086291303..4bf5c43424b7 100644
--- a/drivers/media/usb/gspca/m5602/m5602_po1030.c
+++ b/drivers/media/usb/gspca/m5602/m5602_po1030.c
@@ -55,6 +55,7 @@ static const struct v4l2_ctrl_config po1030_greenbal_cfg = {
55int po1030_probe(struct sd *sd) 55int po1030_probe(struct sd *sd)
56{ 56{
57 u8 dev_id_h = 0, i; 57 u8 dev_id_h = 0, i;
58 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
58 59
59 if (force_sensor) { 60 if (force_sensor) {
60 if (force_sensor == PO1030_SENSOR) { 61 if (force_sensor == PO1030_SENSOR) {
@@ -305,10 +306,10 @@ static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
305 u8 i2c_data; 306 u8 i2c_data;
306 int err; 307 int err;
307 308
308 PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff); 309 PDEBUG(D_CONF, "Set exposure to %d", val & 0xffff);
309 310
310 i2c_data = ((val & 0xff00) >> 8); 311 i2c_data = ((val & 0xff00) >> 8);
311 PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", 312 PDEBUG(D_CONF, "Set exposure to high byte to 0x%x",
312 i2c_data); 313 i2c_data);
313 314
314 err = m5602_write_sensor(sd, PO1030_INTEGLINES_H, 315 err = m5602_write_sensor(sd, PO1030_INTEGLINES_H,
@@ -317,7 +318,7 @@ static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
317 return err; 318 return err;
318 319
319 i2c_data = (val & 0xff); 320 i2c_data = (val & 0xff);
320 PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", 321 PDEBUG(D_CONF, "Set exposure to low byte to 0x%x",
321 i2c_data); 322 i2c_data);
322 err = m5602_write_sensor(sd, PO1030_INTEGLINES_M, 323 err = m5602_write_sensor(sd, PO1030_INTEGLINES_M,
323 &i2c_data, 1); 324 &i2c_data, 1);
@@ -332,7 +333,7 @@ static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val)
332 int err; 333 int err;
333 334
334 i2c_data = val & 0xff; 335 i2c_data = val & 0xff;
335 PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); 336 PDEBUG(D_CONF, "Set global gain to %d", i2c_data);
336 err = m5602_write_sensor(sd, PO1030_GLOBALGAIN, 337 err = m5602_write_sensor(sd, PO1030_GLOBALGAIN,
337 &i2c_data, 1); 338 &i2c_data, 1);
338 return err; 339 return err;
@@ -344,7 +345,7 @@ static int po1030_set_hvflip(struct gspca_dev *gspca_dev)
344 u8 i2c_data; 345 u8 i2c_data;
345 int err; 346 int err;
346 347
347 PDEBUG(D_V4L2, "Set hvflip %d %d", sd->hflip->val, sd->vflip->val); 348 PDEBUG(D_CONF, "Set hvflip %d %d", sd->hflip->val, sd->vflip->val);
348 err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); 349 err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1);
349 if (err < 0) 350 if (err < 0)
350 return err; 351 return err;
@@ -365,7 +366,7 @@ static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
365 int err; 366 int err;
366 367
367 i2c_data = val & 0xff; 368 i2c_data = val & 0xff;
368 PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); 369 PDEBUG(D_CONF, "Set red gain to %d", i2c_data);
369 err = m5602_write_sensor(sd, PO1030_RED_GAIN, 370 err = m5602_write_sensor(sd, PO1030_RED_GAIN,
370 &i2c_data, 1); 371 &i2c_data, 1);
371 return err; 372 return err;
@@ -378,7 +379,7 @@ static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
378 int err; 379 int err;
379 380
380 i2c_data = val & 0xff; 381 i2c_data = val & 0xff;
381 PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); 382 PDEBUG(D_CONF, "Set blue gain to %d", i2c_data);
382 err = m5602_write_sensor(sd, PO1030_BLUE_GAIN, 383 err = m5602_write_sensor(sd, PO1030_BLUE_GAIN,
383 &i2c_data, 1); 384 &i2c_data, 1);
384 385
@@ -392,7 +393,7 @@ static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val)
392 int err; 393 int err;
393 394
394 i2c_data = val & 0xff; 395 i2c_data = val & 0xff;
395 PDEBUG(D_V4L2, "Set green gain to %d", i2c_data); 396 PDEBUG(D_CONF, "Set green gain to %d", i2c_data);
396 397
397 err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN, 398 err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN,
398 &i2c_data, 1); 399 &i2c_data, 1);
@@ -414,7 +415,7 @@ static int po1030_set_auto_white_balance(struct gspca_dev *gspca_dev,
414 if (err < 0) 415 if (err < 0)
415 return err; 416 return err;
416 417
417 PDEBUG(D_V4L2, "Set auto white balance to %d", val); 418 PDEBUG(D_CONF, "Set auto white balance to %d", val);
418 i2c_data = (i2c_data & 0xfe) | (val & 0x01); 419 i2c_data = (i2c_data & 0xfe) | (val & 0x01);
419 err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); 420 err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
420 return err; 421 return err;
@@ -431,7 +432,7 @@ static int po1030_set_auto_exposure(struct gspca_dev *gspca_dev,
431 if (err < 0) 432 if (err < 0)
432 return err; 433 return err;
433 434
434 PDEBUG(D_V4L2, "Set auto exposure to %d", val); 435 PDEBUG(D_CONF, "Set auto exposure to %d", val);
435 val = (val == V4L2_EXPOSURE_AUTO); 436 val = (val == V4L2_EXPOSURE_AUTO);
436 i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1); 437 i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1);
437 return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); 438 return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
index 42ffaf04771c..7d12599458e2 100644
--- a/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
@@ -145,6 +145,7 @@ int s5k4aa_probe(struct sd *sd)
145{ 145{
146 u8 prod_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 146 u8 prod_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
147 const u8 expected_prod_id[6] = {0x00, 0x10, 0x00, 0x4b, 0x33, 0x75}; 147 const u8 expected_prod_id[6] = {0x00, 0x10, 0x00, 0x4b, 0x33, 0x75};
148 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
148 int i, err = 0; 149 int i, err = 0;
149 150
150 if (force_sensor) { 151 if (force_sensor) {
@@ -215,10 +216,11 @@ int s5k4aa_start(struct sd *sd)
215 int i, err = 0; 216 int i, err = 0;
216 u8 data[2]; 217 u8 data[2];
217 struct cam *cam = &sd->gspca_dev.cam; 218 struct cam *cam = &sd->gspca_dev.cam;
219 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
218 220
219 switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) { 221 switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) {
220 case 1280: 222 case 1280:
221 PDEBUG(D_V4L2, "Configuring camera for SXGA mode"); 223 PDEBUG(D_CONF, "Configuring camera for SXGA mode");
222 224
223 for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) { 225 for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) {
224 switch (SXGA_s5k4aa[i][0]) { 226 switch (SXGA_s5k4aa[i][0]) {
@@ -251,7 +253,7 @@ int s5k4aa_start(struct sd *sd)
251 break; 253 break;
252 254
253 case 640: 255 case 640:
254 PDEBUG(D_V4L2, "Configuring camera for VGA mode"); 256 PDEBUG(D_CONF, "Configuring camera for VGA mode");
255 257
256 for (i = 0; i < ARRAY_SIZE(VGA_s5k4aa); i++) { 258 for (i = 0; i < ARRAY_SIZE(VGA_s5k4aa); i++) {
257 switch (VGA_s5k4aa[i][0]) { 259 switch (VGA_s5k4aa[i][0]) {
@@ -367,7 +369,7 @@ static int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
367 u8 data = S5K4AA_PAGE_MAP_2; 369 u8 data = S5K4AA_PAGE_MAP_2;
368 int err; 370 int err;
369 371
370 PDEBUG(D_V4L2, "Set exposure to %d", val); 372 PDEBUG(D_CONF, "Set exposure to %d", val);
371 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 373 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
372 if (err < 0) 374 if (err < 0)
373 return err; 375 return err;
@@ -389,7 +391,7 @@ static int s5k4aa_set_hvflip(struct gspca_dev *gspca_dev)
389 int hflip = sd->hflip->val; 391 int hflip = sd->hflip->val;
390 int vflip = sd->vflip->val; 392 int vflip = sd->vflip->val;
391 393
392 PDEBUG(D_V4L2, "Set hvflip %d %d", hflip, vflip); 394 PDEBUG(D_CONF, "Set hvflip %d %d", hflip, vflip);
393 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 395 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
394 if (err < 0) 396 if (err < 0)
395 return err; 397 return err;
@@ -439,7 +441,7 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
439 u8 data = S5K4AA_PAGE_MAP_2; 441 u8 data = S5K4AA_PAGE_MAP_2;
440 int err; 442 int err;
441 443
442 PDEBUG(D_V4L2, "Set gain to %d", val); 444 PDEBUG(D_CONF, "Set gain to %d", val);
443 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 445 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
444 if (err < 0) 446 if (err < 0)
445 return err; 447 return err;
@@ -456,7 +458,7 @@ static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
456 u8 data = S5K4AA_PAGE_MAP_2; 458 u8 data = S5K4AA_PAGE_MAP_2;
457 int err; 459 int err;
458 460
459 PDEBUG(D_V4L2, "Set brightness to %d", val); 461 PDEBUG(D_CONF, "Set brightness to %d", val);
460 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 462 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
461 if (err < 0) 463 if (err < 0)
462 return err; 464 return err;
@@ -471,7 +473,7 @@ static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val)
471 u8 data = S5K4AA_PAGE_MAP_2; 473 u8 data = S5K4AA_PAGE_MAP_2;
472 int err; 474 int err;
473 475
474 PDEBUG(D_V4L2, "Set noise to %d", val); 476 PDEBUG(D_CONF, "Set noise to %d", val);
475 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 477 err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
476 if (err < 0) 478 if (err < 0)
477 return err; 479 return err;
diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
index 69ee6e26b8ea..7cbc3a00bda8 100644
--- a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
@@ -51,6 +51,7 @@ int s5k83a_probe(struct sd *sd)
51{ 51{
52 u8 prod_id = 0, ver_id = 0; 52 u8 prod_id = 0, ver_id = 0;
53 int i, err = 0; 53 int i, err = 0;
54 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
54 55
55 if (force_sensor) { 56 if (force_sensor) {
56 if (force_sensor == S5K83A_SENSOR) { 57 if (force_sensor == S5K83A_SENSOR) {
diff --git a/drivers/media/usb/gspca/mr97310a.c b/drivers/media/usb/gspca/mr97310a.c
index 8f4714df5990..68bb2f359666 100644
--- a/drivers/media/usb/gspca/mr97310a.c
+++ b/drivers/media/usb/gspca/mr97310a.c
@@ -289,7 +289,7 @@ static int zero_the_pointer(struct gspca_dev *gspca_dev)
289 return err_code; 289 return err_code;
290 } 290 }
291 if (status != 0x0a) 291 if (status != 0x0a)
292 PDEBUG(D_ERR, "status is %02x", status); 292 PERR("status is %02x", status);
293 293
294 tries = 0; 294 tries = 0;
295 while (tries < 4) { 295 while (tries < 4) {
@@ -330,7 +330,7 @@ static void stream_stop(struct gspca_dev *gspca_dev)
330 gspca_dev->usb_buf[0] = 0x01; 330 gspca_dev->usb_buf[0] = 0x01;
331 gspca_dev->usb_buf[1] = 0x00; 331 gspca_dev->usb_buf[1] = 0x00;
332 if (mr_write(gspca_dev, 2) < 0) 332 if (mr_write(gspca_dev, 2) < 0)
333 PDEBUG(D_ERR, "Stream Stop failed"); 333 PERR("Stream Stop failed");
334} 334}
335 335
336static void lcd_stop(struct gspca_dev *gspca_dev) 336static void lcd_stop(struct gspca_dev *gspca_dev)
@@ -338,7 +338,7 @@ static void lcd_stop(struct gspca_dev *gspca_dev)
338 gspca_dev->usb_buf[0] = 0x19; 338 gspca_dev->usb_buf[0] = 0x19;
339 gspca_dev->usb_buf[1] = 0x54; 339 gspca_dev->usb_buf[1] = 0x54;
340 if (mr_write(gspca_dev, 2) < 0) 340 if (mr_write(gspca_dev, 2) < 0)
341 PDEBUG(D_ERR, "LCD Stop failed"); 341 PERR("LCD Stop failed");
342} 342}
343 343
344static int isoc_enable(struct gspca_dev *gspca_dev) 344static int isoc_enable(struct gspca_dev *gspca_dev)
@@ -1026,7 +1026,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1026 struct sd *sd = (struct sd *) gspca_dev; 1026 struct sd *sd = (struct sd *) gspca_dev;
1027 unsigned char *sof; 1027 unsigned char *sof;
1028 1028
1029 sof = pac_find_sof(&sd->sof_read, data, len); 1029 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
1030 if (sof) { 1030 if (sof) {
1031 int n; 1031 int n;
1032 1032
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index 9ad19a7ef81b..a3958ee86816 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -2034,6 +2034,7 @@ static unsigned char ov7670_abs_to_sm(unsigned char v)
2034/* Write a OV519 register */ 2034/* Write a OV519 register */
2035static void reg_w(struct sd *sd, u16 index, u16 value) 2035static void reg_w(struct sd *sd, u16 index, u16 value)
2036{ 2036{
2037 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2037 int ret, req = 0; 2038 int ret, req = 0;
2038 2039
2039 if (sd->gspca_dev.usb_err < 0) 2040 if (sd->gspca_dev.usb_err < 0)
@@ -2071,7 +2072,7 @@ static void reg_w(struct sd *sd, u16 index, u16 value)
2071 sd->gspca_dev.usb_buf, 1, 500); 2072 sd->gspca_dev.usb_buf, 1, 500);
2072leave: 2073leave:
2073 if (ret < 0) { 2074 if (ret < 0) {
2074 pr_err("reg_w %02x failed %d\n", index, ret); 2075 PERR("reg_w %02x failed %d\n", index, ret);
2075 sd->gspca_dev.usb_err = ret; 2076 sd->gspca_dev.usb_err = ret;
2076 return; 2077 return;
2077 } 2078 }
@@ -2081,6 +2082,7 @@ leave:
2081/* returns: negative is error, pos or zero is data */ 2082/* returns: negative is error, pos or zero is data */
2082static int reg_r(struct sd *sd, u16 index) 2083static int reg_r(struct sd *sd, u16 index)
2083{ 2084{
2085 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2084 int ret; 2086 int ret;
2085 int req; 2087 int req;
2086 2088
@@ -2110,7 +2112,7 @@ static int reg_r(struct sd *sd, u16 index)
2110 PDEBUG(D_USBI, "GET %02x 0000 %04x %02x", 2112 PDEBUG(D_USBI, "GET %02x 0000 %04x %02x",
2111 req, index, ret); 2113 req, index, ret);
2112 } else { 2114 } else {
2113 pr_err("reg_r %02x failed %d\n", index, ret); 2115 PERR("reg_r %02x failed %d\n", index, ret);
2114 sd->gspca_dev.usb_err = ret; 2116 sd->gspca_dev.usb_err = ret;
2115 } 2117 }
2116 2118
@@ -2121,6 +2123,7 @@ static int reg_r(struct sd *sd, u16 index)
2121static int reg_r8(struct sd *sd, 2123static int reg_r8(struct sd *sd,
2122 u16 index) 2124 u16 index)
2123{ 2125{
2126 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2124 int ret; 2127 int ret;
2125 2128
2126 if (sd->gspca_dev.usb_err < 0) 2129 if (sd->gspca_dev.usb_err < 0)
@@ -2135,7 +2138,7 @@ static int reg_r8(struct sd *sd,
2135 if (ret >= 0) { 2138 if (ret >= 0) {
2136 ret = sd->gspca_dev.usb_buf[0]; 2139 ret = sd->gspca_dev.usb_buf[0];
2137 } else { 2140 } else {
2138 pr_err("reg_r8 %02x failed %d\n", index, ret); 2141 PERR("reg_r8 %02x failed %d\n", index, ret);
2139 sd->gspca_dev.usb_err = ret; 2142 sd->gspca_dev.usb_err = ret;
2140 } 2143 }
2141 2144
@@ -2174,6 +2177,7 @@ static void reg_w_mask(struct sd *sd,
2174 */ 2177 */
2175static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) 2178static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n)
2176{ 2179{
2180 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2177 int ret; 2181 int ret;
2178 2182
2179 if (sd->gspca_dev.usb_err < 0) 2183 if (sd->gspca_dev.usb_err < 0)
@@ -2188,13 +2192,14 @@ static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n)
2188 0, index, 2192 0, index,
2189 sd->gspca_dev.usb_buf, n, 500); 2193 sd->gspca_dev.usb_buf, n, 500);
2190 if (ret < 0) { 2194 if (ret < 0) {
2191 pr_err("reg_w32 %02x failed %d\n", index, ret); 2195 PERR("reg_w32 %02x failed %d\n", index, ret);
2192 sd->gspca_dev.usb_err = ret; 2196 sd->gspca_dev.usb_err = ret;
2193 } 2197 }
2194} 2198}
2195 2199
2196static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) 2200static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value)
2197{ 2201{
2202 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2198 int rc, retries; 2203 int rc, retries;
2199 2204
2200 PDEBUG(D_USBO, "ov511_i2c_w %02x %02x", reg, value); 2205 PDEBUG(D_USBO, "ov511_i2c_w %02x %02x", reg, value);
@@ -2228,6 +2233,7 @@ static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value)
2228 2233
2229static int ov511_i2c_r(struct sd *sd, u8 reg) 2234static int ov511_i2c_r(struct sd *sd, u8 reg)
2230{ 2235{
2236 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2231 int rc, value, retries; 2237 int rc, value, retries;
2232 2238
2233 /* Two byte write cycle */ 2239 /* Two byte write cycle */
@@ -2300,6 +2306,8 @@ static void ov518_i2c_w(struct sd *sd,
2300 u8 reg, 2306 u8 reg,
2301 u8 value) 2307 u8 value)
2302{ 2308{
2309 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2310
2303 PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value); 2311 PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value);
2304 2312
2305 /* Select camera register */ 2313 /* Select camera register */
@@ -2325,6 +2333,7 @@ static void ov518_i2c_w(struct sd *sd,
2325 */ 2333 */
2326static int ov518_i2c_r(struct sd *sd, u8 reg) 2334static int ov518_i2c_r(struct sd *sd, u8 reg)
2327{ 2335{
2336 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2328 int value; 2337 int value;
2329 2338
2330 /* Select camera register */ 2339 /* Select camera register */
@@ -2345,6 +2354,7 @@ static int ov518_i2c_r(struct sd *sd, u8 reg)
2345 2354
2346static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) 2355static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value)
2347{ 2356{
2357 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2348 int ret; 2358 int ret;
2349 2359
2350 if (sd->gspca_dev.usb_err < 0) 2360 if (sd->gspca_dev.usb_err < 0)
@@ -2357,7 +2367,7 @@ static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value)
2357 (u16) value, (u16) reg, NULL, 0, 500); 2367 (u16) value, (u16) reg, NULL, 0, 500);
2358 2368
2359 if (ret < 0) { 2369 if (ret < 0) {
2360 pr_err("ovfx2_i2c_w %02x failed %d\n", reg, ret); 2370 PERR("ovfx2_i2c_w %02x failed %d\n", reg, ret);
2361 sd->gspca_dev.usb_err = ret; 2371 sd->gspca_dev.usb_err = ret;
2362 } 2372 }
2363 2373
@@ -2366,6 +2376,7 @@ static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value)
2366 2376
2367static int ovfx2_i2c_r(struct sd *sd, u8 reg) 2377static int ovfx2_i2c_r(struct sd *sd, u8 reg)
2368{ 2378{
2379 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2369 int ret; 2380 int ret;
2370 2381
2371 if (sd->gspca_dev.usb_err < 0) 2382 if (sd->gspca_dev.usb_err < 0)
@@ -2381,7 +2392,7 @@ static int ovfx2_i2c_r(struct sd *sd, u8 reg)
2381 ret = sd->gspca_dev.usb_buf[0]; 2392 ret = sd->gspca_dev.usb_buf[0];
2382 PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret); 2393 PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret);
2383 } else { 2394 } else {
2384 pr_err("ovfx2_i2c_r %02x failed %d\n", reg, ret); 2395 PERR("ovfx2_i2c_r %02x failed %d\n", reg, ret);
2385 sd->gspca_dev.usb_err = ret; 2396 sd->gspca_dev.usb_err = ret;
2386 } 2397 }
2387 2398
@@ -2478,6 +2489,8 @@ static void i2c_w_mask(struct sd *sd,
2478 * registers while the camera is streaming */ 2489 * registers while the camera is streaming */
2479static inline void ov51x_stop(struct sd *sd) 2490static inline void ov51x_stop(struct sd *sd)
2480{ 2491{
2492 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2493
2481 PDEBUG(D_STREAM, "stopping"); 2494 PDEBUG(D_STREAM, "stopping");
2482 sd->stopped = 1; 2495 sd->stopped = 1;
2483 switch (sd->bridge) { 2496 switch (sd->bridge) {
@@ -2507,6 +2520,8 @@ static inline void ov51x_stop(struct sd *sd)
2507 * actually stopped (for performance). */ 2520 * actually stopped (for performance). */
2508static inline void ov51x_restart(struct sd *sd) 2521static inline void ov51x_restart(struct sd *sd)
2509{ 2522{
2523 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2524
2510 PDEBUG(D_STREAM, "restarting"); 2525 PDEBUG(D_STREAM, "restarting");
2511 if (!sd->stopped) 2526 if (!sd->stopped)
2512 return; 2527 return;
@@ -2545,6 +2560,7 @@ static void ov51x_set_slave_ids(struct sd *sd, u8 slave);
2545static int init_ov_sensor(struct sd *sd, u8 slave) 2560static int init_ov_sensor(struct sd *sd, u8 slave)
2546{ 2561{
2547 int i; 2562 int i;
2563 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2548 2564
2549 ov51x_set_slave_ids(sd, slave); 2565 ov51x_set_slave_ids(sd, slave);
2550 2566
@@ -2624,10 +2640,11 @@ static void write_i2c_regvals(struct sd *sd,
2624/* This initializes the OV2x10 / OV3610 / OV3620 / OV9600 */ 2640/* This initializes the OV2x10 / OV3610 / OV3620 / OV9600 */
2625static void ov_hires_configure(struct sd *sd) 2641static void ov_hires_configure(struct sd *sd)
2626{ 2642{
2643 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2627 int high, low; 2644 int high, low;
2628 2645
2629 if (sd->bridge != BRIDGE_OVFX2) { 2646 if (sd->bridge != BRIDGE_OVFX2) {
2630 pr_err("error hires sensors only supported with ovfx2\n"); 2647 PERR("error hires sensors only supported with ovfx2\n");
2631 return; 2648 return;
2632 } 2649 }
2633 2650
@@ -2662,7 +2679,7 @@ static void ov_hires_configure(struct sd *sd)
2662 } 2679 }
2663 break; 2680 break;
2664 } 2681 }
2665 pr_err("Error unknown sensor type: %02x%02x\n", high, low); 2682 PERR("Error unknown sensor type: %02x%02x\n", high, low);
2666} 2683}
2667 2684
2668/* This initializes the OV8110, OV8610 sensor. The OV8110 uses 2685/* This initializes the OV8110, OV8610 sensor. The OV8110 uses
@@ -2670,6 +2687,7 @@ static void ov_hires_configure(struct sd *sd)
2670 */ 2687 */
2671static void ov8xx0_configure(struct sd *sd) 2688static void ov8xx0_configure(struct sd *sd)
2672{ 2689{
2690 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2673 int rc; 2691 int rc;
2674 2692
2675 PDEBUG(D_PROBE, "starting ov8xx0 configuration"); 2693 PDEBUG(D_PROBE, "starting ov8xx0 configuration");
@@ -2677,13 +2695,13 @@ static void ov8xx0_configure(struct sd *sd)
2677 /* Detect sensor (sub)type */ 2695 /* Detect sensor (sub)type */
2678 rc = i2c_r(sd, OV7610_REG_COM_I); 2696 rc = i2c_r(sd, OV7610_REG_COM_I);
2679 if (rc < 0) { 2697 if (rc < 0) {
2680 PDEBUG(D_ERR, "Error detecting sensor type"); 2698 PERR("Error detecting sensor type");
2681 return; 2699 return;
2682 } 2700 }
2683 if ((rc & 3) == 1) 2701 if ((rc & 3) == 1)
2684 sd->sensor = SEN_OV8610; 2702 sd->sensor = SEN_OV8610;
2685 else 2703 else
2686 pr_err("Unknown image sensor version: %d\n", rc & 3); 2704 PERR("Unknown image sensor version: %d\n", rc & 3);
2687} 2705}
2688 2706
2689/* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses 2707/* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
@@ -2691,6 +2709,7 @@ static void ov8xx0_configure(struct sd *sd)
2691 */ 2709 */
2692static void ov7xx0_configure(struct sd *sd) 2710static void ov7xx0_configure(struct sd *sd)
2693{ 2711{
2712 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2694 int rc, high, low; 2713 int rc, high, low;
2695 2714
2696 PDEBUG(D_PROBE, "starting OV7xx0 configuration"); 2715 PDEBUG(D_PROBE, "starting OV7xx0 configuration");
@@ -2701,7 +2720,7 @@ static void ov7xx0_configure(struct sd *sd)
2701 /* add OV7670 here 2720 /* add OV7670 here
2702 * it appears to be wrongly detected as a 7610 by default */ 2721 * it appears to be wrongly detected as a 7610 by default */
2703 if (rc < 0) { 2722 if (rc < 0) {
2704 pr_err("Error detecting sensor type\n"); 2723 PERR("Error detecting sensor type\n");
2705 return; 2724 return;
2706 } 2725 }
2707 if ((rc & 3) == 3) { 2726 if ((rc & 3) == 3) {
@@ -2729,19 +2748,19 @@ static void ov7xx0_configure(struct sd *sd)
2729 /* try to read product id registers */ 2748 /* try to read product id registers */
2730 high = i2c_r(sd, 0x0a); 2749 high = i2c_r(sd, 0x0a);
2731 if (high < 0) { 2750 if (high < 0) {
2732 pr_err("Error detecting camera chip PID\n"); 2751 PERR("Error detecting camera chip PID\n");
2733 return; 2752 return;
2734 } 2753 }
2735 low = i2c_r(sd, 0x0b); 2754 low = i2c_r(sd, 0x0b);
2736 if (low < 0) { 2755 if (low < 0) {
2737 pr_err("Error detecting camera chip VER\n"); 2756 PERR("Error detecting camera chip VER\n");
2738 return; 2757 return;
2739 } 2758 }
2740 if (high == 0x76) { 2759 if (high == 0x76) {
2741 switch (low) { 2760 switch (low) {
2742 case 0x30: 2761 case 0x30:
2743 pr_err("Sensor is an OV7630/OV7635\n"); 2762 PERR("Sensor is an OV7630/OV7635\n");
2744 pr_err("7630 is not supported by this driver\n"); 2763 PERR("7630 is not supported by this driver\n");
2745 return; 2764 return;
2746 case 0x40: 2765 case 0x40:
2747 PDEBUG(D_PROBE, "Sensor is an OV7645"); 2766 PDEBUG(D_PROBE, "Sensor is an OV7645");
@@ -2760,7 +2779,7 @@ static void ov7xx0_configure(struct sd *sd)
2760 sd->sensor = SEN_OV7660; 2779 sd->sensor = SEN_OV7660;
2761 break; 2780 break;
2762 default: 2781 default:
2763 pr_err("Unknown sensor: 0x76%02x\n", low); 2782 PERR("Unknown sensor: 0x76%02x\n", low);
2764 return; 2783 return;
2765 } 2784 }
2766 } else { 2785 } else {
@@ -2768,20 +2787,22 @@ static void ov7xx0_configure(struct sd *sd)
2768 sd->sensor = SEN_OV7620; 2787 sd->sensor = SEN_OV7620;
2769 } 2788 }
2770 } else { 2789 } else {
2771 pr_err("Unknown image sensor version: %d\n", rc & 3); 2790 PERR("Unknown image sensor version: %d\n", rc & 3);
2772 } 2791 }
2773} 2792}
2774 2793
2775/* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */ 2794/* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */
2776static void ov6xx0_configure(struct sd *sd) 2795static void ov6xx0_configure(struct sd *sd)
2777{ 2796{
2797 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2778 int rc; 2798 int rc;
2799
2779 PDEBUG(D_PROBE, "starting OV6xx0 configuration"); 2800 PDEBUG(D_PROBE, "starting OV6xx0 configuration");
2780 2801
2781 /* Detect sensor (sub)type */ 2802 /* Detect sensor (sub)type */
2782 rc = i2c_r(sd, OV7610_REG_COM_I); 2803 rc = i2c_r(sd, OV7610_REG_COM_I);
2783 if (rc < 0) { 2804 if (rc < 0) {
2784 pr_err("Error detecting sensor type\n"); 2805 PERR("Error detecting sensor type\n");
2785 return; 2806 return;
2786 } 2807 }
2787 2808
@@ -2810,7 +2831,7 @@ static void ov6xx0_configure(struct sd *sd)
2810 pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n"); 2831 pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n");
2811 break; 2832 break;
2812 default: 2833 default:
2813 pr_err("FATAL: Unknown sensor version: 0x%02x\n", rc); 2834 PERR("FATAL: Unknown sensor version: 0x%02x\n", rc);
2814 return; 2835 return;
2815 } 2836 }
2816 2837
@@ -2907,6 +2928,7 @@ static void ov51x_upload_quan_tables(struct sd *sd)
2907 7, 7, 7, 7, 7, 7, 8, 8 2928 7, 7, 7, 7, 7, 7, 8, 8
2908 }; 2929 };
2909 2930
2931 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
2910 const unsigned char *pYTable, *pUVTable; 2932 const unsigned char *pYTable, *pUVTable;
2911 unsigned char val0, val1; 2933 unsigned char val0, val1;
2912 int i, size, reg = R51x_COMP_LUT_BEGIN; 2934 int i, size, reg = R51x_COMP_LUT_BEGIN;
@@ -3300,7 +3322,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
3300 } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { 3322 } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) {
3301 ov_hires_configure(sd); 3323 ov_hires_configure(sd);
3302 } else { 3324 } else {
3303 pr_err("Can't determine sensor slave IDs\n"); 3325 PERR("Can't determine sensor slave IDs\n");
3304 goto error; 3326 goto error;
3305 } 3327 }
3306 3328
@@ -3433,7 +3455,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
3433 } 3455 }
3434 return gspca_dev->usb_err; 3456 return gspca_dev->usb_err;
3435error: 3457error:
3436 PDEBUG(D_ERR, "OV519 Config failed"); 3458 PERR("OV519 Config failed");
3437 return -EINVAL; 3459 return -EINVAL;
3438} 3460}
3439 3461
@@ -3459,6 +3481,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
3459 */ 3481 */
3460static void ov511_mode_init_regs(struct sd *sd) 3482static void ov511_mode_init_regs(struct sd *sd)
3461{ 3483{
3484 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
3462 int hsegs, vsegs, packet_size, fps, needed; 3485 int hsegs, vsegs, packet_size, fps, needed;
3463 int interlaced = 0; 3486 int interlaced = 0;
3464 struct usb_host_interface *alt; 3487 struct usb_host_interface *alt;
@@ -3467,7 +3490,7 @@ static void ov511_mode_init_regs(struct sd *sd)
3467 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 3490 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
3468 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 3491 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
3469 if (!alt) { 3492 if (!alt) {
3470 pr_err("Couldn't get altsetting\n"); 3493 PERR("Couldn't get altsetting\n");
3471 sd->gspca_dev.usb_err = -EIO; 3494 sd->gspca_dev.usb_err = -EIO;
3472 return; 3495 return;
3473 } 3496 }
@@ -3583,6 +3606,7 @@ static void ov511_mode_init_regs(struct sd *sd)
3583 */ 3606 */
3584static void ov518_mode_init_regs(struct sd *sd) 3607static void ov518_mode_init_regs(struct sd *sd)
3585{ 3608{
3609 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
3586 int hsegs, vsegs, packet_size; 3610 int hsegs, vsegs, packet_size;
3587 struct usb_host_interface *alt; 3611 struct usb_host_interface *alt;
3588 struct usb_interface *intf; 3612 struct usb_interface *intf;
@@ -3590,7 +3614,7 @@ static void ov518_mode_init_regs(struct sd *sd)
3590 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 3614 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
3591 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 3615 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
3592 if (!alt) { 3616 if (!alt) {
3593 pr_err("Couldn't get altsetting\n"); 3617 PERR("Couldn't get altsetting\n");
3594 sd->gspca_dev.usb_err = -EIO; 3618 sd->gspca_dev.usb_err = -EIO;
3595 return; 3619 return;
3596 } 3620 }
@@ -3750,6 +3774,8 @@ static void ov519_mode_init_regs(struct sd *sd)
3750 /* windows reads 0x55 at this point, why? */ 3774 /* windows reads 0x55 at this point, why? */
3751 }; 3775 };
3752 3776
3777 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
3778
3753 /******** Set the mode ********/ 3779 /******** Set the mode ********/
3754 switch (sd->sensor) { 3780 switch (sd->sensor) {
3755 default: 3781 default:
@@ -3865,11 +3891,10 @@ static void ov519_mode_init_regs(struct sd *sd)
3865 3891
3866static void mode_init_ov_sensor_regs(struct sd *sd) 3892static void mode_init_ov_sensor_regs(struct sd *sd)
3867{ 3893{
3868 struct gspca_dev *gspca_dev; 3894 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
3869 int qvga, xstart, xend, ystart, yend; 3895 int qvga, xstart, xend, ystart, yend;
3870 u8 v; 3896 u8 v;
3871 3897
3872 gspca_dev = &sd->gspca_dev;
3873 qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; 3898 qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1;
3874 3899
3875 /******** Mode (VGA/QVGA) and sensor specific regs ********/ 3900 /******** Mode (VGA/QVGA) and sensor specific regs ********/
@@ -4304,7 +4329,7 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
4304 /* Frame end */ 4329 /* Frame end */
4305 if ((in[9] + 1) * 8 != gspca_dev->width || 4330 if ((in[9] + 1) * 8 != gspca_dev->width ||
4306 (in[10] + 1) * 8 != gspca_dev->height) { 4331 (in[10] + 1) * 8 != gspca_dev->height) {
4307 PDEBUG(D_ERR, "Invalid frame size, got: %dx%d," 4332 PERR("Invalid frame size, got: %dx%d,"
4308 " requested: %dx%d\n", 4333 " requested: %dx%d\n",
4309 (in[9] + 1) * 8, (in[10] + 1) * 8, 4334 (in[9] + 1) * 8, (in[10] + 1) * 8,
4310 gspca_dev->width, gspca_dev->height); 4335 gspca_dev->width, gspca_dev->height);
@@ -4355,7 +4380,7 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
4355 except that they may contain part of the footer), are 4380 except that they may contain part of the footer), are
4356 numbered 0 */ 4381 numbered 0 */
4357 else if (sd->packet_nr == 0 || data[len]) { 4382 else if (sd->packet_nr == 0 || data[len]) {
4358 PDEBUG(D_ERR, "Invalid packet nr: %d (expect: %d)", 4383 PERR("Invalid packet nr: %d (expect: %d)",
4359 (int)data[len], (int)sd->packet_nr); 4384 (int)data[len], (int)sd->packet_nr);
4360 gspca_dev->last_packet_type = DISCARD_PACKET; 4385 gspca_dev->last_packet_type = DISCARD_PACKET;
4361 return; 4386 return;
@@ -4898,7 +4923,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
4898 QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF); 4923 QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF);
4899 4924
4900 if (hdl->error) { 4925 if (hdl->error) {
4901 pr_err("Could not initialize controls\n"); 4926 PERR("Could not initialize controls\n");
4902 return hdl->error; 4927 return hdl->error;
4903 } 4928 }
4904 if (gspca_dev->autogain) 4929 if (gspca_dev->autogain)
diff --git a/drivers/media/usb/gspca/ov534.c b/drivers/media/usb/gspca/ov534.c
index bb09d7884b89..2e28c81a03ab 100644
--- a/drivers/media/usb/gspca/ov534.c
+++ b/drivers/media/usb/gspca/ov534.c
@@ -690,7 +690,7 @@ static int sccb_check_status(struct gspca_dev *gspca_dev)
690 case 0x03: 690 case 0x03:
691 break; 691 break;
692 default: 692 default:
693 PDEBUG(D_ERR, "sccb status 0x%02x, attempt %d/5", 693 PERR("sccb status 0x%02x, attempt %d/5",
694 data, i + 1); 694 data, i + 1);
695 } 695 }
696 } 696 }
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index 3b75097dd34e..83519be94e58 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -373,7 +373,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
373 struct sd *sd = (struct sd *) gspca_dev; 373 struct sd *sd = (struct sd *) gspca_dev;
374 unsigned char *sof; 374 unsigned char *sof;
375 375
376 sof = pac_find_sof(&sd->sof_read, data, len); 376 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
377 if (sof) { 377 if (sof) {
378 int n; 378 int n;
379 379
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index add6f725ba50..682ef3340911 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -344,13 +344,10 @@ static void reg_w_var(struct gspca_dev *gspca_dev,
344 reg_w_page(gspca_dev, page3, page3_len); 344 reg_w_page(gspca_dev, page3, page3_len);
345 break; 345 break;
346 default: 346 default:
347#ifdef GSPCA_DEBUG
348 if (len > USB_BUF_SZ) { 347 if (len > USB_BUF_SZ) {
349 PDEBUG(D_ERR|D_STREAM, 348 PERR("Incorrect variable sequence");
350 "Incorrect variable sequence");
351 return; 349 return;
352 } 350 }
353#endif
354 while (len > 0) { 351 while (len > 0) {
355 if (len < 8) { 352 if (len < 8) {
356 reg_w_buf(gspca_dev, 353 reg_w_buf(gspca_dev,
@@ -795,7 +792,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
795 u8 *image; 792 u8 *image;
796 u8 *sof; 793 u8 *sof;
797 794
798 sof = pac_find_sof(&sd->sof_read, data, len); 795 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
799 if (sof) { 796 if (sof) {
800 int n, lum_offset, footer_length; 797 int n, lum_offset, footer_length;
801 798
diff --git a/drivers/media/usb/gspca/pac7311.c b/drivers/media/usb/gspca/pac7311.c
index a12dfbf6e051..1a5bdc853a80 100644
--- a/drivers/media/usb/gspca/pac7311.c
+++ b/drivers/media/usb/gspca/pac7311.c
@@ -262,8 +262,7 @@ static void reg_w_var(struct gspca_dev *gspca_dev,
262 break; 262 break;
263 default: 263 default:
264 if (len > USB_BUF_SZ) { 264 if (len > USB_BUF_SZ) {
265 PDEBUG(D_ERR|D_STREAM, 265 PERR("Incorrect variable sequence");
266 "Incorrect variable sequence");
267 return; 266 return;
268 } 267 }
269 while (len > 0) { 268 while (len > 0) {
@@ -575,7 +574,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
575 u8 *image; 574 u8 *image;
576 unsigned char *sof; 575 unsigned char *sof;
577 576
578 sof = pac_find_sof(&sd->sof_read, data, len); 577 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
579 if (sof) { 578 if (sof) {
580 int n, lum_offset, footer_length; 579 int n, lum_offset, footer_length;
581 580
diff --git a/drivers/media/usb/gspca/pac_common.h b/drivers/media/usb/gspca/pac_common.h
index 8462a7c1a338..fbc5e226c3e4 100644
--- a/drivers/media/usb/gspca/pac_common.h
+++ b/drivers/media/usb/gspca/pac_common.h
@@ -71,7 +71,7 @@ static const unsigned char pac_sof_marker[5] =
71 +----------+ 71 +----------+
72*/ 72*/
73 73
74static unsigned char *pac_find_sof(u8 *sof_read, 74static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, u8 *sof_read,
75 unsigned char *m, int len) 75 unsigned char *m, int len)
76{ 76{
77 int i; 77 int i;
diff --git a/drivers/media/usb/gspca/sn9c2028.c b/drivers/media/usb/gspca/sn9c2028.c
index 03fa3fd940b4..39b6b2e02963 100644
--- a/drivers/media/usb/gspca/sn9c2028.c
+++ b/drivers/media/usb/gspca/sn9c2028.c
@@ -650,13 +650,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
650 650
651 result = sn9c2028_read1(gspca_dev); 651 result = sn9c2028_read1(gspca_dev);
652 if (result < 0) 652 if (result < 0)
653 PDEBUG(D_ERR, "Camera Stop read failed"); 653 PERR("Camera Stop read failed");
654 654
655 memset(data, 0, 6); 655 memset(data, 0, 6);
656 data[0] = 0x14; 656 data[0] = 0x14;
657 result = sn9c2028_command(gspca_dev, data); 657 result = sn9c2028_command(gspca_dev, data);
658 if (result < 0) 658 if (result < 0)
659 PDEBUG(D_ERR, "Camera Stop command failed"); 659 PERR("Camera Stop command failed");
660} 660}
661 661
662/* Include sn9c2028 sof detection functions */ 662/* Include sn9c2028 sof detection functions */
diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c
index 8246e1dc3e9d..3b5ccb1c4cdf 100644
--- a/drivers/media/usb/gspca/sonixj.c
+++ b/drivers/media/usb/gspca/sonixj.c
@@ -1159,12 +1159,11 @@ static void reg_r(struct gspca_dev *gspca_dev,
1159 1159
1160 if (gspca_dev->usb_err < 0) 1160 if (gspca_dev->usb_err < 0)
1161 return; 1161 return;
1162#ifdef GSPCA_DEBUG
1163 if (len > USB_BUF_SZ) { 1162 if (len > USB_BUF_SZ) {
1164 pr_err("reg_r: buffer overflow\n"); 1163 PERR("reg_r: buffer overflow\n");
1165 return; 1164 return;
1166 } 1165 }
1167#endif 1166
1168 ret = usb_control_msg(gspca_dev->dev, 1167 ret = usb_control_msg(gspca_dev->dev,
1169 usb_rcvctrlpipe(gspca_dev->dev, 0), 1168 usb_rcvctrlpipe(gspca_dev->dev, 0),
1170 0, 1169 0,
@@ -1213,12 +1212,12 @@ static void reg_w(struct gspca_dev *gspca_dev,
1213 return; 1212 return;
1214 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", 1213 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1215 value, buffer[0], buffer[1]); 1214 value, buffer[0], buffer[1]);
1216#ifdef GSPCA_DEBUG 1215
1217 if (len > USB_BUF_SZ) { 1216 if (len > USB_BUF_SZ) {
1218 pr_err("reg_w: buffer overflow\n"); 1217 PERR("reg_w: buffer overflow\n");
1219 return; 1218 return;
1220 } 1219 }
1221#endif 1220
1222 memcpy(gspca_dev->usb_buf, buffer, len); 1221 memcpy(gspca_dev->usb_buf, buffer, len);
1223 ret = usb_control_msg(gspca_dev->dev, 1222 ret = usb_control_msg(gspca_dev->dev,
1224 usb_sndctrlpipe(gspca_dev->dev, 0), 1223 usb_sndctrlpipe(gspca_dev->dev, 0),
diff --git a/drivers/media/usb/gspca/spca1528.c b/drivers/media/usb/gspca/spca1528.c
index 14d635277d71..688592b289ea 100644
--- a/drivers/media/usb/gspca/spca1528.c
+++ b/drivers/media/usb/gspca/spca1528.c
@@ -146,7 +146,7 @@ static void wait_status_0(struct gspca_dev *gspca_dev)
146 w += 15; 146 w += 15;
147 msleep(w); 147 msleep(w);
148 } while (--i > 0); 148 } while (--i > 0);
149 PDEBUG(D_ERR, "wait_status_0 timeout"); 149 PERR("wait_status_0 timeout");
150 gspca_dev->usb_err = -ETIME; 150 gspca_dev->usb_err = -ETIME;
151} 151}
152 152
@@ -164,7 +164,7 @@ static void wait_status_1(struct gspca_dev *gspca_dev)
164 return; 164 return;
165 } 165 }
166 } while (--i > 0); 166 } while (--i > 0);
167 PDEBUG(D_ERR, "wait_status_1 timeout"); 167 PERR("wait_status_1 timeout");
168 gspca_dev->usb_err = -ETIME; 168 gspca_dev->usb_err = -ETIME;
169} 169}
170 170
diff --git a/drivers/media/usb/gspca/spca500.c b/drivers/media/usb/gspca/spca500.c
index 25cb68d0556d..9f8bf51fd64b 100644
--- a/drivers/media/usb/gspca/spca500.c
+++ b/drivers/media/usb/gspca/spca500.c
@@ -489,7 +489,7 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev)
489 return err; 489 return err;
490 err = reg_r_wait(gspca_dev, 0x06, 0, 0); 490 err = reg_r_wait(gspca_dev, 0x06, 0, 0);
491 if (err < 0) { 491 if (err < 0) {
492 PDEBUG(D_ERR, "reg_r_wait() failed"); 492 PERR("reg_r_wait() failed");
493 return err; 493 return err;
494 } 494 }
495 /* all ok */ 495 /* all ok */
@@ -505,7 +505,7 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev)
505static int spca500_synch310(struct gspca_dev *gspca_dev) 505static int spca500_synch310(struct gspca_dev *gspca_dev)
506{ 506{
507 if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) { 507 if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) {
508 PDEBUG(D_ERR, "Set packet size: set interface error"); 508 PERR("Set packet size: set interface error");
509 goto error; 509 goto error;
510 } 510 }
511 spca500_ping310(gspca_dev); 511 spca500_ping310(gspca_dev);
@@ -519,7 +519,7 @@ static int spca500_synch310(struct gspca_dev *gspca_dev)
519 if (usb_set_interface(gspca_dev->dev, 519 if (usb_set_interface(gspca_dev->dev,
520 gspca_dev->iface, 520 gspca_dev->iface,
521 gspca_dev->alt) < 0) { 521 gspca_dev->alt) < 0) {
522 PDEBUG(D_ERR, "Set packet size: set interface error"); 522 PERR("Set packet size: set interface error");
523 goto error; 523 goto error;
524 } 524 }
525 return 0; 525 return 0;
@@ -544,7 +544,7 @@ static void spca500_reinit(struct gspca_dev *gspca_dev)
544 err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, 544 err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840,
545 qtable_pocketdv); 545 qtable_pocketdv);
546 if (err < 0) 546 if (err < 0)
547 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init"); 547 PERR("spca50x_setup_qtable failed on init");
548 548
549 /* set qtable index */ 549 /* set qtable index */
550 reg_w(gspca_dev, 0x00, 0x8880, 2); 550 reg_w(gspca_dev, 0x00, 0x8880, 2);
@@ -639,7 +639,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
639 0x00, 0x8800, 0x8840, 639 0x00, 0x8800, 0x8840,
640 qtable_creative_pccam); 640 qtable_creative_pccam);
641 if (err < 0) 641 if (err < 0)
642 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 642 PERR("spca50x_setup_qtable failed");
643 /* Init SDRAM - needed for SDRAM access */ 643 /* Init SDRAM - needed for SDRAM access */
644 reg_w(gspca_dev, 0x00, 0x870a, 0x04); 644 reg_w(gspca_dev, 0x00, 0x870a, 0x04);
645 645
@@ -647,7 +647,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
647 reg_w(gspca_dev, 0x00, 0x8000, 0x0004); 647 reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
648 msleep(500); 648 msleep(500);
649 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) 649 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
650 PDEBUG(D_ERR, "reg_r_wait() failed"); 650 PERR("reg_r_wait() failed");
651 651
652 reg_r(gspca_dev, 0x816b, 1); 652 reg_r(gspca_dev, 0x816b, 1);
653 Data = gspca_dev->usb_buf[0]; 653 Data = gspca_dev->usb_buf[0];
@@ -660,13 +660,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
660 /* enable drop packet */ 660 /* enable drop packet */
661 err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001); 661 err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
662 if (err < 0) 662 if (err < 0)
663 PDEBUG(D_ERR, "failed to enable drop packet"); 663 PERR("failed to enable drop packet");
664 reg_w(gspca_dev, 0x00, 0x8880, 3); 664 reg_w(gspca_dev, 0x00, 0x8880, 3);
665 err = spca50x_setup_qtable(gspca_dev, 665 err = spca50x_setup_qtable(gspca_dev,
666 0x00, 0x8800, 0x8840, 666 0x00, 0x8800, 0x8840,
667 qtable_creative_pccam); 667 qtable_creative_pccam);
668 if (err < 0) 668 if (err < 0)
669 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 669 PERR("spca50x_setup_qtable failed");
670 670
671 /* Init SDRAM - needed for SDRAM access */ 671 /* Init SDRAM - needed for SDRAM access */
672 reg_w(gspca_dev, 0x00, 0x870a, 0x04); 672 reg_w(gspca_dev, 0x00, 0x870a, 0x04);
@@ -675,7 +675,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
675 reg_w(gspca_dev, 0x00, 0x8000, 0x0004); 675 reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
676 676
677 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) 677 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
678 PDEBUG(D_ERR, "reg_r_wait() failed"); 678 PERR("reg_r_wait() failed");
679 679
680 reg_r(gspca_dev, 0x816b, 1); 680 reg_r(gspca_dev, 0x816b, 1);
681 Data = gspca_dev->usb_buf[0]; 681 Data = gspca_dev->usb_buf[0];
@@ -689,18 +689,18 @@ static int sd_start(struct gspca_dev *gspca_dev)
689 /* do a full reset */ 689 /* do a full reset */
690 err = spca500_full_reset(gspca_dev); 690 err = spca500_full_reset(gspca_dev);
691 if (err < 0) 691 if (err < 0)
692 PDEBUG(D_ERR, "spca500_full_reset failed"); 692 PERR("spca500_full_reset failed");
693 693
694 /* enable drop packet */ 694 /* enable drop packet */
695 err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001); 695 err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
696 if (err < 0) 696 if (err < 0)
697 PDEBUG(D_ERR, "failed to enable drop packet"); 697 PERR("failed to enable drop packet");
698 reg_w(gspca_dev, 0x00, 0x8880, 3); 698 reg_w(gspca_dev, 0x00, 0x8880, 3);
699 err = spca50x_setup_qtable(gspca_dev, 699 err = spca50x_setup_qtable(gspca_dev,
700 0x00, 0x8800, 0x8840, 700 0x00, 0x8800, 0x8840,
701 qtable_creative_pccam); 701 qtable_creative_pccam);
702 if (err < 0) 702 if (err < 0)
703 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 703 PERR("spca50x_setup_qtable failed");
704 704
705 spca500_setmode(gspca_dev, xmult, ymult); 705 spca500_setmode(gspca_dev, xmult, ymult);
706 reg_w(gspca_dev, 0x20, 0x0001, 0x0004); 706 reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
@@ -709,7 +709,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
709 reg_w(gspca_dev, 0x00, 0x8000, 0x0004); 709 reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
710 710
711 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) 711 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
712 PDEBUG(D_ERR, "reg_r_wait() failed"); 712 PERR("reg_r_wait() failed");
713 713
714 reg_r(gspca_dev, 0x816b, 1); 714 reg_r(gspca_dev, 0x816b, 1);
715 Data = gspca_dev->usb_buf[0]; 715 Data = gspca_dev->usb_buf[0];
@@ -722,7 +722,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
722 /* do a full reset */ 722 /* do a full reset */
723 err = spca500_full_reset(gspca_dev); 723 err = spca500_full_reset(gspca_dev);
724 if (err < 0) 724 if (err < 0)
725 PDEBUG(D_ERR, "spca500_full_reset failed"); 725 PERR("spca500_full_reset failed");
726 /* enable drop packet */ 726 /* enable drop packet */
727 reg_w(gspca_dev, 0x00, 0x850a, 0x0001); 727 reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
728 reg_w(gspca_dev, 0x00, 0x8880, 0); 728 reg_w(gspca_dev, 0x00, 0x8880, 0);
@@ -730,7 +730,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
730 0x00, 0x8800, 0x8840, 730 0x00, 0x8800, 0x8840,
731 qtable_kodak_ez200); 731 qtable_kodak_ez200);
732 if (err < 0) 732 if (err < 0)
733 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 733 PERR("spca50x_setup_qtable failed");
734 spca500_setmode(gspca_dev, xmult, ymult); 734 spca500_setmode(gspca_dev, xmult, ymult);
735 735
736 reg_w(gspca_dev, 0x20, 0x0001, 0x0004); 736 reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
@@ -739,7 +739,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
739 reg_w(gspca_dev, 0x00, 0x8000, 0x0004); 739 reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
740 740
741 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) 741 if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
742 PDEBUG(D_ERR, "reg_r_wait() failed"); 742 PERR("reg_r_wait() failed");
743 743
744 reg_r(gspca_dev, 0x816b, 1); 744 reg_r(gspca_dev, 0x816b, 1);
745 Data = gspca_dev->usb_buf[0]; 745 Data = gspca_dev->usb_buf[0];
@@ -765,7 +765,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
765 err = spca50x_setup_qtable(gspca_dev, 765 err = spca50x_setup_qtable(gspca_dev,
766 0x00, 0x8800, 0x8840, qtable_pocketdv); 766 0x00, 0x8800, 0x8840, qtable_pocketdv);
767 if (err < 0) 767 if (err < 0)
768 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 768 PERR("spca50x_setup_qtable failed");
769 reg_w(gspca_dev, 0x00, 0x8880, 2); 769 reg_w(gspca_dev, 0x00, 0x8880, 2);
770 770
771 /* familycam Quicksmart pocketDV stuff */ 771 /* familycam Quicksmart pocketDV stuff */
@@ -795,7 +795,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
795 0x00, 0x8800, 795 0x00, 0x8800,
796 0x8840, qtable_creative_pccam); 796 0x8840, qtable_creative_pccam);
797 if (err < 0) 797 if (err < 0)
798 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 798 PERR("spca50x_setup_qtable failed");
799 reg_w(gspca_dev, 0x00, 0x8880, 3); 799 reg_w(gspca_dev, 0x00, 0x8880, 3);
800 reg_w(gspca_dev, 0x00, 0x800a, 0x00); 800 reg_w(gspca_dev, 0x00, 0x800a, 0x00);
801 /* Init SDRAM - needed for SDRAM access */ 801 /* Init SDRAM - needed for SDRAM access */
diff --git a/drivers/media/usb/gspca/spca501.c b/drivers/media/usb/gspca/spca501.c
index 3b7f777785b4..d92fd17d6701 100644
--- a/drivers/media/usb/gspca/spca501.c
+++ b/drivers/media/usb/gspca/spca501.c
@@ -1756,10 +1756,11 @@ static const __u16 spca501c_mysterious_init_data[][3] = {
1756 {} 1756 {}
1757}; 1757};
1758 1758
1759static int reg_write(struct usb_device *dev, 1759static int reg_write(struct gspca_dev *gspca_dev,
1760 __u16 req, __u16 index, __u16 value) 1760 __u16 req, __u16 index, __u16 value)
1761{ 1761{
1762 int ret; 1762 int ret;
1763 struct usb_device *dev = gspca_dev->dev;
1763 1764
1764 ret = usb_control_msg(dev, 1765 ret = usb_control_msg(dev,
1765 usb_sndctrlpipe(dev, 0), 1766 usb_sndctrlpipe(dev, 0),
@@ -1774,17 +1775,15 @@ static int reg_write(struct usb_device *dev,
1774} 1775}
1775 1776
1776 1777
1777static int write_vector(struct gspca_dev *gspca_dev, 1778static int write_vector(struct gspca_dev *gspca_dev, const __u16 data[][3])
1778 const __u16 data[][3])
1779{ 1779{
1780 struct usb_device *dev = gspca_dev->dev;
1781 int ret, i = 0; 1780 int ret, i = 0;
1782 1781
1783 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { 1782 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
1784 ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); 1783 ret = reg_write(gspca_dev, data[i][0], data[i][2],
1784 data[i][1]);
1785 if (ret < 0) { 1785 if (ret < 0) {
1786 PDEBUG(D_ERR, 1786 PERR("Reg write failed for 0x%02x,0x%02x,0x%02x",
1787 "Reg write failed for 0x%02x,0x%02x,0x%02x",
1788 data[i][0], data[i][1], data[i][2]); 1787 data[i][0], data[i][1], data[i][2]);
1789 return ret; 1788 return ret;
1790 } 1789 }
@@ -1795,30 +1794,28 @@ static int write_vector(struct gspca_dev *gspca_dev,
1795 1794
1796static void setbrightness(struct gspca_dev *gspca_dev, s32 val) 1795static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
1797{ 1796{
1798 reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x12, val); 1797 reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x12, val);
1799} 1798}
1800 1799
1801static void setcontrast(struct gspca_dev *gspca_dev, s32 val) 1800static void setcontrast(struct gspca_dev *gspca_dev, s32 val)
1802{ 1801{
1803 reg_write(gspca_dev->dev, 0x00, 0x00, 1802 reg_write(gspca_dev, 0x00, 0x00, (val >> 8) & 0xff);
1804 (val >> 8) & 0xff); 1803 reg_write(gspca_dev, 0x00, 0x01, val & 0xff);
1805 reg_write(gspca_dev->dev, 0x00, 0x01,
1806 val & 0xff);
1807} 1804}
1808 1805
1809static void setcolors(struct gspca_dev *gspca_dev, s32 val) 1806static void setcolors(struct gspca_dev *gspca_dev, s32 val)
1810{ 1807{
1811 reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x0c, val); 1808 reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x0c, val);
1812} 1809}
1813 1810
1814static void setblue_balance(struct gspca_dev *gspca_dev, s32 val) 1811static void setblue_balance(struct gspca_dev *gspca_dev, s32 val)
1815{ 1812{
1816 reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, val); 1813 reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x11, val);
1817} 1814}
1818 1815
1819static void setred_balance(struct gspca_dev *gspca_dev, s32 val) 1816static void setred_balance(struct gspca_dev *gspca_dev, s32 val)
1820{ 1817{
1821 reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, val); 1818 reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x13, val);
1822} 1819}
1823 1820
1824/* this function is called at probe time */ 1821/* this function is called at probe time */
@@ -1868,7 +1865,6 @@ error:
1868static int sd_start(struct gspca_dev *gspca_dev) 1865static int sd_start(struct gspca_dev *gspca_dev)
1869{ 1866{
1870 struct sd *sd = (struct sd *) gspca_dev; 1867 struct sd *sd = (struct sd *) gspca_dev;
1871 struct usb_device *dev = gspca_dev->dev;
1872 int mode; 1868 int mode;
1873 1869
1874 switch (sd->subtype) { 1870 switch (sd->subtype) {
@@ -1895,20 +1891,20 @@ static int sd_start(struct gspca_dev *gspca_dev)
1895 1891
1896 /* Enable ISO packet machine CTRL reg=2, 1892 /* Enable ISO packet machine CTRL reg=2,
1897 * index=1 bitmask=0x2 (bit ordinal 1) */ 1893 * index=1 bitmask=0x2 (bit ordinal 1) */
1898 reg_write(dev, SPCA50X_REG_USB, 0x6, 0x94); 1894 reg_write(gspca_dev, SPCA50X_REG_USB, 0x6, 0x94);
1899 switch (mode) { 1895 switch (mode) {
1900 case 0: /* 640x480 */ 1896 case 0: /* 640x480 */
1901 reg_write(dev, SPCA50X_REG_USB, 0x07, 0x004a); 1897 reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x004a);
1902 break; 1898 break;
1903 case 1: /* 320x240 */ 1899 case 1: /* 320x240 */
1904 reg_write(dev, SPCA50X_REG_USB, 0x07, 0x104a); 1900 reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x104a);
1905 break; 1901 break;
1906 default: 1902 default:
1907/* case 2: * 160x120 */ 1903/* case 2: * 160x120 */
1908 reg_write(dev, SPCA50X_REG_USB, 0x07, 0x204a); 1904 reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x204a);
1909 break; 1905 break;
1910 } 1906 }
1911 reg_write(dev, SPCA501_REG_CTLRL, 0x01, 0x02); 1907 reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x01, 0x02);
1912 1908
1913 return 0; 1909 return 0;
1914} 1910}
@@ -1917,7 +1913,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1917{ 1913{
1918 /* Disable ISO packet 1914 /* Disable ISO packet
1919 * machine CTRL reg=2, index=1 bitmask=0x0 (bit ordinal 1) */ 1915 * machine CTRL reg=2, index=1 bitmask=0x0 (bit ordinal 1) */
1920 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); 1916 reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x01, 0x00);
1921} 1917}
1922 1918
1923/* called on streamoff with alt 0 and on disconnect */ 1919/* called on streamoff with alt 0 and on disconnect */
@@ -1925,7 +1921,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
1925{ 1921{
1926 if (!gspca_dev->present) 1922 if (!gspca_dev->present)
1927 return; 1923 return;
1928 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); 1924 reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x05, 0x00);
1929} 1925}
1930 1926
1931static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1927static void sd_pkt_scan(struct gspca_dev *gspca_dev,
diff --git a/drivers/media/usb/gspca/spca505.c b/drivers/media/usb/gspca/spca505.c
index bc7d67c3cb04..232b330d2dd3 100644
--- a/drivers/media/usb/gspca/spca505.c
+++ b/drivers/media/usb/gspca/spca505.c
@@ -544,10 +544,11 @@ static const u8 spca505b_open_data_ccd[][3] = {
544 {} 544 {}
545}; 545};
546 546
547static int reg_write(struct usb_device *dev, 547static int reg_write(struct gspca_dev *gspca_dev,
548 u16 req, u16 index, u16 value) 548 u16 req, u16 index, u16 value)
549{ 549{
550 int ret; 550 int ret;
551 struct usb_device *dev = gspca_dev->dev;
551 552
552 ret = usb_control_msg(dev, 553 ret = usb_control_msg(dev,
553 usb_sndctrlpipe(dev, 0), 554 usb_sndctrlpipe(dev, 0),
@@ -584,11 +585,11 @@ static int reg_read(struct gspca_dev *gspca_dev,
584static int write_vector(struct gspca_dev *gspca_dev, 585static int write_vector(struct gspca_dev *gspca_dev,
585 const u8 data[][3]) 586 const u8 data[][3])
586{ 587{
587 struct usb_device *dev = gspca_dev->dev;
588 int ret, i = 0; 588 int ret, i = 0;
589 589
590 while (data[i][0] != 0) { 590 while (data[i][0] != 0) {
591 ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); 591 ret = reg_write(gspca_dev, data[i][0], data[i][2],
592 data[i][1]);
592 if (ret < 0) 593 if (ret < 0)
593 return ret; 594 return ret;
594 i++; 595 i++;
@@ -629,14 +630,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
629 630
630static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness) 631static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness)
631{ 632{
632 reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6); 633 reg_write(gspca_dev, 0x05, 0x00, (255 - brightness) >> 6);
633 reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2); 634 reg_write(gspca_dev, 0x05, 0x01, (255 - brightness) << 2);
634} 635}
635 636
636static int sd_start(struct gspca_dev *gspca_dev) 637static int sd_start(struct gspca_dev *gspca_dev)
637{ 638{
638 struct sd *sd = (struct sd *) gspca_dev; 639 struct sd *sd = (struct sd *) gspca_dev;
639 struct usb_device *dev = gspca_dev->dev;
640 int ret, mode; 640 int ret, mode;
641 static u8 mode_tb[][3] = { 641 static u8 mode_tb[][3] = {
642 /* r00 r06 r07 */ 642 /* r00 r06 r07 */
@@ -654,9 +654,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
654 ret = reg_read(gspca_dev, 0x06, 0x16); 654 ret = reg_read(gspca_dev, 0x06, 0x16);
655 655
656 if (ret < 0) { 656 if (ret < 0) {
657 PDEBUG(D_ERR|D_CONF, 657 PERR("register read failed err: %d", ret);
658 "register read failed err: %d",
659 ret);
660 return ret; 658 return ret;
661 } 659 }
662 if (ret != 0x0101) { 660 if (ret != 0x0101) {
@@ -664,22 +662,22 @@ static int sd_start(struct gspca_dev *gspca_dev)
664 ret); 662 ret);
665 } 663 }
666 664
667 ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a); 665 ret = reg_write(gspca_dev, 0x06, 0x16, 0x0a);
668 if (ret < 0) 666 if (ret < 0)
669 return ret; 667 return ret;
670 reg_write(gspca_dev->dev, 0x05, 0xc2, 0x12); 668 reg_write(gspca_dev, 0x05, 0xc2, 0x12);
671 669
672 /* necessary because without it we can see stream 670 /* necessary because without it we can see stream
673 * only once after loading module */ 671 * only once after loading module */
674 /* stopping usb registers Tomasz change */ 672 /* stopping usb registers Tomasz change */
675 reg_write(dev, 0x02, 0x00, 0x00); 673 reg_write(gspca_dev, 0x02, 0x00, 0x00);
676 674
677 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 675 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
678 reg_write(dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]); 676 reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]);
679 reg_write(dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]); 677 reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]);
680 reg_write(dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]); 678 reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]);
681 679
682 return reg_write(dev, SPCA50X_REG_USB, 680 return reg_write(gspca_dev, SPCA50X_REG_USB,
683 SPCA50X_USB_CTRL, 681 SPCA50X_USB_CTRL,
684 SPCA50X_CUSB_ENABLE); 682 SPCA50X_CUSB_ENABLE);
685} 683}
@@ -687,7 +685,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
687static void sd_stopN(struct gspca_dev *gspca_dev) 685static void sd_stopN(struct gspca_dev *gspca_dev)
688{ 686{
689 /* Disable ISO packet machine */ 687 /* Disable ISO packet machine */
690 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); 688 reg_write(gspca_dev, 0x02, 0x00, 0x00);
691} 689}
692 690
693/* called on streamoff with alt 0 and on disconnect */ 691/* called on streamoff with alt 0 and on disconnect */
@@ -697,11 +695,11 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
697 return; 695 return;
698 696
699 /* This maybe reset or power control */ 697 /* This maybe reset or power control */
700 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); 698 reg_write(gspca_dev, 0x03, 0x03, 0x20);
701 reg_write(gspca_dev->dev, 0x03, 0x01, 0x00); 699 reg_write(gspca_dev, 0x03, 0x01, 0x00);
702 reg_write(gspca_dev->dev, 0x03, 0x00, 0x01); 700 reg_write(gspca_dev, 0x03, 0x00, 0x01);
703 reg_write(gspca_dev->dev, 0x05, 0x10, 0x01); 701 reg_write(gspca_dev, 0x05, 0x10, 0x01);
704 reg_write(gspca_dev->dev, 0x05, 0x11, 0x0f); 702 reg_write(gspca_dev, 0x05, 0x11, 0x0f);
705} 703}
706 704
707static void sd_pkt_scan(struct gspca_dev *gspca_dev, 705static void sd_pkt_scan(struct gspca_dev *gspca_dev,
diff --git a/drivers/media/usb/gspca/spca508.c b/drivers/media/usb/gspca/spca508.c
index 1286b4170b88..75f2beb2ea5a 100644
--- a/drivers/media/usb/gspca/spca508.c
+++ b/drivers/media/usb/gspca/spca508.c
@@ -1241,10 +1241,10 @@ static const u16 spca508_vista_init_data[][2] = {
1241 {} 1241 {}
1242}; 1242};
1243 1243
1244static int reg_write(struct usb_device *dev, 1244static int reg_write(struct gspca_dev *gspca_dev, u16 index, u16 value)
1245 u16 index, u16 value)
1246{ 1245{
1247 int ret; 1246 int ret;
1247 struct usb_device *dev = gspca_dev->dev;
1248 1248
1249 ret = usb_control_msg(dev, 1249 ret = usb_control_msg(dev,
1250 usb_sndctrlpipe(dev, 0), 1250 usb_sndctrlpipe(dev, 0),
@@ -1286,22 +1286,21 @@ static int reg_read(struct gspca_dev *gspca_dev,
1286static int ssi_w(struct gspca_dev *gspca_dev, 1286static int ssi_w(struct gspca_dev *gspca_dev,
1287 u16 reg, u16 val) 1287 u16 reg, u16 val)
1288{ 1288{
1289 struct usb_device *dev = gspca_dev->dev;
1290 int ret, retry; 1289 int ret, retry;
1291 1290
1292 ret = reg_write(dev, 0x8802, reg >> 8); 1291 ret = reg_write(gspca_dev, 0x8802, reg >> 8);
1293 if (ret < 0) 1292 if (ret < 0)
1294 goto out; 1293 goto out;
1295 ret = reg_write(dev, 0x8801, reg & 0x00ff); 1294 ret = reg_write(gspca_dev, 0x8801, reg & 0x00ff);
1296 if (ret < 0) 1295 if (ret < 0)
1297 goto out; 1296 goto out;
1298 if ((reg & 0xff00) == 0x1000) { /* if 2 bytes */ 1297 if ((reg & 0xff00) == 0x1000) { /* if 2 bytes */
1299 ret = reg_write(dev, 0x8805, val & 0x00ff); 1298 ret = reg_write(gspca_dev, 0x8805, val & 0x00ff);
1300 if (ret < 0) 1299 if (ret < 0)
1301 goto out; 1300 goto out;
1302 val >>= 8; 1301 val >>= 8;
1303 } 1302 }
1304 ret = reg_write(dev, 0x8800, val); 1303 ret = reg_write(gspca_dev, 0x8800, val);
1305 if (ret < 0) 1304 if (ret < 0)
1306 goto out; 1305 goto out;
1307 1306
@@ -1314,8 +1313,7 @@ static int ssi_w(struct gspca_dev *gspca_dev,
1314 if (gspca_dev->usb_buf[0] == 0) 1313 if (gspca_dev->usb_buf[0] == 0)
1315 break; 1314 break;
1316 if (--retry <= 0) { 1315 if (--retry <= 0) {
1317 PDEBUG(D_ERR, "ssi_w busy %02x", 1316 PERR("ssi_w busy %02x", gspca_dev->usb_buf[0]);
1318 gspca_dev->usb_buf[0]);
1319 ret = -1; 1317 ret = -1;
1320 break; 1318 break;
1321 } 1319 }
@@ -1329,7 +1327,6 @@ out:
1329static int write_vector(struct gspca_dev *gspca_dev, 1327static int write_vector(struct gspca_dev *gspca_dev,
1330 const u16 (*data)[2]) 1328 const u16 (*data)[2])
1331{ 1329{
1332 struct usb_device *dev = gspca_dev->dev;
1333 int ret = 0; 1330 int ret = 0;
1334 1331
1335 while ((*data)[1] != 0) { 1332 while ((*data)[1] != 0) {
@@ -1337,7 +1334,8 @@ static int write_vector(struct gspca_dev *gspca_dev,
1337 if ((*data)[1] == 0xdd00) /* delay */ 1334 if ((*data)[1] == 0xdd00) /* delay */
1338 msleep((*data)[0]); 1335 msleep((*data)[0]);
1339 else 1336 else
1340 ret = reg_write(dev, (*data)[1], (*data)[0]); 1337 ret = reg_write(gspca_dev, (*data)[1],
1338 (*data)[0]);
1341 } else { 1339 } else {
1342 ret = ssi_w(gspca_dev, (*data)[1], (*data)[0]); 1340 ret = ssi_w(gspca_dev, (*data)[1], (*data)[0]);
1343 } 1341 }
@@ -1363,8 +1361,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
1363 spca508cs110_init_data, /* MicroInnovationIC200 4 */ 1361 spca508cs110_init_data, /* MicroInnovationIC200 4 */
1364 spca508_init_data, /* ViewQuestVQ110 5 */ 1362 spca508_init_data, /* ViewQuestVQ110 5 */
1365 }; 1363 };
1366
1367#ifdef GSPCA_DEBUG
1368 int data1, data2; 1364 int data1, data2;
1369 1365
1370 /* Read from global register the USB product and vendor IDs, just to 1366 /* Read from global register the USB product and vendor IDs, just to
@@ -1381,7 +1377,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
1381 1377
1382 data1 = reg_read(gspca_dev, 0x8621); 1378 data1 = reg_read(gspca_dev, 0x8621);
1383 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); 1379 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1);
1384#endif
1385 1380
1386 cam = &gspca_dev->cam; 1381 cam = &gspca_dev->cam;
1387 cam->cam_mode = sif_mode; 1382 cam->cam_mode = sif_mode;
@@ -1404,26 +1399,26 @@ static int sd_start(struct gspca_dev *gspca_dev)
1404 int mode; 1399 int mode;
1405 1400
1406 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 1401 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
1407 reg_write(gspca_dev->dev, 0x8500, mode); 1402 reg_write(gspca_dev, 0x8500, mode);
1408 switch (mode) { 1403 switch (mode) {
1409 case 0: 1404 case 0:
1410 case 1: 1405 case 1:
1411 reg_write(gspca_dev->dev, 0x8700, 0x28); /* clock */ 1406 reg_write(gspca_dev, 0x8700, 0x28); /* clock */
1412 break; 1407 break;
1413 default: 1408 default:
1414/* case 2: */ 1409/* case 2: */
1415/* case 3: */ 1410/* case 3: */
1416 reg_write(gspca_dev->dev, 0x8700, 0x23); /* clock */ 1411 reg_write(gspca_dev, 0x8700, 0x23); /* clock */
1417 break; 1412 break;
1418 } 1413 }
1419 reg_write(gspca_dev->dev, 0x8112, 0x10 | 0x20); 1414 reg_write(gspca_dev, 0x8112, 0x10 | 0x20);
1420 return 0; 1415 return 0;
1421} 1416}
1422 1417
1423static void sd_stopN(struct gspca_dev *gspca_dev) 1418static void sd_stopN(struct gspca_dev *gspca_dev)
1424{ 1419{
1425 /* Video ISO disable, Video Drop Packet enable: */ 1420 /* Video ISO disable, Video Drop Packet enable: */
1426 reg_write(gspca_dev->dev, 0x8112, 0x20); 1421 reg_write(gspca_dev, 0x8112, 0x20);
1427} 1422}
1428 1423
1429static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1424static void sd_pkt_scan(struct gspca_dev *gspca_dev,
@@ -1450,10 +1445,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1450static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness) 1445static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness)
1451{ 1446{
1452 /* MX seem contrast */ 1447 /* MX seem contrast */
1453 reg_write(gspca_dev->dev, 0x8651, brightness); 1448 reg_write(gspca_dev, 0x8651, brightness);
1454 reg_write(gspca_dev->dev, 0x8652, brightness); 1449 reg_write(gspca_dev, 0x8652, brightness);
1455 reg_write(gspca_dev->dev, 0x8653, brightness); 1450 reg_write(gspca_dev, 0x8653, brightness);
1456 reg_write(gspca_dev->dev, 0x8654, brightness); 1451 reg_write(gspca_dev, 0x8654, brightness);
1457} 1452}
1458 1453
1459static int sd_s_ctrl(struct v4l2_ctrl *ctrl) 1454static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
diff --git a/drivers/media/usb/gspca/spca561.c b/drivers/media/usb/gspca/spca561.c
index d1db3d8f6522..403d71cd65d9 100644
--- a/drivers/media/usb/gspca/spca561.c
+++ b/drivers/media/usb/gspca/spca561.c
@@ -285,9 +285,10 @@ static const __u16 spca561_161rev12A_data2[][2] = {
285 {} 285 {}
286}; 286};
287 287
288static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value) 288static void reg_w_val(struct gspca_dev *gspca_dev, __u16 index, __u8 value)
289{ 289{
290 int ret; 290 int ret;
291 struct usb_device *dev = gspca_dev->dev;
291 292
292 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 293 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
293 0, /* request */ 294 0, /* request */
@@ -301,12 +302,11 @@ static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value)
301static void write_vector(struct gspca_dev *gspca_dev, 302static void write_vector(struct gspca_dev *gspca_dev,
302 const __u16 data[][2]) 303 const __u16 data[][2])
303{ 304{
304 struct usb_device *dev = gspca_dev->dev;
305 int i; 305 int i;
306 306
307 i = 0; 307 i = 0;
308 while (data[i][1] != 0) { 308 while (data[i][1] != 0) {
309 reg_w_val(dev, data[i][1], data[i][0]); 309 reg_w_val(gspca_dev, data[i][1], data[i][0]);
310 i++; 310 i++;
311 } 311 }
312} 312}
@@ -339,9 +339,9 @@ static void i2c_write(struct gspca_dev *gspca_dev, __u16 value, __u16 reg)
339{ 339{
340 int retry = 60; 340 int retry = 60;
341 341
342 reg_w_val(gspca_dev->dev, 0x8801, reg); 342 reg_w_val(gspca_dev, 0x8801, reg);
343 reg_w_val(gspca_dev->dev, 0x8805, value); 343 reg_w_val(gspca_dev, 0x8805, value);
344 reg_w_val(gspca_dev->dev, 0x8800, value >> 8); 344 reg_w_val(gspca_dev, 0x8800, value >> 8);
345 do { 345 do {
346 reg_r(gspca_dev, 0x8803, 1); 346 reg_r(gspca_dev, 0x8803, 1);
347 if (!gspca_dev->usb_buf[0]) 347 if (!gspca_dev->usb_buf[0])
@@ -355,9 +355,9 @@ static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode)
355 int retry = 60; 355 int retry = 60;
356 __u8 value; 356 __u8 value;
357 357
358 reg_w_val(gspca_dev->dev, 0x8804, 0x92); 358 reg_w_val(gspca_dev, 0x8804, 0x92);
359 reg_w_val(gspca_dev->dev, 0x8801, reg); 359 reg_w_val(gspca_dev, 0x8801, reg);
360 reg_w_val(gspca_dev->dev, 0x8802, mode | 0x01); 360 reg_w_val(gspca_dev, 0x8802, mode | 0x01);
361 do { 361 do {
362 reg_r(gspca_dev, 0x8803, 1); 362 reg_r(gspca_dev, 0x8803, 1);
363 if (!gspca_dev->usb_buf[0]) { 363 if (!gspca_dev->usb_buf[0]) {
@@ -459,14 +459,13 @@ static int sd_init_72a(struct gspca_dev *gspca_dev)
459 write_sensor_72a(gspca_dev, rev72a_init_sensor1); 459 write_sensor_72a(gspca_dev, rev72a_init_sensor1);
460 write_vector(gspca_dev, rev72a_init_data2); 460 write_vector(gspca_dev, rev72a_init_data2);
461 write_sensor_72a(gspca_dev, rev72a_init_sensor2); 461 write_sensor_72a(gspca_dev, rev72a_init_sensor2);
462 reg_w_val(gspca_dev->dev, 0x8112, 0x30); 462 reg_w_val(gspca_dev, 0x8112, 0x30);
463 return 0; 463 return 0;
464} 464}
465 465
466static void setbrightness(struct gspca_dev *gspca_dev, s32 val) 466static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
467{ 467{
468 struct sd *sd = (struct sd *) gspca_dev; 468 struct sd *sd = (struct sd *) gspca_dev;
469 struct usb_device *dev = gspca_dev->dev;
470 __u16 reg; 469 __u16 reg;
471 470
472 if (sd->chip_revision == Rev012A) 471 if (sd->chip_revision == Rev012A)
@@ -474,16 +473,15 @@ static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
474 else 473 else
475 reg = 0x8611; 474 reg = 0x8611;
476 475
477 reg_w_val(dev, reg + 0, val); /* R */ 476 reg_w_val(gspca_dev, reg + 0, val); /* R */
478 reg_w_val(dev, reg + 1, val); /* Gr */ 477 reg_w_val(gspca_dev, reg + 1, val); /* Gr */
479 reg_w_val(dev, reg + 2, val); /* B */ 478 reg_w_val(gspca_dev, reg + 2, val); /* B */
480 reg_w_val(dev, reg + 3, val); /* Gb */ 479 reg_w_val(gspca_dev, reg + 3, val); /* Gb */
481} 480}
482 481
483static void setwhite(struct gspca_dev *gspca_dev, s32 white, s32 contrast) 482static void setwhite(struct gspca_dev *gspca_dev, s32 white, s32 contrast)
484{ 483{
485 struct sd *sd = (struct sd *) gspca_dev; 484 struct sd *sd = (struct sd *) gspca_dev;
486 struct usb_device *dev = gspca_dev->dev;
487 __u8 blue, red; 485 __u8 blue, red;
488 __u16 reg; 486 __u16 reg;
489 487
@@ -496,11 +494,11 @@ static void setwhite(struct gspca_dev *gspca_dev, s32 white, s32 contrast)
496 reg = 0x8651; 494 reg = 0x8651;
497 red += contrast - 0x20; 495 red += contrast - 0x20;
498 blue += contrast - 0x20; 496 blue += contrast - 0x20;
499 reg_w_val(dev, 0x8652, contrast + 0x20); /* Gr */ 497 reg_w_val(gspca_dev, 0x8652, contrast + 0x20); /* Gr */
500 reg_w_val(dev, 0x8654, contrast + 0x20); /* Gb */ 498 reg_w_val(gspca_dev, 0x8654, contrast + 0x20); /* Gb */
501 } 499 }
502 reg_w_val(dev, reg, red); 500 reg_w_val(gspca_dev, reg, red);
503 reg_w_val(dev, reg + 2, blue); 501 reg_w_val(gspca_dev, reg + 2, blue);
504} 502}
505 503
506/* rev 12a only */ 504/* rev 12a only */
@@ -570,7 +568,6 @@ static void setautogain(struct gspca_dev *gspca_dev, s32 val)
570 568
571static int sd_start_12a(struct gspca_dev *gspca_dev) 569static int sd_start_12a(struct gspca_dev *gspca_dev)
572{ 570{
573 struct usb_device *dev = gspca_dev->dev;
574 int mode; 571 int mode;
575 static const __u8 Reg8391[8] = 572 static const __u8 Reg8391[8] =
576 {0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00}; 573 {0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00};
@@ -578,34 +575,33 @@ static int sd_start_12a(struct gspca_dev *gspca_dev)
578 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 575 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
579 if (mode <= 1) { 576 if (mode <= 1) {
580 /* Use compression on 320x240 and above */ 577 /* Use compression on 320x240 and above */
581 reg_w_val(dev, 0x8500, 0x10 | mode); 578 reg_w_val(gspca_dev, 0x8500, 0x10 | mode);
582 } else { 579 } else {
583 /* I couldn't get the compression to work below 320x240 580 /* I couldn't get the compression to work below 320x240
584 * Fortunately at these resolutions the bandwidth 581 * Fortunately at these resolutions the bandwidth
585 * is sufficient to push raw frames at ~20fps */ 582 * is sufficient to push raw frames at ~20fps */
586 reg_w_val(dev, 0x8500, mode); 583 reg_w_val(gspca_dev, 0x8500, mode);
587 } /* -- qq@kuku.eu.org */ 584 } /* -- qq@kuku.eu.org */
588 585
589 gspca_dev->usb_buf[0] = 0xaa; 586 gspca_dev->usb_buf[0] = 0xaa;
590 gspca_dev->usb_buf[1] = 0x00; 587 gspca_dev->usb_buf[1] = 0x00;
591 reg_w_buf(gspca_dev, 0x8307, 2); 588 reg_w_buf(gspca_dev, 0x8307, 2);
592 /* clock - lower 0x8X values lead to fps > 30 */ 589 /* clock - lower 0x8X values lead to fps > 30 */
593 reg_w_val(gspca_dev->dev, 0x8700, 0x8a); 590 reg_w_val(gspca_dev, 0x8700, 0x8a);
594 /* 0x8f 0x85 0x27 clock */ 591 /* 0x8f 0x85 0x27 clock */
595 reg_w_val(gspca_dev->dev, 0x8112, 0x1e | 0x20); 592 reg_w_val(gspca_dev, 0x8112, 0x1e | 0x20);
596 reg_w_val(gspca_dev->dev, 0x850b, 0x03); 593 reg_w_val(gspca_dev, 0x850b, 0x03);
597 memcpy(gspca_dev->usb_buf, Reg8391, 8); 594 memcpy(gspca_dev->usb_buf, Reg8391, 8);
598 reg_w_buf(gspca_dev, 0x8391, 8); 595 reg_w_buf(gspca_dev, 0x8391, 8);
599 reg_w_buf(gspca_dev, 0x8390, 8); 596 reg_w_buf(gspca_dev, 0x8390, 8);
600 597
601 /* Led ON (bit 3 -> 0 */ 598 /* Led ON (bit 3 -> 0 */
602 reg_w_val(gspca_dev->dev, 0x8114, 0x00); 599 reg_w_val(gspca_dev, 0x8114, 0x00);
603 return 0; 600 return 0;
604} 601}
605static int sd_start_72a(struct gspca_dev *gspca_dev) 602static int sd_start_72a(struct gspca_dev *gspca_dev)
606{ 603{
607 struct sd *sd = (struct sd *) gspca_dev; 604 struct sd *sd = (struct sd *) gspca_dev;
608 struct usb_device *dev = gspca_dev->dev;
609 int Clck; 605 int Clck;
610 int mode; 606 int mode;
611 607
@@ -630,15 +626,15 @@ static int sd_start_72a(struct gspca_dev *gspca_dev)
630 Clck = 0x21; 626 Clck = 0x21;
631 break; 627 break;
632 } 628 }
633 reg_w_val(dev, 0x8700, Clck); /* 0x27 clock */ 629 reg_w_val(gspca_dev, 0x8700, Clck); /* 0x27 clock */
634 reg_w_val(dev, 0x8702, 0x81); 630 reg_w_val(gspca_dev, 0x8702, 0x81);
635 reg_w_val(dev, 0x8500, mode); /* mode */ 631 reg_w_val(gspca_dev, 0x8500, mode); /* mode */
636 write_sensor_72a(gspca_dev, rev72a_init_sensor2); 632 write_sensor_72a(gspca_dev, rev72a_init_sensor2);
637 setwhite(gspca_dev, v4l2_ctrl_g_ctrl(sd->hue), 633 setwhite(gspca_dev, v4l2_ctrl_g_ctrl(sd->hue),
638 v4l2_ctrl_g_ctrl(sd->contrast)); 634 v4l2_ctrl_g_ctrl(sd->contrast));
639/* setbrightness(gspca_dev); * fixme: bad values */ 635/* setbrightness(gspca_dev); * fixme: bad values */
640 setautogain(gspca_dev, v4l2_ctrl_g_ctrl(sd->autogain)); 636 setautogain(gspca_dev, v4l2_ctrl_g_ctrl(sd->autogain));
641 reg_w_val(dev, 0x8112, 0x10 | 0x20); 637 reg_w_val(gspca_dev, 0x8112, 0x10 | 0x20);
642 return 0; 638 return 0;
643} 639}
644 640
@@ -647,12 +643,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
647 struct sd *sd = (struct sd *) gspca_dev; 643 struct sd *sd = (struct sd *) gspca_dev;
648 644
649 if (sd->chip_revision == Rev012A) { 645 if (sd->chip_revision == Rev012A) {
650 reg_w_val(gspca_dev->dev, 0x8112, 0x0e); 646 reg_w_val(gspca_dev, 0x8112, 0x0e);
651 /* Led Off (bit 3 -> 1 */ 647 /* Led Off (bit 3 -> 1 */
652 reg_w_val(gspca_dev->dev, 0x8114, 0x08); 648 reg_w_val(gspca_dev, 0x8114, 0x08);
653 } else { 649 } else {
654 reg_w_val(gspca_dev->dev, 0x8112, 0x20); 650 reg_w_val(gspca_dev, 0x8112, 0x20);
655/* reg_w_val(gspca_dev->dev, 0x8102, 0x00); ?? */ 651/* reg_w_val(gspca_dev, 0x8102, 0x00); ?? */
656 } 652 }
657} 653}
658 654
@@ -736,7 +732,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
736 732
737 /* This should never happen */ 733 /* This should never happen */
738 if (len < 2) { 734 if (len < 2) {
739 PDEBUG(D_ERR, "Short SOF packet, ignoring"); 735 PERR("Short SOF packet, ignoring");
740 gspca_dev->last_packet_type = DISCARD_PACKET; 736 gspca_dev->last_packet_type = DISCARD_PACKET;
741 return; 737 return;
742 } 738 }
diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
index 1d99f10a3e19..a7ae0ec9fa91 100644
--- a/drivers/media/usb/gspca/sq905.c
+++ b/drivers/media/usb/gspca/sq905.c
@@ -387,7 +387,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
387 } 387 }
388 388
389 if (ret < 0) { 389 if (ret < 0) {
390 PDEBUG(D_ERR, "Start streaming command failed"); 390 PERR("Start streaming command failed");
391 return ret; 391 return ret;
392 } 392 }
393 /* Start the workqueue function to do the streaming */ 393 /* Start the workqueue function to do the streaming */
diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c
index 410cdcbb55d4..acb19fb9a3df 100644
--- a/drivers/media/usb/gspca/sq905c.c
+++ b/drivers/media/usb/gspca/sq905c.c
@@ -215,13 +215,13 @@ static int sd_config(struct gspca_dev *gspca_dev,
215 215
216 ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0); 216 ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0);
217 if (ret < 0) { 217 if (ret < 0) {
218 PDEBUG(D_ERR, "Get version command failed"); 218 PERR("Get version command failed");
219 return ret; 219 return ret;
220 } 220 }
221 221
222 ret = sq905c_read(gspca_dev, 0xf5, 0, 20); 222 ret = sq905c_read(gspca_dev, 0xf5, 0, 20);
223 if (ret < 0) { 223 if (ret < 0) {
224 PDEBUG(D_ERR, "Reading version command failed"); 224 PERR("Reading version command failed");
225 return ret; 225 return ret;
226 } 226 }
227 /* Note we leave out the usb id and the manufacturing date */ 227 /* Note we leave out the usb id and the manufacturing date */
@@ -286,7 +286,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
286 } 286 }
287 287
288 if (ret < 0) { 288 if (ret < 0) {
289 PDEBUG(D_ERR, "Start streaming command failed"); 289 PERR("Start streaming command failed");
290 return ret; 290 return ret;
291 } 291 }
292 /* Start the workqueue function to do the streaming */ 292 /* Start the workqueue function to do the streaming */
diff --git a/drivers/media/usb/gspca/sq930x.c b/drivers/media/usb/gspca/sq930x.c
index 7e8748b31e85..b10d0821111c 100644
--- a/drivers/media/usb/gspca/sq930x.c
+++ b/drivers/media/usb/gspca/sq930x.c
@@ -541,13 +541,11 @@ static void ucbus_write(struct gspca_dev *gspca_dev,
541 if (gspca_dev->usb_err < 0) 541 if (gspca_dev->usb_err < 0)
542 return; 542 return;
543 543
544#ifdef GSPCA_DEBUG
545 if ((batchsize - 1) * 3 > USB_BUF_SZ) { 544 if ((batchsize - 1) * 3 > USB_BUF_SZ) {
546 pr_err("Bug: usb_buf overflow\n"); 545 PERR("Bug: usb_buf overflow\n");
547 gspca_dev->usb_err = -ENOMEM; 546 gspca_dev->usb_err = -ENOMEM;
548 return; 547 return;
549 } 548 }
550#endif
551 549
552 for (;;) { 550 for (;;) {
553 len = ncmds; 551 len = ncmds;
diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c
index 67605272aaa8..9c0827631b9c 100644
--- a/drivers/media/usb/gspca/stv0680.c
+++ b/drivers/media/usb/gspca/stv0680.c
@@ -86,7 +86,7 @@ static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val,
86static int stv0680_handle_error(struct gspca_dev *gspca_dev, int ret) 86static int stv0680_handle_error(struct gspca_dev *gspca_dev, int ret)
87{ 87{
88 stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02); /* Get Last Error */ 88 stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02); /* Get Last Error */
89 PDEBUG(D_ERR, "last error: %i, command = 0x%x", 89 PERR("last error: %i, command = 0x%x",
90 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); 90 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
91 return ret; 91 return ret;
92} 92}
@@ -98,7 +98,7 @@ static int stv0680_get_video_mode(struct gspca_dev *gspca_dev)
98 gspca_dev->usb_buf[0] = 0x0f; 98 gspca_dev->usb_buf[0] = 0x0f;
99 99
100 if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) { 100 if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) {
101 PDEBUG(D_ERR, "Get_Camera_Mode failed"); 101 PERR("Get_Camera_Mode failed");
102 return stv0680_handle_error(gspca_dev, -EIO); 102 return stv0680_handle_error(gspca_dev, -EIO);
103 } 103 }
104 104
@@ -116,13 +116,13 @@ static int stv0680_set_video_mode(struct gspca_dev *gspca_dev, u8 mode)
116 gspca_dev->usb_buf[0] = mode; 116 gspca_dev->usb_buf[0] = mode;
117 117
118 if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) { 118 if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) {
119 PDEBUG(D_ERR, "Set_Camera_Mode failed"); 119 PERR("Set_Camera_Mode failed");
120 return stv0680_handle_error(gspca_dev, -EIO); 120 return stv0680_handle_error(gspca_dev, -EIO);
121 } 121 }
122 122
123 /* Verify we got what we've asked for */ 123 /* Verify we got what we've asked for */
124 if (stv0680_get_video_mode(gspca_dev) != mode) { 124 if (stv0680_get_video_mode(gspca_dev) != mode) {
125 PDEBUG(D_ERR, "Error setting camera video mode!"); 125 PERR("Error setting camera video mode!");
126 return -EIO; 126 return -EIO;
127 } 127 }
128 128
@@ -146,7 +146,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
146 /* ping camera to be sure STV0680 is present */ 146 /* ping camera to be sure STV0680 is present */
147 if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 || 147 if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 ||
148 gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) { 148 gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) {
149 PDEBUG(D_ERR, "STV(e): camera ping failed!!"); 149 PERR("STV(e): camera ping failed!!");
150 return stv0680_handle_error(gspca_dev, -ENODEV); 150 return stv0680_handle_error(gspca_dev, -ENODEV);
151 } 151 }
152 152
@@ -156,7 +156,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
156 156
157 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 || 157 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 ||
158 gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) { 158 gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) {
159 PDEBUG(D_ERR, "Could not get descriptor 0200."); 159 PERR("Could not get descriptor 0200.");
160 return stv0680_handle_error(gspca_dev, -ENODEV); 160 return stv0680_handle_error(gspca_dev, -ENODEV);
161 } 161 }
162 if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02) 162 if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02)
@@ -167,7 +167,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
167 return stv0680_handle_error(gspca_dev, -ENODEV); 167 return stv0680_handle_error(gspca_dev, -ENODEV);
168 168
169 if (!(gspca_dev->usb_buf[7] & 0x09)) { 169 if (!(gspca_dev->usb_buf[7] & 0x09)) {
170 PDEBUG(D_ERR, "Camera supports neither CIF nor QVGA mode"); 170 PERR("Camera supports neither CIF nor QVGA mode");
171 return -ENODEV; 171 return -ENODEV;
172 } 172 }
173 if (gspca_dev->usb_buf[7] & 0x01) 173 if (gspca_dev->usb_buf[7] & 0x01)
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
index 657160b4a1f7..55ee7a61c67f 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
@@ -42,8 +42,10 @@ static bool dump_sensor;
42int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data) 42int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data)
43{ 43{
44 int err; 44 int err;
45 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
45 struct usb_device *udev = sd->gspca_dev.dev; 46 struct usb_device *udev = sd->gspca_dev.dev;
46 __u8 *buf = sd->gspca_dev.usb_buf; 47 __u8 *buf = sd->gspca_dev.usb_buf;
48
47 u8 len = (i2c_data > 0xff) ? 2 : 1; 49 u8 len = (i2c_data > 0xff) ? 2 : 1;
48 50
49 buf[0] = i2c_data & 0xff; 51 buf[0] = i2c_data & 0xff;
@@ -62,6 +64,7 @@ int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data)
62int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data) 64int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data)
63{ 65{
64 int err; 66 int err;
67 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
65 struct usb_device *udev = sd->gspca_dev.dev; 68 struct usb_device *udev = sd->gspca_dev.dev;
66 __u8 *buf = sd->gspca_dev.usb_buf; 69 __u8 *buf = sd->gspca_dev.usb_buf;
67 70
@@ -110,6 +113,7 @@ static int stv06xx_write_sensor_finish(struct sd *sd)
110int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len) 113int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
111{ 114{
112 int err, i, j; 115 int err, i, j;
116 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
113 struct usb_device *udev = sd->gspca_dev.dev; 117 struct usb_device *udev = sd->gspca_dev.dev;
114 __u8 *buf = sd->gspca_dev.usb_buf; 118 __u8 *buf = sd->gspca_dev.usb_buf;
115 119
@@ -139,6 +143,7 @@ int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
139int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len) 143int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
140{ 144{
141 int err, i, j; 145 int err, i, j;
146 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
142 struct usb_device *udev = sd->gspca_dev.dev; 147 struct usb_device *udev = sd->gspca_dev.dev;
143 __u8 *buf = sd->gspca_dev.usb_buf; 148 __u8 *buf = sd->gspca_dev.usb_buf;
144 149
@@ -170,6 +175,7 @@ int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
170int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value) 175int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value)
171{ 176{
172 int err; 177 int err;
178 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
173 struct usb_device *udev = sd->gspca_dev.dev; 179 struct usb_device *udev = sd->gspca_dev.dev;
174 __u8 *buf = sd->gspca_dev.usb_buf; 180 __u8 *buf = sd->gspca_dev.usb_buf;
175 181
@@ -283,7 +289,7 @@ static int stv06xx_start(struct gspca_dev *gspca_dev)
283 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); 289 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
284 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); 290 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
285 if (!alt) { 291 if (!alt) {
286 PDEBUG(D_ERR, "Couldn't get altsetting"); 292 PERR("Couldn't get altsetting");
287 return -EIO; 293 return -EIO;
288 } 294 }
289 295
@@ -341,7 +347,7 @@ static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev)
341 347
342 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); 348 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
343 if (ret < 0) 349 if (ret < 0)
344 PDEBUG(D_ERR|D_STREAM, "set alt 1 err %d", ret); 350 PERR("set alt 1 err %d", ret);
345 351
346 return ret; 352 return ret;
347} 353}
@@ -406,7 +412,7 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev,
406 len -= 4; 412 len -= 4;
407 413
408 if (len < chunk_len) { 414 if (len < chunk_len) {
409 PDEBUG(D_ERR, "URB packet length is smaller" 415 PERR("URB packet length is smaller"
410 " than the specified chunk length"); 416 " than the specified chunk length");
411 gspca_dev->last_packet_type = DISCARD_PACKET; 417 gspca_dev->last_packet_type = DISCARD_PACKET;
412 return; 418 return;
@@ -449,7 +455,7 @@ frame_data:
449 sd->to_skip = gspca_dev->width * 4; 455 sd->to_skip = gspca_dev->width * 4;
450 456
451 if (chunk_len) 457 if (chunk_len)
452 PDEBUG(D_ERR, "Chunk length is " 458 PERR("Chunk length is "
453 "non-zero on a SOF"); 459 "non-zero on a SOF");
454 break; 460 break;
455 461
@@ -463,7 +469,7 @@ frame_data:
463 NULL, 0); 469 NULL, 0);
464 470
465 if (chunk_len) 471 if (chunk_len)
466 PDEBUG(D_ERR, "Chunk length is " 472 PERR("Chunk length is "
467 "non-zero on a EOF"); 473 "non-zero on a EOF");
468 break; 474 break;
469 475
@@ -596,7 +602,6 @@ MODULE_DEVICE_TABLE(usb, device_table);
596static int sd_probe(struct usb_interface *intf, 602static int sd_probe(struct usb_interface *intf,
597 const struct usb_device_id *id) 603 const struct usb_device_id *id)
598{ 604{
599 PDEBUG(D_PROBE, "Probing for a stv06xx device");
600 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 605 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
601 THIS_MODULE); 606 THIS_MODULE);
602} 607}
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
index 06fa54c5efb2..2220b70d47e6 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
@@ -255,7 +255,7 @@ static int hdcs_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
255 if (err < 0) 255 if (err < 0)
256 return err; 256 return err;
257 } 257 }
258 PDEBUG(D_V4L2, "Writing exposure %d, rowexp %d, srowexp %d", 258 PDEBUG(D_CONF, "Writing exposure %d, rowexp %d, srowexp %d",
259 val, rowexp, srowexp); 259 val, rowexp, srowexp);
260 return err; 260 return err;
261} 261}
@@ -280,7 +280,7 @@ static int hdcs_set_gains(struct sd *sd, u8 g)
280 280
281static int hdcs_set_gain(struct gspca_dev *gspca_dev, __s32 val) 281static int hdcs_set_gain(struct gspca_dev *gspca_dev, __s32 val)
282{ 282{
283 PDEBUG(D_V4L2, "Writing gain %d", val); 283 PDEBUG(D_CONF, "Writing gain %d", val);
284 return hdcs_set_gains((struct sd *) gspca_dev, 284 return hdcs_set_gains((struct sd *) gspca_dev,
285 val & 0xff); 285 val & 0xff);
286} 286}
@@ -467,6 +467,8 @@ static int hdcs_probe_1020(struct sd *sd)
467 467
468static int hdcs_start(struct sd *sd) 468static int hdcs_start(struct sd *sd)
469{ 469{
470 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
471
470 PDEBUG(D_STREAM, "Starting stream"); 472 PDEBUG(D_STREAM, "Starting stream");
471 473
472 return hdcs_set_state(sd, HDCS_STATE_RUN); 474 return hdcs_set_state(sd, HDCS_STATE_RUN);
@@ -474,6 +476,8 @@ static int hdcs_start(struct sd *sd)
474 476
475static int hdcs_stop(struct sd *sd) 477static int hdcs_stop(struct sd *sd)
476{ 478{
479 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
480
477 PDEBUG(D_STREAM, "Halting stream"); 481 PDEBUG(D_STREAM, "Halting stream");
478 482
479 return hdcs_set_state(sd, HDCS_STATE_SLEEP); 483 return hdcs_set_state(sd, HDCS_STATE_SLEEP);
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
index cdfc3d05ab6b..8206b7743300 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
@@ -190,6 +190,7 @@ static int pb0100_start(struct sd *sd)
190 int err, packet_size, max_packet_size; 190 int err, packet_size, max_packet_size;
191 struct usb_host_interface *alt; 191 struct usb_host_interface *alt;
192 struct usb_interface *intf; 192 struct usb_interface *intf;
193 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
193 struct cam *cam = &sd->gspca_dev.cam; 194 struct cam *cam = &sd->gspca_dev.cam;
194 u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv; 195 u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
195 196
@@ -239,6 +240,7 @@ static int pb0100_start(struct sd *sd)
239 240
240static int pb0100_stop(struct sd *sd) 241static int pb0100_stop(struct sd *sd)
241{ 242{
243 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
242 int err; 244 int err;
243 245
244 err = stv06xx_write_sensor(sd, PB_ABORTFRAME, 1); 246 err = stv06xx_write_sensor(sd, PB_ABORTFRAME, 1);
@@ -334,7 +336,7 @@ static int pb0100_set_gain(struct gspca_dev *gspca_dev, __s32 val)
334 err = stv06xx_write_sensor(sd, PB_G1GAIN, val); 336 err = stv06xx_write_sensor(sd, PB_G1GAIN, val);
335 if (!err) 337 if (!err)
336 err = stv06xx_write_sensor(sd, PB_G2GAIN, val); 338 err = stv06xx_write_sensor(sd, PB_G2GAIN, val);
337 PDEBUG(D_V4L2, "Set green gain to %d, status: %d", val, err); 339 PDEBUG(D_CONF, "Set green gain to %d, status: %d", val, err);
338 340
339 if (!err) 341 if (!err)
340 err = pb0100_set_red_balance(gspca_dev, ctrls->red->val); 342 err = pb0100_set_red_balance(gspca_dev, ctrls->red->val);
@@ -357,7 +359,7 @@ static int pb0100_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
357 val = 255; 359 val = 255;
358 360
359 err = stv06xx_write_sensor(sd, PB_RGAIN, val); 361 err = stv06xx_write_sensor(sd, PB_RGAIN, val);
360 PDEBUG(D_V4L2, "Set red gain to %d, status: %d", val, err); 362 PDEBUG(D_CONF, "Set red gain to %d, status: %d", val, err);
361 363
362 return err; 364 return err;
363} 365}
@@ -375,7 +377,7 @@ static int pb0100_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
375 val = 255; 377 val = 255;
376 378
377 err = stv06xx_write_sensor(sd, PB_BGAIN, val); 379 err = stv06xx_write_sensor(sd, PB_BGAIN, val);
378 PDEBUG(D_V4L2, "Set blue gain to %d, status: %d", val, err); 380 PDEBUG(D_CONF, "Set blue gain to %d, status: %d", val, err);
379 381
380 return err; 382 return err;
381} 383}
@@ -386,7 +388,7 @@ static int pb0100_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
386 int err; 388 int err;
387 389
388 err = stv06xx_write_sensor(sd, PB_RINTTIME, val); 390 err = stv06xx_write_sensor(sd, PB_RINTTIME, val);
389 PDEBUG(D_V4L2, "Set exposure to %d, status: %d", val, err); 391 PDEBUG(D_CONF, "Set exposure to %d, status: %d", val, err);
390 392
391 return err; 393 return err;
392} 394}
@@ -406,7 +408,7 @@ static int pb0100_set_autogain(struct gspca_dev *gspca_dev, __s32 val)
406 val = 0; 408 val = 0;
407 409
408 err = stv06xx_write_sensor(sd, PB_EXPGAIN, val); 410 err = stv06xx_write_sensor(sd, PB_EXPGAIN, val);
409 PDEBUG(D_V4L2, "Set autogain to %d (natural: %d), status: %d", 411 PDEBUG(D_CONF, "Set autogain to %d (natural: %d), status: %d",
410 val, ctrls->natural->val, err); 412 val, ctrls->natural->val, err);
411 413
412 return err; 414 return err;
@@ -428,7 +430,7 @@ static int pb0100_set_autogain_target(struct gspca_dev *gspca_dev, __s32 val)
428 if (!err) 430 if (!err)
429 err = stv06xx_write_sensor(sd, PB_R22, darkpixels); 431 err = stv06xx_write_sensor(sd, PB_R22, darkpixels);
430 432
431 PDEBUG(D_V4L2, "Set autogain target to %d, status: %d", val, err); 433 PDEBUG(D_CONF, "Set autogain target to %d, status: %d", val, err);
432 434
433 return err; 435 return err;
434} 436}
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
index 8a57990dfe0f..515a9e121653 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_st6422.c
@@ -279,6 +279,8 @@ static int st6422_start(struct sd *sd)
279 279
280static int st6422_stop(struct sd *sd) 280static int st6422_stop(struct sd *sd)
281{ 281{
282 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
283
282 PDEBUG(D_STREAM, "Halting stream"); 284 PDEBUG(D_STREAM, "Halting stream");
283 285
284 return 0; 286 return 0;
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
index e95fa8997d22..bf3e5c317a26 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
@@ -131,6 +131,7 @@ static int vv6410_init(struct sd *sd)
131static int vv6410_start(struct sd *sd) 131static int vv6410_start(struct sd *sd)
132{ 132{
133 int err; 133 int err;
134 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
134 struct cam *cam = &sd->gspca_dev.cam; 135 struct cam *cam = &sd->gspca_dev.cam;
135 u32 priv = cam->cam_mode[sd->gspca_dev.curr_mode].priv; 136 u32 priv = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
136 137
@@ -163,6 +164,7 @@ static int vv6410_start(struct sd *sd)
163 164
164static int vv6410_stop(struct sd *sd) 165static int vv6410_stop(struct sd *sd)
165{ 166{
167 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
166 int err; 168 int err;
167 169
168 /* Turn off LED */ 170 /* Turn off LED */
@@ -208,7 +210,7 @@ static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
208 else 210 else
209 i2c_data &= ~VV6410_HFLIP; 211 i2c_data &= ~VV6410_HFLIP;
210 212
211 PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 213 PDEBUG(D_CONF, "Set horizontal flip to %d", val);
212 err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data); 214 err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data);
213 215
214 return (err < 0) ? err : 0; 216 return (err < 0) ? err : 0;
@@ -229,7 +231,7 @@ static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
229 else 231 else
230 i2c_data &= ~VV6410_VFLIP; 232 i2c_data &= ~VV6410_VFLIP;
231 233
232 PDEBUG(D_V4L2, "Set vertical flip to %d", val); 234 PDEBUG(D_CONF, "Set vertical flip to %d", val);
233 err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data); 235 err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data);
234 236
235 return (err < 0) ? err : 0; 237 return (err < 0) ? err : 0;
@@ -240,7 +242,7 @@ static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val)
240 int err; 242 int err;
241 struct sd *sd = (struct sd *) gspca_dev; 243 struct sd *sd = (struct sd *) gspca_dev;
242 244
243 PDEBUG(D_V4L2, "Set analog gain to %d", val); 245 PDEBUG(D_CONF, "Set analog gain to %d", val);
244 err = stv06xx_write_sensor(sd, VV6410_ANALOGGAIN, 0xf0 | (val & 0xf)); 246 err = stv06xx_write_sensor(sd, VV6410_ANALOGGAIN, 0xf0 | (val & 0xf));
245 247
246 return (err < 0) ? err : 0; 248 return (err < 0) ? err : 0;
@@ -257,7 +259,7 @@ static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
257 fine = val % VV6410_CIF_LINELENGTH; 259 fine = val % VV6410_CIF_LINELENGTH;
258 coarse = min(512, val / VV6410_CIF_LINELENGTH); 260 coarse = min(512, val / VV6410_CIF_LINELENGTH);
259 261
260 PDEBUG(D_V4L2, "Set coarse exposure to %d, fine expsure to %d", 262 PDEBUG(D_CONF, "Set coarse exposure to %d, fine expsure to %d",
261 coarse, fine); 263 coarse, fine);
262 264
263 err = stv06xx_write_sensor(sd, VV6410_FINEH, fine >> 8); 265 err = stv06xx_write_sensor(sd, VV6410_FINEH, fine >> 8);
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index 9ccfcb1c6479..af8767a9bd4c 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -251,12 +251,10 @@ static void reg_r(struct gspca_dev *gspca_dev,
251{ 251{
252 int ret; 252 int ret;
253 253
254#ifdef GSPCA_DEBUG
255 if (len > USB_BUF_SZ) { 254 if (len > USB_BUF_SZ) {
256 pr_err("reg_r: buffer overflow\n"); 255 PERR("reg_r: buffer overflow\n");
257 return; 256 return;
258 } 257 }
259#endif
260 if (gspca_dev->usb_err < 0) 258 if (gspca_dev->usb_err < 0)
261 return; 259 return;
262 ret = usb_control_msg(gspca_dev->dev, 260 ret = usb_control_msg(gspca_dev->dev,
@@ -357,12 +355,14 @@ static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
357 PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]); 355 PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]);
358} 356}
359 357
360#ifdef GSPCA_DEBUG
361static void spca504_read_info(struct gspca_dev *gspca_dev) 358static void spca504_read_info(struct gspca_dev *gspca_dev)
362{ 359{
363 int i; 360 int i;
364 u8 info[6]; 361 u8 info[6];
365 362
363 if (gspca_debug < D_STREAM)
364 return;
365
366 for (i = 0; i < 6; i++) { 366 for (i = 0; i < 6; i++) {
367 reg_r(gspca_dev, 0, i, 1); 367 reg_r(gspca_dev, 0, i, 1);
368 info[i] = gspca_dev->usb_buf[0]; 368 info[i] = gspca_dev->usb_buf[0];
@@ -373,7 +373,6 @@ static void spca504_read_info(struct gspca_dev *gspca_dev)
373 info[0], info[1], info[2], 373 info[0], info[1], info[2],
374 info[3], info[4], info[5]); 374 info[3], info[4], info[5]);
375} 375}
376#endif
377 376
378static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, 377static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
379 u8 req, 378 u8 req,
@@ -432,11 +431,13 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
432 } 431 }
433} 432}
434 433
435#ifdef GSPCA_DEBUG
436static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) 434static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
437{ 435{
438 u8 *data; 436 u8 *data;
439 437
438 if (gspca_debug < D_STREAM)
439 return;
440
440 data = gspca_dev->usb_buf; 441 data = gspca_dev->usb_buf;
441 reg_r(gspca_dev, 0x20, 0, 5); 442 reg_r(gspca_dev, 0x20, 0, 5);
442 PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d", 443 PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d",
@@ -444,7 +445,6 @@ static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
444 reg_r(gspca_dev, 0x23, 0, 64); 445 reg_r(gspca_dev, 0x23, 0, 64);
445 reg_r(gspca_dev, 0x23, 1, 64); 446 reg_r(gspca_dev, 0x23, 1, 64);
446} 447}
447#endif
448 448
449static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) 449static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
450{ 450{
@@ -457,9 +457,8 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
457 reg_w_riv(gspca_dev, 0x31, 0, 0); 457 reg_w_riv(gspca_dev, 0x31, 0, 0);
458 spca504B_WaitCmdStatus(gspca_dev); 458 spca504B_WaitCmdStatus(gspca_dev);
459 spca504B_PollingDataReady(gspca_dev); 459 spca504B_PollingDataReady(gspca_dev);
460#ifdef GSPCA_DEBUG
461 spca50x_GetFirmware(gspca_dev); 460 spca50x_GetFirmware(gspca_dev);
462#endif 461
463 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */ 462 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
464 reg_r(gspca_dev, 0x24, 8, 1); 463 reg_r(gspca_dev, 0x24, 8, 1);
465 464
@@ -645,14 +644,10 @@ static int sd_init(struct gspca_dev *gspca_dev)
645 /* fall thru */ 644 /* fall thru */
646 case BRIDGE_SPCA533: 645 case BRIDGE_SPCA533:
647 spca504B_PollingDataReady(gspca_dev); 646 spca504B_PollingDataReady(gspca_dev);
648#ifdef GSPCA_DEBUG
649 spca50x_GetFirmware(gspca_dev); 647 spca50x_GetFirmware(gspca_dev);
650#endif
651 break; 648 break;
652 case BRIDGE_SPCA536: 649 case BRIDGE_SPCA536:
653#ifdef GSPCA_DEBUG
654 spca50x_GetFirmware(gspca_dev); 650 spca50x_GetFirmware(gspca_dev);
655#endif
656 reg_r(gspca_dev, 0x00, 0x5002, 1); 651 reg_r(gspca_dev, 0x00, 0x5002, 1);
657 reg_w_1(gspca_dev, 0x24, 0, 0, 0); 652 reg_w_1(gspca_dev, 0x24, 0, 0, 0);
658 reg_r(gspca_dev, 0x24, 0, 1); 653 reg_r(gspca_dev, 0x24, 0, 1);
@@ -678,9 +673,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
678/* case BRIDGE_SPCA504: */ 673/* case BRIDGE_SPCA504: */
679 PDEBUG(D_STREAM, "Opening SPCA504"); 674 PDEBUG(D_STREAM, "Opening SPCA504");
680 if (sd->subtype == AiptekMiniPenCam13) { 675 if (sd->subtype == AiptekMiniPenCam13) {
681#ifdef GSPCA_DEBUG
682 spca504_read_info(gspca_dev); 676 spca504_read_info(gspca_dev);
683#endif
684 677
685 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ 678 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
686 spca504A_acknowledged_command(gspca_dev, 0x24, 679 spca504A_acknowledged_command(gspca_dev, 0x24,
@@ -752,9 +745,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
752 break; 745 break;
753 case BRIDGE_SPCA504: 746 case BRIDGE_SPCA504:
754 if (sd->subtype == AiptekMiniPenCam13) { 747 if (sd->subtype == AiptekMiniPenCam13) {
755#ifdef GSPCA_DEBUG
756 spca504_read_info(gspca_dev); 748 spca504_read_info(gspca_dev);
757#endif
758 749
759 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ 750 /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
760 spca504A_acknowledged_command(gspca_dev, 0x24, 751 spca504A_acknowledged_command(gspca_dev, 0x24,
@@ -766,9 +757,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
766 0, 0, 0x9d, 1); 757 0, 0, 0x9d, 1);
767 } else { 758 } else {
768 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); 759 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
769#ifdef GSPCA_DEBUG
770 spca504_read_info(gspca_dev); 760 spca504_read_info(gspca_dev);
771#endif
772 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); 761 spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
773 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 762 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
774 } 763 }
diff --git a/drivers/media/usb/gspca/vc032x.c b/drivers/media/usb/gspca/vc032x.c
index e50079503d96..c00ac57de510 100644
--- a/drivers/media/usb/gspca/vc032x.c
+++ b/drivers/media/usb/gspca/vc032x.c
@@ -2927,7 +2927,6 @@ static void reg_r(struct gspca_dev *gspca_dev,
2927 u16 len) 2927 u16 len)
2928{ 2928{
2929 reg_r_i(gspca_dev, req, index, len); 2929 reg_r_i(gspca_dev, req, index, len);
2930#ifdef GSPCA_DEBUG
2931 if (gspca_dev->usb_err < 0) 2930 if (gspca_dev->usb_err < 0)
2932 return; 2931 return;
2933 if (len == 1) 2932 if (len == 1)
@@ -2936,7 +2935,6 @@ static void reg_r(struct gspca_dev *gspca_dev,
2936 else 2935 else
2937 PDEBUG(D_USBI, "GET %02x 0001 %04x %*ph", 2936 PDEBUG(D_USBI, "GET %02x 0001 %04x %*ph",
2938 req, index, 3, gspca_dev->usb_buf); 2937 req, index, 3, gspca_dev->usb_buf);
2939#endif
2940} 2938}
2941 2939
2942static void reg_w_i(struct gspca_dev *gspca_dev, 2940static void reg_w_i(struct gspca_dev *gspca_dev,
@@ -2964,11 +2962,9 @@ static void reg_w(struct gspca_dev *gspca_dev,
2964 u16 value, 2962 u16 value,
2965 u16 index) 2963 u16 index)
2966{ 2964{
2967#ifdef GSPCA_DEBUG
2968 if (gspca_dev->usb_err < 0) 2965 if (gspca_dev->usb_err < 0)
2969 return; 2966 return;
2970 PDEBUG(D_USBO, "SET %02x %04x %04x", req, value, index); 2967 PDEBUG(D_USBO, "SET %02x %04x %04x", req, value, index);
2971#endif
2972 reg_w_i(gspca_dev, req, value, index); 2968 reg_w_i(gspca_dev, req, value, index);
2973} 2969}
2974 2970
@@ -3044,8 +3040,7 @@ static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
3044 if (value == 0 && ptsensor_info->IdAdd == 0x82) 3040 if (value == 0 && ptsensor_info->IdAdd == 0x82)
3045 value = read_sensor_register(gspca_dev, 0x83); 3041 value = read_sensor_register(gspca_dev, 0x83);
3046 if (value != 0) { 3042 if (value != 0) {
3047 PDEBUG(D_ERR|D_PROBE, "Sensor ID %04x (%d)", 3043 PDEBUG(D_PROBE, "Sensor ID %04x (%d)", value, i);
3048 value, i);
3049 if (value == ptsensor_info->VpId) 3044 if (value == ptsensor_info->VpId)
3050 return ptsensor_info->sensorId; 3045 return ptsensor_info->sensorId;
3051 3046
@@ -3069,14 +3064,12 @@ static void i2c_write(struct gspca_dev *gspca_dev,
3069{ 3064{
3070 int retry; 3065 int retry;
3071 3066
3072#ifdef GSPCA_DEBUG
3073 if (gspca_dev->usb_err < 0) 3067 if (gspca_dev->usb_err < 0)
3074 return; 3068 return;
3075 if (size == 1) 3069 if (size == 1)
3076 PDEBUG(D_USBO, "i2c_w %02x %02x", reg, *val); 3070 PDEBUG(D_USBO, "i2c_w %02x %02x", reg, *val);
3077 else 3071 else
3078 PDEBUG(D_USBO, "i2c_w %02x %02x%02x", reg, *val, val[1]); 3072 PDEBUG(D_USBO, "i2c_w %02x %02x%02x", reg, *val, val[1]);
3079#endif
3080 reg_r_i(gspca_dev, 0xa1, 0xb33f, 1); 3073 reg_r_i(gspca_dev, 0xa1, 0xb33f, 1);
3081/*fixme:should check if (!(gspca_dev->usb_buf[0] & 0x02)) error*/ 3074/*fixme:should check if (!(gspca_dev->usb_buf[0] & 0x02)) error*/
3082 reg_w_i(gspca_dev, 0xa0, size, 0xb334); 3075 reg_w_i(gspca_dev, 0xa0, size, 0xb334);
diff --git a/drivers/media/usb/gspca/w996Xcf.c b/drivers/media/usb/gspca/w996Xcf.c
index 9e3a909e0a00..2165da0c7ce1 100644
--- a/drivers/media/usb/gspca/w996Xcf.c
+++ b/drivers/media/usb/gspca/w996Xcf.c
@@ -232,6 +232,7 @@ static void w9968cf_smbus_write_nack(struct sd *sd)
232 232
233static void w9968cf_smbus_read_ack(struct sd *sd) 233static void w9968cf_smbus_read_ack(struct sd *sd)
234{ 234{
235 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
235 int sda; 236 int sda;
236 237
237 /* Ensure SDA is high before raising clock to avoid a spurious stop */ 238 /* Ensure SDA is high before raising clock to avoid a spurious stop */
@@ -248,6 +249,7 @@ static void w9968cf_smbus_read_ack(struct sd *sd)
248/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ 249/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
249static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) 250static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value)
250{ 251{
252 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
251 u16* data = (u16 *)sd->gspca_dev.usb_buf; 253 u16* data = (u16 *)sd->gspca_dev.usb_buf;
252 254
253 data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0); 255 data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0);
@@ -297,6 +299,7 @@ static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value)
297/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ 299/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
298static int w9968cf_i2c_r(struct sd *sd, u8 reg) 300static int w9968cf_i2c_r(struct sd *sd, u8 reg)
299{ 301{
302 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
300 int ret = 0; 303 int ret = 0;
301 u8 value; 304 u8 value;
302 305
@@ -326,7 +329,7 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg)
326 ret = value; 329 ret = value;
327 PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); 330 PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value);
328 } else 331 } else
329 PDEBUG(D_ERR, "i2c read [0x%02x] failed", reg); 332 PERR("i2c read [0x%02x] failed", reg);
330 333
331 return ret; 334 return ret;
332} 335}
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index a8dc421f9f1f..cbfc2f921427 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -6259,12 +6259,11 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6259 retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */ 6259 retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */
6260 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword); 6260 PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword);
6261 if (retword == 0x2030) { 6261 if (retword == 0x2030) {
6262#ifdef GSPCA_DEBUG
6263 u8 retbyte; 6262 u8 retbyte;
6264 6263
6265 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */ 6264 retbyte = i2c_read(gspca_dev, 0x02); /* revision number */
6266 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte); 6265 PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte);
6267#endif 6266
6268 send_unknown(gspca_dev, SENSOR_PO2030); 6267 send_unknown(gspca_dev, SENSOR_PO2030);
6269 return retword; 6268 return retword;
6270 } 6269 }