diff options
Diffstat (limited to 'drivers/usb/media/usbvideo.c')
-rw-r--r-- | drivers/usb/media/usbvideo.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 63a72e550a1b..0b51fae720a9 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c | |||
@@ -690,14 +690,13 @@ int usbvideo_register( | |||
690 | } | 690 | } |
691 | 691 | ||
692 | base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); | 692 | base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); |
693 | cams = (struct usbvideo *) kmalloc(base_size, GFP_KERNEL); | 693 | cams = (struct usbvideo *) kzalloc(base_size, GFP_KERNEL); |
694 | if (cams == NULL) { | 694 | if (cams == NULL) { |
695 | err("Failed to allocate %d. bytes for usbvideo struct", base_size); | 695 | err("Failed to allocate %d. bytes for usbvideo struct", base_size); |
696 | return -ENOMEM; | 696 | return -ENOMEM; |
697 | } | 697 | } |
698 | dbg("%s: Allocated $%p (%d. bytes) for %d. cameras", | 698 | dbg("%s: Allocated $%p (%d. bytes) for %d. cameras", |
699 | __FUNCTION__, cams, base_size, num_cams); | 699 | __FUNCTION__, cams, base_size, num_cams); |
700 | memset(cams, 0, base_size); | ||
701 | 700 | ||
702 | /* Copy callbacks, apply defaults for those that are not set */ | 701 | /* Copy callbacks, apply defaults for those that are not set */ |
703 | memmove(&cams->cb, cbTbl, sizeof(cams->cb)); | 702 | memmove(&cams->cb, cbTbl, sizeof(cams->cb)); |
@@ -715,7 +714,7 @@ int usbvideo_register( | |||
715 | cams->md_module = md; | 714 | cams->md_module = md; |
716 | if (cams->md_module == NULL) | 715 | if (cams->md_module == NULL) |
717 | warn("%s: module == NULL!", __FUNCTION__); | 716 | warn("%s: module == NULL!", __FUNCTION__); |
718 | init_MUTEX(&cams->lock); /* to 1 == available */ | 717 | mutex_init(&cams->lock); /* to 1 == available */ |
719 | 718 | ||
720 | for (i = 0; i < num_cams; i++) { | 719 | for (i = 0; i < num_cams; i++) { |
721 | struct uvd *up = &cams->cam[i]; | 720 | struct uvd *up = &cams->cam[i]; |
@@ -863,7 +862,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
863 | if (uvd->debug > 0) | 862 | if (uvd->debug > 0) |
864 | info("%s(%p.)", __FUNCTION__, intf); | 863 | info("%s(%p.)", __FUNCTION__, intf); |
865 | 864 | ||
866 | down(&uvd->lock); | 865 | mutex_lock(&uvd->lock); |
867 | uvd->remove_pending = 1; /* Now all ISO data will be ignored */ | 866 | uvd->remove_pending = 1; /* Now all ISO data will be ignored */ |
868 | 867 | ||
869 | /* At this time we ask to cancel outstanding URBs */ | 868 | /* At this time we ask to cancel outstanding URBs */ |
@@ -883,7 +882,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
883 | info("%s: In use, disconnect pending.", __FUNCTION__); | 882 | info("%s: In use, disconnect pending.", __FUNCTION__); |
884 | else | 883 | else |
885 | usbvideo_CameraRelease(uvd); | 884 | usbvideo_CameraRelease(uvd); |
886 | up(&uvd->lock); | 885 | mutex_unlock(&uvd->lock); |
887 | info("USB camera disconnected."); | 886 | info("USB camera disconnected."); |
888 | 887 | ||
889 | usbvideo_ClientDecModCount(uvd); | 888 | usbvideo_ClientDecModCount(uvd); |
@@ -930,19 +929,19 @@ static int usbvideo_find_struct(struct usbvideo *cams) | |||
930 | err("No usbvideo handle?"); | 929 | err("No usbvideo handle?"); |
931 | return -1; | 930 | return -1; |
932 | } | 931 | } |
933 | down(&cams->lock); | 932 | mutex_lock(&cams->lock); |
934 | for (u = 0; u < cams->num_cameras; u++) { | 933 | for (u = 0; u < cams->num_cameras; u++) { |
935 | struct uvd *uvd = &cams->cam[u]; | 934 | struct uvd *uvd = &cams->cam[u]; |
936 | if (!uvd->uvd_used) /* This one is free */ | 935 | if (!uvd->uvd_used) /* This one is free */ |
937 | { | 936 | { |
938 | uvd->uvd_used = 1; /* In use now */ | 937 | uvd->uvd_used = 1; /* In use now */ |
939 | init_MUTEX(&uvd->lock); /* to 1 == available */ | 938 | mutex_init(&uvd->lock); /* to 1 == available */ |
940 | uvd->dev = NULL; | 939 | uvd->dev = NULL; |
941 | rv = u; | 940 | rv = u; |
942 | break; | 941 | break; |
943 | } | 942 | } |
944 | } | 943 | } |
945 | up(&cams->lock); | 944 | mutex_unlock(&cams->lock); |
946 | return rv; | 945 | return rv; |
947 | } | 946 | } |
948 | 947 | ||
@@ -984,7 +983,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) | |||
984 | /* Not relying upon caller we increase module counter ourselves */ | 983 | /* Not relying upon caller we increase module counter ourselves */ |
985 | usbvideo_ClientIncModCount(uvd); | 984 | usbvideo_ClientIncModCount(uvd); |
986 | 985 | ||
987 | down(&uvd->lock); | 986 | mutex_lock(&uvd->lock); |
988 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | 987 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { |
989 | uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); | 988 | uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); |
990 | if (uvd->sbuf[i].urb == NULL) { | 989 | if (uvd->sbuf[i].urb == NULL) { |
@@ -1007,7 +1006,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) | |||
1007 | * return control to the client's probe function right now. | 1006 | * return control to the client's probe function right now. |
1008 | */ | 1007 | */ |
1009 | allocate_done: | 1008 | allocate_done: |
1010 | up (&uvd->lock); | 1009 | mutex_unlock(&uvd->lock); |
1011 | usbvideo_ClientDecModCount(uvd); | 1010 | usbvideo_ClientDecModCount(uvd); |
1012 | return uvd; | 1011 | return uvd; |
1013 | } | 1012 | } |
@@ -1121,7 +1120,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
1121 | info("%s($%p)", __FUNCTION__, dev); | 1120 | info("%s($%p)", __FUNCTION__, dev); |
1122 | 1121 | ||
1123 | usbvideo_ClientIncModCount(uvd); | 1122 | usbvideo_ClientIncModCount(uvd); |
1124 | down(&uvd->lock); | 1123 | mutex_lock(&uvd->lock); |
1125 | 1124 | ||
1126 | if (uvd->user) { | 1125 | if (uvd->user) { |
1127 | err("%s: Someone tried to open an already opened device!", __FUNCTION__); | 1126 | err("%s: Someone tried to open an already opened device!", __FUNCTION__); |
@@ -1202,7 +1201,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
1202 | } | 1201 | } |
1203 | } | 1202 | } |
1204 | } | 1203 | } |
1205 | up(&uvd->lock); | 1204 | mutex_unlock(&uvd->lock); |
1206 | if (errCode != 0) | 1205 | if (errCode != 0) |
1207 | usbvideo_ClientDecModCount(uvd); | 1206 | usbvideo_ClientDecModCount(uvd); |
1208 | if (uvd->debug > 0) | 1207 | if (uvd->debug > 0) |
@@ -1231,7 +1230,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) | |||
1231 | if (uvd->debug > 1) | 1230 | if (uvd->debug > 1) |
1232 | info("%s($%p)", __FUNCTION__, dev); | 1231 | info("%s($%p)", __FUNCTION__, dev); |
1233 | 1232 | ||
1234 | down(&uvd->lock); | 1233 | mutex_lock(&uvd->lock); |
1235 | GET_CALLBACK(uvd, stopDataPump)(uvd); | 1234 | GET_CALLBACK(uvd, stopDataPump)(uvd); |
1236 | usbvideo_rvfree(uvd->fbuf, uvd->fbuf_size); | 1235 | usbvideo_rvfree(uvd->fbuf, uvd->fbuf_size); |
1237 | uvd->fbuf = NULL; | 1236 | uvd->fbuf = NULL; |
@@ -1252,7 +1251,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) | |||
1252 | info("usbvideo_v4l_close: Final disconnect."); | 1251 | info("usbvideo_v4l_close: Final disconnect."); |
1253 | usbvideo_CameraRelease(uvd); | 1252 | usbvideo_CameraRelease(uvd); |
1254 | } | 1253 | } |
1255 | up(&uvd->lock); | 1254 | mutex_unlock(&uvd->lock); |
1256 | usbvideo_ClientDecModCount(uvd); | 1255 | usbvideo_ClientDecModCount(uvd); |
1257 | 1256 | ||
1258 | if (uvd->debug > 1) | 1257 | if (uvd->debug > 1) |
@@ -1512,7 +1511,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
1512 | if (uvd->debug >= 1) | 1511 | if (uvd->debug >= 1) |
1513 | info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock); | 1512 | info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock); |
1514 | 1513 | ||
1515 | down(&uvd->lock); | 1514 | mutex_lock(&uvd->lock); |
1516 | 1515 | ||
1517 | /* See if a frame is completed, then use it. */ | 1516 | /* See if a frame is completed, then use it. */ |
1518 | for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { | 1517 | for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { |
@@ -1644,7 +1643,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
1644 | } | 1643 | } |
1645 | } | 1644 | } |
1646 | read_done: | 1645 | read_done: |
1647 | up(&uvd->lock); | 1646 | mutex_unlock(&uvd->lock); |
1648 | return count; | 1647 | return count; |
1649 | } | 1648 | } |
1650 | 1649 | ||