aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/conex.c4
-rw-r--r--drivers/media/video/gspca/etoms.c4
-rw-r--r--drivers/media/video/gspca/gspca.c8
-rw-r--r--drivers/media/video/gspca/gspca.h3
-rw-r--r--drivers/media/video/gspca/mars.c21
-rw-r--r--drivers/media/video/gspca/sonixb.c24
-rw-r--r--drivers/media/video/gspca/sonixj.c43
-rw-r--r--drivers/media/video/gspca/sunplus.c147
-rw-r--r--drivers/media/video/gspca/t613.c2
9 files changed, 116 insertions, 140 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 3db5c1e3283a..8c91ffde9536 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -124,7 +124,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
124 struct usb_device *dev = gspca_dev->dev; 124 struct usb_device *dev = gspca_dev->dev;
125 125
126#ifdef GSPCA_DEBUG 126#ifdef GSPCA_DEBUG
127 if (len > sizeof gspca_dev->usb_buf) { 127 if (len > USB_BUF_SZ) {
128 err("reg_r: buffer overflow"); 128 err("reg_r: buffer overflow");
129 return; 129 return;
130 } 130 }
@@ -164,7 +164,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
164 struct usb_device *dev = gspca_dev->dev; 164 struct usb_device *dev = gspca_dev->dev;
165 165
166#ifdef GSPCA_DEBUG 166#ifdef GSPCA_DEBUG
167 if (len > sizeof gspca_dev->usb_buf) { 167 if (len > USB_BUF_SZ) {
168 err("reg_w: buffer overflow"); 168 err("reg_w: buffer overflow");
169 return; 169 return;
170 } 170 }
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index c03b1f45de10..9eb6adb24bd0 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -235,7 +235,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
235 struct usb_device *dev = gspca_dev->dev; 235 struct usb_device *dev = gspca_dev->dev;
236 236
237#ifdef GSPCA_DEBUG 237#ifdef GSPCA_DEBUG
238 if (len > sizeof gspca_dev->usb_buf) { 238 if (len > USB_BUF_SZ) {
239 err("reg_r: buffer overflow"); 239 err("reg_r: buffer overflow");
240 return; 240 return;
241 } 241 }
@@ -273,7 +273,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
273 struct usb_device *dev = gspca_dev->dev; 273 struct usb_device *dev = gspca_dev->dev;
274 274
275#ifdef GSPCA_DEBUG 275#ifdef GSPCA_DEBUG
276 if (len > sizeof gspca_dev->usb_buf) { 276 if (len > USB_BUF_SZ) {
277 err("reg_w: buffer overflow"); 277 err("reg_w: buffer overflow");
278 return; 278 return;
279 } 279 }
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 42b0b83d0953..7be69284da03 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -1731,6 +1731,12 @@ int gspca_dev_probe(struct usb_interface *intf,
1731 err("couldn't kzalloc gspca struct"); 1731 err("couldn't kzalloc gspca struct");
1732 return -EIO; 1732 return -EIO;
1733 } 1733 }
1734 gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
1735 if (!gspca_dev->usb_buf) {
1736 err("out of memory");
1737 ret = -EIO;
1738 goto out;
1739 }
1734 gspca_dev->dev = dev; 1740 gspca_dev->dev = dev;
1735 gspca_dev->iface = interface->bInterfaceNumber; 1741 gspca_dev->iface = interface->bInterfaceNumber;
1736 gspca_dev->nbalt = intf->num_altsetting; 1742 gspca_dev->nbalt = intf->num_altsetting;
@@ -1774,6 +1780,7 @@ int gspca_dev_probe(struct usb_interface *intf,
1774 PDEBUG(D_PROBE, "probe ok"); 1780 PDEBUG(D_PROBE, "probe ok");
1775 return 0; 1781 return 0;
1776out: 1782out:
1783 kfree(gspca_dev->usb_buf);
1777 kfree(gspca_dev); 1784 kfree(gspca_dev);
1778 return ret; 1785 return ret;
1779} 1786}
@@ -1806,6 +1813,7 @@ void gspca_disconnect(struct usb_interface *intf)
1806/* We don't want people trying to open up the device */ 1813/* We don't want people trying to open up the device */
1807 video_unregister_device(&gspca_dev->vdev); 1814 video_unregister_device(&gspca_dev->vdev);
1808/* Free the memory */ 1815/* Free the memory */
1816 kfree(gspca_dev->usb_buf);
1809 kfree(gspca_dev); 1817 kfree(gspca_dev);
1810 PDEBUG(D_PROBE, "disconnect complete"); 1818 PDEBUG(D_PROBE, "disconnect complete");
1811} 1819}
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 7c2f44b2397f..c17625cff9ba 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -127,7 +127,8 @@ struct gspca_dev {
127 const struct sd_desc *sd_desc; /* subdriver description */ 127 const struct sd_desc *sd_desc; /* subdriver description */
128 unsigned ctrl_dis; /* disabled controls (bit map) */ 128 unsigned ctrl_dis; /* disabled controls (bit map) */
129 129
130 __u8 usb_buf[8]; /* buffer for USB exchanges */ 130#define USB_BUF_SZ 64
131 __u8 *usb_buf; /* buffer for USB exchanges */
131 struct urb *urb[MAX_NURBS]; 132 struct urb *urb[MAX_NURBS];
132 133
133 __u8 *frbuf; /* buffer for nframes */ 134 __u8 *frbuf; /* buffer for nframes */
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index 281475913a61..4d5db47ba8cb 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -100,22 +100,6 @@ static int reg_w(struct gspca_dev *gspca_dev,
100 return rc; 100 return rc;
101} 101}
102 102
103static int reg_w_buf(struct gspca_dev *gspca_dev,
104 __u16 index, __u8 *buf, int len)
105{
106 int rc;
107
108 rc = usb_control_msg(gspca_dev->dev,
109 usb_sndbulkpipe(gspca_dev->dev, 4),
110 0x12,
111 0xc8, /* ?? */
112 0, /* value */
113 index, buf, len, 500);
114 if (rc < 0)
115 PDEBUG(D_ERR, "reg write [%02x] error %d", index, rc);
116 return rc;
117}
118
119static void bulk_w(struct gspca_dev *gspca_dev, 103static void bulk_w(struct gspca_dev *gspca_dev,
120 __u16 *pch, 104 __u16 *pch,
121 __u16 Address) 105 __u16 Address)
@@ -175,7 +159,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
175 /* 159 /*
176 Initialize the MR97113 chip register 160 Initialize the MR97113 chip register
177 */ 161 */
178 data = kmalloc(16, GFP_KERNEL);
179 data[0] = 0x00; /* address */ 162 data[0] = 0x00; /* address */
180 data[1] = 0x0c | 0x01; /* reg 0 */ 163 data[1] = 0x0c | 0x01; /* reg 0 */
181 data[2] = 0x01; /* reg 1 */ 164 data[2] = 0x01; /* reg 1 */
@@ -195,12 +178,10 @@ static void sd_start(struct gspca_dev *gspca_dev)
195 data[10] = 0x5d; /* reg 9, I2C device address 178 data[10] = 0x5d; /* reg 9, I2C device address
196 * [for PAS5101 (0x40)] [for MI (0x5d)] */ 179 * [for PAS5101 (0x40)] [for MI (0x5d)] */
197 180
198 err_code = reg_w_buf(gspca_dev, data[0], data, 11); 181 err_code = reg_w(gspca_dev, data[0], 11);
199 kfree(data);
200 if (err_code < 0) 182 if (err_code < 0)
201 return; 183 return;
202 184
203 data = gspca_dev->usb_buf;
204 data[0] = 0x23; /* address */ 185 data[0] = 0x23; /* address */
205 data[1] = 0x09; /* reg 35, append frame header */ 186 data[1] = 0x09; /* reg 35, append frame header */
206 187
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 044a9ec58db5..162beb3feadb 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -410,7 +410,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
410 int len) 410 int len)
411{ 411{
412#ifdef GSPCA_DEBUG 412#ifdef GSPCA_DEBUG
413 if (len > sizeof gspca_dev->usb_buf) { 413 if (len > USB_BUF_SZ) {
414 PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow"); 414 PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow");
415 return; 415 return;
416 } 416 }
@@ -426,26 +426,6 @@ static void reg_w(struct gspca_dev *gspca_dev,
426 500); 426 500);
427} 427}
428 428
429static void reg_w_big(struct gspca_dev *gspca_dev,
430 __u16 value,
431 const __u8 *buffer,
432 int len)
433{
434 __u8 *tmpbuf;
435
436 tmpbuf = kmalloc(len, GFP_KERNEL);
437 memcpy(tmpbuf, buffer, len);
438 usb_control_msg(gspca_dev->dev,
439 usb_sndctrlpipe(gspca_dev->dev, 0),
440 0x08, /* request */
441 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
442 value,
443 0, /* index */
444 tmpbuf, len,
445 500);
446 kfree(tmpbuf);
447}
448
449static int i2c_w(struct gspca_dev *gspca_dev, const __u8 *buffer) 429static int i2c_w(struct gspca_dev *gspca_dev, const __u8 *buffer)
450{ 430{
451 int retry = 60; 431 int retry = 60;
@@ -886,7 +866,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
886 /* reg 0x17 SensorClk enable inv Clk 0x60 */ 866 /* reg 0x17 SensorClk enable inv Clk 0x60 */
887 reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); 867 reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1);
888 /* Set the registers from the template */ 868 /* Set the registers from the template */
889 reg_w_big(gspca_dev, 0x01, sn9c10x, l); 869 reg_w(gspca_dev, 0x01, sn9c10x, l);
890 switch (sd->sensor) { 870 switch (sd->sensor) {
891 case SENSOR_HV7131R: 871 case SENSOR_HV7131R:
892 i2c_w_vector(gspca_dev, hv7131_sensor_init, 872 i2c_w_vector(gspca_dev, hv7131_sensor_init,
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index feb17dbdd7b3..5697959e7245 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -613,10 +613,16 @@ static const __u8 qtable4[] = {
613 0x29, 0x29, 0x29, 0x29 613 0x29, 0x29, 0x29, 0x29
614}; 614};
615 615
616/* read <len> bytes (len < sizeof gspca_dev->usb_buf) to gspca_dev->usb_buf */ 616/* read <len> bytes to gspca_dev->usb_buf */
617static void reg_r(struct gspca_dev *gspca_dev, 617static void reg_r(struct gspca_dev *gspca_dev,
618 __u16 value, int len) 618 __u16 value, int len)
619{ 619{
620#ifdef GSPCA_DEBUG
621 if (len > USB_BUF_SZ) {
622 err("reg_r: buffer overflow");
623 return;
624 }
625#endif
620 usb_control_msg(gspca_dev->dev, 626 usb_control_msg(gspca_dev->dev,
621 usb_rcvctrlpipe(gspca_dev->dev, 0), 627 usb_rcvctrlpipe(gspca_dev->dev, 0),
622 0, 628 0,
@@ -649,29 +655,20 @@ static void reg_w(struct gspca_dev *gspca_dev,
649{ 655{
650 PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", 656 PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..",
651 value, buffer[0], buffer[1]); 657 value, buffer[0], buffer[1]);
652 if (len <= sizeof gspca_dev->usb_buf) { 658#ifdef GSPCA_DEBUG
653 memcpy(gspca_dev->usb_buf, buffer, len); 659 if (len > USB_BUF_SZ) {
654 usb_control_msg(gspca_dev->dev, 660 err("reg_w: buffer overflow");
655 usb_sndctrlpipe(gspca_dev->dev, 0), 661 return;
656 0x08,
657 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
658 value, 0,
659 gspca_dev->usb_buf, len,
660 500);
661 } else {
662 __u8 *tmpbuf;
663
664 tmpbuf = kmalloc(len, GFP_KERNEL);
665 memcpy(tmpbuf, buffer, len);
666 usb_control_msg(gspca_dev->dev,
667 usb_sndctrlpipe(gspca_dev->dev, 0),
668 0x08,
669 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
670 value, 0,
671 tmpbuf, len,
672 500);
673 kfree(tmpbuf);
674 } 662 }
663#endif
664 memcpy(gspca_dev->usb_buf, buffer, len);
665 usb_control_msg(gspca_dev->dev,
666 usb_sndctrlpipe(gspca_dev->dev, 0),
667 0x08,
668 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
669 value, 0,
670 gspca_dev->usb_buf, len,
671 500);
675} 672}
676 673
677/* I2C write 1 byte */ 674/* I2C write 1 byte */
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index bddf73360c25..1cfcc6c49558 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -449,31 +449,47 @@ static const __u8 qtable_spca504_default[2][64] = {
449 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} 449 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
450}; 450};
451 451
452static void reg_r(struct usb_device *dev, 452/* read <len> bytes to gspca_dev->usb_buf */
453 __u16 req, 453static void reg_r(struct gspca_dev *gspca_dev,
454 __u16 index, 454 __u16 req,
455 __u8 *buffer, __u16 length) 455 __u16 index,
456 __u16 len)
456{ 457{
457 usb_control_msg(dev, 458#ifdef GSPCA_DEBUG
458 usb_rcvctrlpipe(dev, 0), 459 if (len > USB_BUF_SZ) {
460 err("reg_r: buffer overflow");
461 return;
462 }
463#endif
464 usb_control_msg(gspca_dev->dev,
465 usb_rcvctrlpipe(gspca_dev->dev, 0),
459 req, 466 req,
460 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 467 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
461 0, /* value */ 468 0, /* value */
462 index, buffer, length, 469 index,
470 len ? gspca_dev->usb_buf : NULL, len,
463 500); 471 500);
464} 472}
465 473
466static void reg_w(struct usb_device *dev, 474/* write <len> bytes from gspca_dev->usb_buf */
467 __u16 req, 475static void reg_w(struct gspca_dev *gspca_dev,
468 __u16 value, 476 __u16 req,
469 __u16 index, 477 __u16 value,
470 __u8 *buffer, __u16 length) 478 __u16 index,
479 __u16 len)
471{ 480{
472 usb_control_msg(dev, 481#ifdef GSPCA_DEBUG
473 usb_sndctrlpipe(dev, 0), 482 if (len > USB_BUF_SZ) {
483 err("reg_w: buffer overflow");
484 return;
485 }
486#endif
487 usb_control_msg(gspca_dev->dev,
488 usb_sndctrlpipe(gspca_dev->dev, 0),
474 req, 489 req,
475 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
476 value, index, buffer, length, 491 value, index,
492 len ? gspca_dev->usb_buf : NULL, len,
477 500); 493 500);
478} 494}
479 495
@@ -634,7 +650,7 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
634 int count = 10; 650 int count = 10;
635 651
636 while (--count > 0) { 652 while (--count > 0) {
637 reg_r(gspca_dev->dev, 0x21, 0, gspca_dev->usb_buf, 1); 653 reg_r(gspca_dev, 0x21, 0, 1);
638 if ((gspca_dev->usb_buf[0] & 0x01) == 0) 654 if ((gspca_dev->usb_buf[0] & 0x01) == 0)
639 break; 655 break;
640 msleep(10); 656 msleep(10);
@@ -644,15 +660,14 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
644 660
645static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) 661static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
646{ 662{
647 struct usb_device *dev = gspca_dev->dev;
648 int count = 50; 663 int count = 50;
649 664
650 while (--count > 0) { 665 while (--count > 0) {
651 reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1); 666 reg_r(gspca_dev, 0x21, 1, 1);
652 if (gspca_dev->usb_buf[0] != 0) { 667 if (gspca_dev->usb_buf[0] != 0) {
653 gspca_dev->usb_buf[0] = 0; 668 gspca_dev->usb_buf[0] = 0;
654 reg_w(dev, 0x21, 0, 1, gspca_dev->usb_buf, 1); 669 reg_w(gspca_dev, 0x21, 0, 1, 1);
655 reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1); 670 reg_r(gspca_dev, 0x21, 1, 1);
656 spca504B_PollingDataReady(gspca_dev); 671 spca504B_PollingDataReady(gspca_dev);
657 break; 672 break;
658 } 673 }
@@ -662,16 +677,14 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
662 677
663static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) 678static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
664{ 679{
665 struct usb_device *dev = gspca_dev->dev;
666 __u8 *data; 680 __u8 *data;
667 681
668 data = kmalloc(64, GFP_KERNEL); 682 data = gspca_dev->usb_buf;
669 reg_r(dev, 0x20, 0, data, 5); 683 reg_r(gspca_dev, 0x20, 0, 5);
670 PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ", 684 PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ",
671 data[0], data[1], data[2], data[3], data[4]); 685 data[0], data[1], data[2], data[3], data[4]);
672 reg_r(dev, 0x23, 0, data, 64); 686 reg_r(gspca_dev, 0x23, 0, 64);
673 reg_r(dev, 0x23, 1, data, 64); 687 reg_r(gspca_dev, 0x23, 1, 64);
674 kfree(data);
675} 688}
676 689
677static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) 690static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
@@ -686,21 +699,21 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
686 Type = 0; 699 Type = 0;
687 switch (sd->bridge) { 700 switch (sd->bridge) {
688 case BRIDGE_SPCA533: 701 case BRIDGE_SPCA533:
689 reg_w(dev, 0x31, 0, 0, NULL, 0); 702 reg_w(gspca_dev, 0x31, 0, 0, 0);
690 spca504B_WaitCmdStatus(gspca_dev); 703 spca504B_WaitCmdStatus(gspca_dev);
691 rc = spca504B_PollingDataReady(gspca_dev); 704 rc = spca504B_PollingDataReady(gspca_dev);
692 spca50x_GetFirmware(gspca_dev); 705 spca50x_GetFirmware(gspca_dev);
693 gspca_dev->usb_buf[0] = 2; /* type */ 706 gspca_dev->usb_buf[0] = 2; /* type */
694 reg_w(dev, 0x24, 0, 8, gspca_dev->usb_buf, 1); 707 reg_w(gspca_dev, 0x24, 0, 8, 1);
695 reg_r(dev, 0x24, 8, gspca_dev->usb_buf, 1); 708 reg_r(gspca_dev, 0x24, 8, 1);
696 709
697 gspca_dev->usb_buf[0] = Size; 710 gspca_dev->usb_buf[0] = Size;
698 reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1); 711 reg_w(gspca_dev, 0x25, 0, 4, 1);
699 reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */ 712 reg_r(gspca_dev, 0x25, 4, 1); /* size */
700 rc = spca504B_PollingDataReady(gspca_dev); 713 rc = spca504B_PollingDataReady(gspca_dev);
701 714
702 /* Init the cam width height with some values get on init ? */ 715 /* Init the cam width height with some values get on init ? */
703 reg_w(dev, 0x31, 0, 4, NULL, 0); 716 reg_w(gspca_dev, 0x31, 0, 4, 0);
704 spca504B_WaitCmdStatus(gspca_dev); 717 spca504B_WaitCmdStatus(gspca_dev);
705 rc = spca504B_PollingDataReady(gspca_dev); 718 rc = spca504B_PollingDataReady(gspca_dev);
706 break; 719 break;
@@ -708,12 +721,12 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
708/* case BRIDGE_SPCA504B: */ 721/* case BRIDGE_SPCA504B: */
709/* case BRIDGE_SPCA536: */ 722/* case BRIDGE_SPCA536: */
710 gspca_dev->usb_buf[0] = Size; 723 gspca_dev->usb_buf[0] = Size;
711 reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1); 724 reg_w(gspca_dev, 0x25, 0, 4, 1);
712 reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */ 725 reg_r(gspca_dev, 0x25, 4, 1); /* size */
713 Type = 6; 726 Type = 6;
714 gspca_dev->usb_buf[0] = Type; 727 gspca_dev->usb_buf[0] = Type;
715 reg_w(dev, 0x27, 0, 0, gspca_dev->usb_buf, 1); 728 reg_w(gspca_dev, 0x27, 0, 0, 1);
716 reg_r(dev, 0x27, 0, gspca_dev->usb_buf, 1); /* type */ 729 reg_r(gspca_dev, 0x27, 0, 1); /* type */
717 rc = spca504B_PollingDataReady(gspca_dev); 730 rc = spca504B_PollingDataReady(gspca_dev);
718 break; 731 break;
719 case BRIDGE_SPCA504: 732 case BRIDGE_SPCA504:
@@ -752,18 +765,15 @@ static void spca504_wait_status(struct gspca_dev *gspca_dev)
752 765
753static void spca504B_setQtable(struct gspca_dev *gspca_dev) 766static void spca504B_setQtable(struct gspca_dev *gspca_dev)
754{ 767{
755 struct usb_device *dev = gspca_dev->dev;
756
757 gspca_dev->usb_buf[0] = 3; 768 gspca_dev->usb_buf[0] = 3;
758 reg_w(dev, 0x26, 0, 0, gspca_dev->usb_buf, 1); 769 reg_w(gspca_dev, 0x26, 0, 0, 1);
759 reg_r(dev, 0x26, 0, gspca_dev->usb_buf, 1); 770 reg_r(gspca_dev, 0x26, 0, 1);
760 spca504B_PollingDataReady(gspca_dev); 771 spca504B_PollingDataReady(gspca_dev);
761} 772}
762 773
763static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) 774static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
764{ 775{
765 struct sd *sd = (struct sd *) gspca_dev; 776 struct sd *sd = (struct sd *) gspca_dev;
766 struct usb_device *dev = gspca_dev->dev;
767 int pollreg = 1; 777 int pollreg = 1;
768 778
769 switch (sd->bridge) { 779 switch (sd->bridge) {
@@ -774,20 +784,20 @@ static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
774 default: 784 default:
775/* case BRIDGE_SPCA533: */ 785/* case BRIDGE_SPCA533: */
776/* case BRIDGE_SPCA504B: */ 786/* case BRIDGE_SPCA504B: */
777 reg_w(dev, 0, 0, 0x21a7, NULL, 0); /* brightness */ 787 reg_w(gspca_dev, 0, 0, 0x21a7, 0); /* brightness */
778 reg_w(dev, 0, 0x20, 0x21a8, NULL, 0); /* contrast */ 788 reg_w(gspca_dev, 0, 0x20, 0x21a8, 0); /* contrast */
779 reg_w(dev, 0, 0, 0x21ad, NULL, 0); /* hue */ 789 reg_w(gspca_dev, 0, 0, 0x21ad, 0); /* hue */
780 reg_w(dev, 0, 1, 0x21ac, NULL, 0); /* sat/hue */ 790 reg_w(gspca_dev, 0, 1, 0x21ac, 0); /* sat/hue */
781 reg_w(dev, 0, 0x20, 0x21ae, NULL, 0); /* saturation */ 791 reg_w(gspca_dev, 0, 0x20, 0x21ae, 0); /* saturation */
782 reg_w(dev, 0, 0, 0x21a3, NULL, 0); /* gamma */ 792 reg_w(gspca_dev, 0, 0, 0x21a3, 0); /* gamma */
783 break; 793 break;
784 case BRIDGE_SPCA536: 794 case BRIDGE_SPCA536:
785 reg_w(dev, 0, 0, 0x20f0, NULL, 0); 795 reg_w(gspca_dev, 0, 0, 0x20f0, 0);
786 reg_w(dev, 0, 0x21, 0x20f1, NULL, 0); 796 reg_w(gspca_dev, 0, 0x21, 0x20f1, 0);
787 reg_w(dev, 0, 0x40, 0x20f5, NULL, 0); 797 reg_w(gspca_dev, 0, 0x40, 0x20f5, 0);
788 reg_w(dev, 0, 1, 0x20f4, NULL, 0); 798 reg_w(gspca_dev, 0, 1, 0x20f4, 0);
789 reg_w(dev, 0, 0x40, 0x20f6, NULL, 0); 799 reg_w(gspca_dev, 0, 0x40, 0x20f6, 0);
790 reg_w(dev, 0, 0, 0x2089, NULL, 0); 800 reg_w(gspca_dev, 0, 0, 0x2089, 0);
791 break; 801 break;
792 } 802 }
793 if (pollreg) 803 if (pollreg)
@@ -799,7 +809,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
799 const struct usb_device_id *id) 809 const struct usb_device_id *id)
800{ 810{
801 struct sd *sd = (struct sd *) gspca_dev; 811 struct sd *sd = (struct sd *) gspca_dev;
802 struct usb_device *dev = gspca_dev->dev;
803 struct cam *cam; 812 struct cam *cam;
804 813
805 cam = &gspca_dev->cam; 814 cam = &gspca_dev->cam;
@@ -811,7 +820,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
811 if (sd->subtype == AiptekMiniPenCam13) { 820 if (sd->subtype == AiptekMiniPenCam13) {
812/* try to get the firmware as some cam answer 2.0.1.2.2 821/* try to get the firmware as some cam answer 2.0.1.2.2
813 * and should be a spca504b then overwrite that setting */ 822 * and should be a spca504b then overwrite that setting */
814 reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1); 823 reg_r(gspca_dev, 0x20, 0, 1);
815 switch (gspca_dev->usb_buf[0]) { 824 switch (gspca_dev->usb_buf[0]) {
816 case 1: 825 case 1:
817 break; /* (right bridge/subtype) */ 826 break; /* (right bridge/subtype) */
@@ -860,12 +869,12 @@ static int sd_init(struct gspca_dev *gspca_dev)
860 869
861 switch (sd->bridge) { 870 switch (sd->bridge) {
862 case BRIDGE_SPCA504B: 871 case BRIDGE_SPCA504B:
863 reg_w(dev, 0x1d, 0, 0, NULL, 0); 872 reg_w(gspca_dev, 0x1d, 0, 0, 0);
864 reg_w(dev, 0, 1, 0x2306, NULL, 0); 873 reg_w(gspca_dev, 0, 1, 0x2306, 0);
865 reg_w(dev, 0, 0, 0x0d04, NULL, 0); 874 reg_w(gspca_dev, 0, 0, 0x0d04, 0);
866 reg_w(dev, 0, 0, 0x2000, NULL, 0); 875 reg_w(gspca_dev, 0, 0, 0x2000, 0);
867 reg_w(dev, 0, 0x13, 0x2301, NULL, 0); 876 reg_w(gspca_dev, 0, 0x13, 0x2301, 0);
868 reg_w(dev, 0, 0, 0x2306, NULL, 0); 877 reg_w(gspca_dev, 0, 0, 0x2306, 0);
869 /* fall thru */ 878 /* fall thru */
870 case BRIDGE_SPCA533: 879 case BRIDGE_SPCA533:
871 rc = spca504B_PollingDataReady(gspca_dev); 880 rc = spca504B_PollingDataReady(gspca_dev);
@@ -873,12 +882,12 @@ static int sd_init(struct gspca_dev *gspca_dev)
873 break; 882 break;
874 case BRIDGE_SPCA536: 883 case BRIDGE_SPCA536:
875 spca50x_GetFirmware(gspca_dev); 884 spca50x_GetFirmware(gspca_dev);
876 reg_r(dev, 0x00, 0x5002, gspca_dev->usb_buf, 1); 885 reg_r(gspca_dev, 0x00, 0x5002, 1);
877 gspca_dev->usb_buf[0] = 0; 886 gspca_dev->usb_buf[0] = 0;
878 reg_w(dev, 0x24, 0, 0, gspca_dev->usb_buf, 1); 887 reg_w(gspca_dev, 0x24, 0, 0, 1);
879 reg_r(dev, 0x24, 0, gspca_dev->usb_buf, 1); 888 reg_r(gspca_dev, 0x24, 0, 1);
880 rc = spca504B_PollingDataReady(gspca_dev); 889 rc = spca504B_PollingDataReady(gspca_dev);
881 reg_w(dev, 0x34, 0, 0, NULL, 0); 890 reg_w(gspca_dev, 0x34, 0, 0, 0);
882 spca504B_WaitCmdStatus(gspca_dev); 891 spca504B_WaitCmdStatus(gspca_dev);
883 break; 892 break;
884 case BRIDGE_SPCA504C: /* pccam600 */ 893 case BRIDGE_SPCA504C: /* pccam600 */
@@ -971,12 +980,12 @@ static void sd_start(struct gspca_dev *gspca_dev)
971/* case BRIDGE_SPCA536: */ 980/* case BRIDGE_SPCA536: */
972 if (sd->subtype == MegapixV4 || 981 if (sd->subtype == MegapixV4 ||
973 sd->subtype == LogitechClickSmart820) { 982 sd->subtype == LogitechClickSmart820) {
974 reg_w(dev, 0xf0, 0, 0, NULL, 0); 983 reg_w(gspca_dev, 0xf0, 0, 0, 0);
975 spca504B_WaitCmdStatus(gspca_dev); 984 spca504B_WaitCmdStatus(gspca_dev);
976 reg_r(dev, 0xf0, 4, NULL, 0); 985 reg_r(gspca_dev, 0xf0, 4, 0);
977 spca504B_WaitCmdStatus(gspca_dev); 986 spca504B_WaitCmdStatus(gspca_dev);
978 } else { 987 } else {
979 reg_w(dev, 0x31, 0, 4, NULL, 0); 988 reg_w(gspca_dev, 0x31, 0, 4, 0);
980 spca504B_WaitCmdStatus(gspca_dev); 989 spca504B_WaitCmdStatus(gspca_dev);
981 rc = spca504B_PollingDataReady(gspca_dev); 990 rc = spca504B_PollingDataReady(gspca_dev);
982 } 991 }
@@ -1045,7 +1054,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1045/* case BRIDGE_SPCA533: */ 1054/* case BRIDGE_SPCA533: */
1046/* case BRIDGE_SPCA536: */ 1055/* case BRIDGE_SPCA536: */
1047/* case BRIDGE_SPCA504B: */ 1056/* case BRIDGE_SPCA504B: */
1048 reg_w(dev, 0x31, 0, 0, NULL, 0); 1057 reg_w(gspca_dev, 0x31, 0, 0, 0);
1049 spca504B_WaitCmdStatus(gspca_dev); 1058 spca504B_WaitCmdStatus(gspca_dev);
1050 spca504B_PollingDataReady(gspca_dev); 1059 spca504B_PollingDataReady(gspca_dev);
1051 break; 1060 break;
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 81b175e15ca7..f034c748fc7e 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -391,7 +391,7 @@ static void reg_w(struct gspca_dev *gspca_dev,
391 NULL, 0, 500); 391 NULL, 0, 500);
392 return; 392 return;
393 } 393 }
394 if (len <= sizeof gspca_dev->usb_buf) { 394 if (len <= USB_BUF_SZ) {
395 memcpy(gspca_dev->usb_buf, buffer, len); 395 memcpy(gspca_dev->usb_buf, buffer, len);
396 usb_control_msg(gspca_dev->dev, 396 usb_control_msg(gspca_dev->dev,
397 usb_sndctrlpipe(gspca_dev->dev, 0), 397 usb_sndctrlpipe(gspca_dev->dev, 0),