diff options
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 43 |
1 files changed, 20 insertions, 23 deletions
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 */ |
617 | static void reg_r(struct gspca_dev *gspca_dev, | 617 | static 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 */ |