aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/media/ov511.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/media/ov511.c')
-rw-r--r--drivers/usb/media/ov511.c97
1 files changed, 47 insertions, 50 deletions
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index 51e9cc06f7e3..da44579d6f29 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -365,14 +365,14 @@ reg_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value)
365 365
366 PDEBUG(5, "0x%02X:0x%02X", reg, value); 366 PDEBUG(5, "0x%02X:0x%02X", reg, value);
367 367
368 down(&ov->cbuf_lock); 368 mutex_lock(&ov->cbuf_lock);
369 ov->cbuf[0] = value; 369 ov->cbuf[0] = value;
370 rc = usb_control_msg(ov->dev, 370 rc = usb_control_msg(ov->dev,
371 usb_sndctrlpipe(ov->dev, 0), 371 usb_sndctrlpipe(ov->dev, 0),
372 (ov->bclass == BCL_OV518)?1:2 /* REG_IO */, 372 (ov->bclass == BCL_OV518)?1:2 /* REG_IO */,
373 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 373 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
374 0, (__u16)reg, &ov->cbuf[0], 1, 1000); 374 0, (__u16)reg, &ov->cbuf[0], 1, 1000);
375 up(&ov->cbuf_lock); 375 mutex_unlock(&ov->cbuf_lock);
376 376
377 if (rc < 0) 377 if (rc < 0)
378 err("reg write: error %d: %s", rc, symbolic(urb_errlist, rc)); 378 err("reg write: error %d: %s", rc, symbolic(urb_errlist, rc));
@@ -387,7 +387,7 @@ reg_r(struct usb_ov511 *ov, unsigned char reg)
387{ 387{
388 int rc; 388 int rc;
389 389
390 down(&ov->cbuf_lock); 390 mutex_lock(&ov->cbuf_lock);
391 rc = usb_control_msg(ov->dev, 391 rc = usb_control_msg(ov->dev,
392 usb_rcvctrlpipe(ov->dev, 0), 392 usb_rcvctrlpipe(ov->dev, 0),
393 (ov->bclass == BCL_OV518)?1:3 /* REG_IO */, 393 (ov->bclass == BCL_OV518)?1:3 /* REG_IO */,
@@ -401,7 +401,7 @@ reg_r(struct usb_ov511 *ov, unsigned char reg)
401 PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]); 401 PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]);
402 } 402 }
403 403
404 up(&ov->cbuf_lock); 404 mutex_unlock(&ov->cbuf_lock);
405 405
406 return rc; 406 return rc;
407} 407}
@@ -444,7 +444,7 @@ ov518_reg_w32(struct usb_ov511 *ov, unsigned char reg, u32 val, int n)
444 444
445 PDEBUG(5, "0x%02X:%7d, n=%d", reg, val, n); 445 PDEBUG(5, "0x%02X:%7d, n=%d", reg, val, n);
446 446
447 down(&ov->cbuf_lock); 447 mutex_lock(&ov->cbuf_lock);
448 448
449 *((__le32 *)ov->cbuf) = __cpu_to_le32(val); 449 *((__le32 *)ov->cbuf) = __cpu_to_le32(val);
450 450
@@ -453,7 +453,7 @@ ov518_reg_w32(struct usb_ov511 *ov, unsigned char reg, u32 val, int n)
453 1 /* REG_IO */, 453 1 /* REG_IO */,
454 USB_TYPE_VENDOR | USB_RECIP_DEVICE, 454 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
455 0, (__u16)reg, ov->cbuf, n, 1000); 455 0, (__u16)reg, ov->cbuf, n, 1000);
456 up(&ov->cbuf_lock); 456 mutex_unlock(&ov->cbuf_lock);
457 457
458 if (rc < 0) 458 if (rc < 0)
459 err("reg write multiple: error %d: %s", rc, 459 err("reg write multiple: error %d: %s", rc,
@@ -768,14 +768,14 @@ i2c_r(struct usb_ov511 *ov, unsigned char reg)
768{ 768{
769 int rc; 769 int rc;
770 770
771 down(&ov->i2c_lock); 771 mutex_lock(&ov->i2c_lock);
772 772
773 if (ov->bclass == BCL_OV518) 773 if (ov->bclass == BCL_OV518)
774 rc = ov518_i2c_read_internal(ov, reg); 774 rc = ov518_i2c_read_internal(ov, reg);
775 else 775 else
776 rc = ov511_i2c_read_internal(ov, reg); 776 rc = ov511_i2c_read_internal(ov, reg);
777 777
778 up(&ov->i2c_lock); 778 mutex_unlock(&ov->i2c_lock);
779 779
780 return rc; 780 return rc;
781} 781}
@@ -785,14 +785,14 @@ i2c_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value)
785{ 785{
786 int rc; 786 int rc;
787 787
788 down(&ov->i2c_lock); 788 mutex_lock(&ov->i2c_lock);
789 789
790 if (ov->bclass == BCL_OV518) 790 if (ov->bclass == BCL_OV518)
791 rc = ov518_i2c_write_internal(ov, reg, value); 791 rc = ov518_i2c_write_internal(ov, reg, value);
792 else 792 else
793 rc = ov511_i2c_write_internal(ov, reg, value); 793 rc = ov511_i2c_write_internal(ov, reg, value);
794 794
795 up(&ov->i2c_lock); 795 mutex_unlock(&ov->i2c_lock);
796 796
797 return rc; 797 return rc;
798} 798}
@@ -842,9 +842,9 @@ i2c_w_mask(struct usb_ov511 *ov,
842{ 842{
843 int rc; 843 int rc;
844 844
845 down(&ov->i2c_lock); 845 mutex_lock(&ov->i2c_lock);
846 rc = ov51x_i2c_write_mask_internal(ov, reg, value, mask); 846 rc = ov51x_i2c_write_mask_internal(ov, reg, value, mask);
847 up(&ov->i2c_lock); 847 mutex_unlock(&ov->i2c_lock);
848 848
849 return rc; 849 return rc;
850} 850}
@@ -880,7 +880,7 @@ i2c_w_slave(struct usb_ov511 *ov,
880{ 880{
881 int rc = 0; 881 int rc = 0;
882 882
883 down(&ov->i2c_lock); 883 mutex_lock(&ov->i2c_lock);
884 884
885 /* Set new slave IDs */ 885 /* Set new slave IDs */
886 rc = i2c_set_slave_internal(ov, slave); 886 rc = i2c_set_slave_internal(ov, slave);
@@ -894,7 +894,7 @@ out:
894 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) 894 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0)
895 err("Couldn't restore primary I2C slave"); 895 err("Couldn't restore primary I2C slave");
896 896
897 up(&ov->i2c_lock); 897 mutex_unlock(&ov->i2c_lock);
898 return rc; 898 return rc;
899} 899}
900 900
@@ -906,7 +906,7 @@ i2c_r_slave(struct usb_ov511 *ov,
906{ 906{
907 int rc; 907 int rc;
908 908
909 down(&ov->i2c_lock); 909 mutex_lock(&ov->i2c_lock);
910 910
911 /* Set new slave IDs */ 911 /* Set new slave IDs */
912 rc = i2c_set_slave_internal(ov, slave); 912 rc = i2c_set_slave_internal(ov, slave);
@@ -923,7 +923,7 @@ out:
923 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) 923 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0)
924 err("Couldn't restore primary I2C slave"); 924 err("Couldn't restore primary I2C slave");
925 925
926 up(&ov->i2c_lock); 926 mutex_unlock(&ov->i2c_lock);
927 return rc; 927 return rc;
928} 928}
929 929
@@ -933,7 +933,7 @@ ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid)
933{ 933{
934 int rc; 934 int rc;
935 935
936 down(&ov->i2c_lock); 936 mutex_lock(&ov->i2c_lock);
937 937
938 rc = i2c_set_slave_internal(ov, sid); 938 rc = i2c_set_slave_internal(ov, sid);
939 if (rc < 0) 939 if (rc < 0)
@@ -942,7 +942,7 @@ ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid)
942 // FIXME: Is this actually necessary? 942 // FIXME: Is this actually necessary?
943 rc = ov51x_reset(ov, OV511_RESET_NOREGS); 943 rc = ov51x_reset(ov, OV511_RESET_NOREGS);
944out: 944out:
945 up(&ov->i2c_lock); 945 mutex_unlock(&ov->i2c_lock);
946 return rc; 946 return rc;
947} 947}
948 948
@@ -3832,7 +3832,7 @@ ov51x_alloc(struct usb_ov511 *ov)
3832 const int raw_bufsize = OV511_NUMFRAMES * MAX_RAW_DATA_SIZE(w, h); 3832 const int raw_bufsize = OV511_NUMFRAMES * MAX_RAW_DATA_SIZE(w, h);
3833 3833
3834 PDEBUG(4, "entered"); 3834 PDEBUG(4, "entered");
3835 down(&ov->buf_lock); 3835 mutex_lock(&ov->buf_lock);
3836 3836
3837 if (ov->buf_state == BUF_ALLOCATED) 3837 if (ov->buf_state == BUF_ALLOCATED)
3838 goto out; 3838 goto out;
@@ -3879,12 +3879,12 @@ ov51x_alloc(struct usb_ov511 *ov)
3879 3879
3880 ov->buf_state = BUF_ALLOCATED; 3880 ov->buf_state = BUF_ALLOCATED;
3881out: 3881out:
3882 up(&ov->buf_lock); 3882 mutex_unlock(&ov->buf_lock);
3883 PDEBUG(4, "leaving"); 3883 PDEBUG(4, "leaving");
3884 return 0; 3884 return 0;
3885error: 3885error:
3886 ov51x_do_dealloc(ov); 3886 ov51x_do_dealloc(ov);
3887 up(&ov->buf_lock); 3887 mutex_unlock(&ov->buf_lock);
3888 PDEBUG(4, "errored"); 3888 PDEBUG(4, "errored");
3889 return -ENOMEM; 3889 return -ENOMEM;
3890} 3890}
@@ -3893,9 +3893,9 @@ static void
3893ov51x_dealloc(struct usb_ov511 *ov) 3893ov51x_dealloc(struct usb_ov511 *ov)
3894{ 3894{
3895 PDEBUG(4, "entered"); 3895 PDEBUG(4, "entered");
3896 down(&ov->buf_lock); 3896 mutex_lock(&ov->buf_lock);
3897 ov51x_do_dealloc(ov); 3897 ov51x_do_dealloc(ov);
3898 up(&ov->buf_lock); 3898 mutex_unlock(&ov->buf_lock);
3899 PDEBUG(4, "leaving"); 3899 PDEBUG(4, "leaving");
3900} 3900}
3901 3901
@@ -3914,7 +3914,7 @@ ov51x_v4l1_open(struct inode *inode, struct file *file)
3914 3914
3915 PDEBUG(4, "opening"); 3915 PDEBUG(4, "opening");
3916 3916
3917 down(&ov->lock); 3917 mutex_lock(&ov->lock);
3918 3918
3919 err = -EBUSY; 3919 err = -EBUSY;
3920 if (ov->user) 3920 if (ov->user)
@@ -3958,7 +3958,7 @@ ov51x_v4l1_open(struct inode *inode, struct file *file)
3958 ov51x_led_control(ov, 1); 3958 ov51x_led_control(ov, 1);
3959 3959
3960out: 3960out:
3961 up(&ov->lock); 3961 mutex_unlock(&ov->lock);
3962 return err; 3962 return err;
3963} 3963}
3964 3964
@@ -3970,7 +3970,7 @@ ov51x_v4l1_close(struct inode *inode, struct file *file)
3970 3970
3971 PDEBUG(4, "ov511_close"); 3971 PDEBUG(4, "ov511_close");
3972 3972
3973 down(&ov->lock); 3973 mutex_lock(&ov->lock);
3974 3974
3975 ov->user--; 3975 ov->user--;
3976 ov51x_stop_isoc(ov); 3976 ov51x_stop_isoc(ov);
@@ -3981,15 +3981,15 @@ ov51x_v4l1_close(struct inode *inode, struct file *file)
3981 if (ov->dev) 3981 if (ov->dev)
3982 ov51x_dealloc(ov); 3982 ov51x_dealloc(ov);
3983 3983
3984 up(&ov->lock); 3984 mutex_unlock(&ov->lock);
3985 3985
3986 /* Device unplugged while open. Only a minimum of unregistration is done 3986 /* Device unplugged while open. Only a minimum of unregistration is done
3987 * here; the disconnect callback already did the rest. */ 3987 * here; the disconnect callback already did the rest. */
3988 if (!ov->dev) { 3988 if (!ov->dev) {
3989 down(&ov->cbuf_lock); 3989 mutex_lock(&ov->cbuf_lock);
3990 kfree(ov->cbuf); 3990 kfree(ov->cbuf);
3991 ov->cbuf = NULL; 3991 ov->cbuf = NULL;
3992 up(&ov->cbuf_lock); 3992 mutex_unlock(&ov->cbuf_lock);
3993 3993
3994 ov51x_dealloc(ov); 3994 ov51x_dealloc(ov);
3995 kfree(ov); 3995 kfree(ov);
@@ -4449,12 +4449,12 @@ ov51x_v4l1_ioctl(struct inode *inode, struct file *file,
4449 struct usb_ov511 *ov = video_get_drvdata(vdev); 4449 struct usb_ov511 *ov = video_get_drvdata(vdev);
4450 int rc; 4450 int rc;
4451 4451
4452 if (down_interruptible(&ov->lock)) 4452 if (mutex_lock_interruptible(&ov->lock))
4453 return -EINTR; 4453 return -EINTR;
4454 4454
4455 rc = video_usercopy(inode, file, cmd, arg, ov51x_v4l1_ioctl_internal); 4455 rc = video_usercopy(inode, file, cmd, arg, ov51x_v4l1_ioctl_internal);
4456 4456
4457 up(&ov->lock); 4457 mutex_unlock(&ov->lock);
4458 return rc; 4458 return rc;
4459} 4459}
4460 4460
@@ -4468,7 +4468,7 @@ ov51x_v4l1_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos)
4468 int i, rc = 0, frmx = -1; 4468 int i, rc = 0, frmx = -1;
4469 struct ov511_frame *frame; 4469 struct ov511_frame *frame;
4470 4470
4471 if (down_interruptible(&ov->lock)) 4471 if (mutex_lock_interruptible(&ov->lock))
4472 return -EINTR; 4472 return -EINTR;
4473 4473
4474 PDEBUG(4, "%ld bytes, noblock=%d", count, noblock); 4474 PDEBUG(4, "%ld bytes, noblock=%d", count, noblock);
@@ -4604,11 +4604,11 @@ restart:
4604 4604
4605 PDEBUG(4, "read finished, returning %ld (sweet)", count); 4605 PDEBUG(4, "read finished, returning %ld (sweet)", count);
4606 4606
4607 up(&ov->lock); 4607 mutex_unlock(&ov->lock);
4608 return count; 4608 return count;
4609 4609
4610error: 4610error:
4611 up(&ov->lock); 4611 mutex_unlock(&ov->lock);
4612 return rc; 4612 return rc;
4613} 4613}
4614 4614
@@ -4631,14 +4631,14 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))) 4631 + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))))
4632 return -EINVAL; 4632 return -EINVAL;
4633 4633
4634 if (down_interruptible(&ov->lock)) 4634 if (mutex_lock_interruptible(&ov->lock))
4635 return -EINTR; 4635 return -EINTR;
4636 4636
4637 pos = (unsigned long)ov->fbuf; 4637 pos = (unsigned long)ov->fbuf;
4638 while (size > 0) { 4638 while (size > 0) {
4639 page = vmalloc_to_pfn((void *)pos); 4639 page = vmalloc_to_pfn((void *)pos);
4640 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) { 4640 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
4641 up(&ov->lock); 4641 mutex_unlock(&ov->lock);
4642 return -EAGAIN; 4642 return -EAGAIN;
4643 } 4643 }
4644 start += PAGE_SIZE; 4644 start += PAGE_SIZE;
@@ -4649,7 +4649,7 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
4649 size = 0; 4649 size = 0;
4650 } 4650 }
4651 4651
4652 up(&ov->lock); 4652 mutex_unlock(&ov->lock);
4653 return 0; 4653 return 0;
4654} 4654}
4655 4655
@@ -5639,7 +5639,7 @@ static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
5639static ssize_t show_exposure(struct class_device *cd, char *buf) 5639static ssize_t show_exposure(struct class_device *cd, char *buf)
5640{ 5640{
5641 struct usb_ov511 *ov = cd_to_ov(cd); 5641 struct usb_ov511 *ov = cd_to_ov(cd);
5642 unsigned char exp; 5642 unsigned char exp = 0;
5643 5643
5644 if (!ov->dev) 5644 if (!ov->dev)
5645 return -ENODEV; 5645 return -ENODEV;
@@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5686 if (idesc->bInterfaceSubClass != 0x00) 5686 if (idesc->bInterfaceSubClass != 0x00)
5687 return -ENODEV; 5687 return -ENODEV;
5688 5688
5689 if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) { 5689 if ((ov = kzalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
5690 err("couldn't kmalloc ov struct"); 5690 err("couldn't kmalloc ov struct");
5691 goto error_out; 5691 goto error_out;
5692 } 5692 }
5693 5693
5694 memset(ov, 0, sizeof(*ov));
5695
5696 ov->dev = dev; 5694 ov->dev = dev;
5697 ov->iface = idesc->bInterfaceNumber; 5695 ov->iface = idesc->bInterfaceNumber;
5698 ov->led_policy = led; 5696 ov->led_policy = led;
@@ -5738,11 +5736,10 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5738 5736
5739 init_waitqueue_head(&ov->wq); 5737 init_waitqueue_head(&ov->wq);
5740 5738
5741 init_MUTEX(&ov->lock); /* to 1 == available */ 5739 mutex_init(&ov->lock); /* to 1 == available */
5742 init_MUTEX(&ov->buf_lock); 5740 mutex_init(&ov->buf_lock);
5743 init_MUTEX(&ov->param_lock); 5741 mutex_init(&ov->i2c_lock);
5744 init_MUTEX(&ov->i2c_lock); 5742 mutex_init(&ov->cbuf_lock);
5745 init_MUTEX(&ov->cbuf_lock);
5746 5743
5747 ov->buf_state = BUF_NOT_ALLOCATED; 5744 ov->buf_state = BUF_NOT_ALLOCATED;
5748 5745
@@ -5833,10 +5830,10 @@ error:
5833 } 5830 }
5834 5831
5835 if (ov->cbuf) { 5832 if (ov->cbuf) {
5836 down(&ov->cbuf_lock); 5833 mutex_lock(&ov->cbuf_lock);
5837 kfree(ov->cbuf); 5834 kfree(ov->cbuf);
5838 ov->cbuf = NULL; 5835 ov->cbuf = NULL;
5839 up(&ov->cbuf_lock); 5836 mutex_unlock(&ov->cbuf_lock);
5840 } 5837 }
5841 5838
5842 kfree(ov); 5839 kfree(ov);
@@ -5881,10 +5878,10 @@ ov51x_disconnect(struct usb_interface *intf)
5881 5878
5882 /* Free the memory */ 5879 /* Free the memory */
5883 if (ov && !ov->user) { 5880 if (ov && !ov->user) {
5884 down(&ov->cbuf_lock); 5881 mutex_lock(&ov->cbuf_lock);
5885 kfree(ov->cbuf); 5882 kfree(ov->cbuf);
5886 ov->cbuf = NULL; 5883 ov->cbuf = NULL;
5887 up(&ov->cbuf_lock); 5884 mutex_unlock(&ov->cbuf_lock);
5888 5885
5889 ov51x_dealloc(ov); 5886 ov51x_dealloc(ov);
5890 kfree(ov); 5887 kfree(ov);