diff options
Diffstat (limited to 'drivers/media/video/pwc/pwc-if.c')
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index bd1519a4ecb4..780af5f81642 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -151,8 +151,6 @@ static int pwc_video_close(struct file *file); | |||
151 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | 151 | static ssize_t pwc_video_read(struct file *file, char __user *buf, |
152 | size_t count, loff_t *ppos); | 152 | size_t count, loff_t *ppos); |
153 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); | 153 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); |
154 | static long pwc_video_ioctl(struct file *file, | ||
155 | unsigned int ioctlnr, unsigned long arg); | ||
156 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); | 154 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); |
157 | 155 | ||
158 | static const struct v4l2_file_operations pwc_fops = { | 156 | static const struct v4l2_file_operations pwc_fops = { |
@@ -162,7 +160,7 @@ static const struct v4l2_file_operations pwc_fops = { | |||
162 | .read = pwc_video_read, | 160 | .read = pwc_video_read, |
163 | .poll = pwc_video_poll, | 161 | .poll = pwc_video_poll, |
164 | .mmap = pwc_video_mmap, | 162 | .mmap = pwc_video_mmap, |
165 | .unlocked_ioctl = pwc_video_ioctl, | 163 | .unlocked_ioctl = video_ioctl2, |
166 | }; | 164 | }; |
167 | static struct video_device pwc_template = { | 165 | static struct video_device pwc_template = { |
168 | .name = "Philips Webcam", /* Filled in later */ | 166 | .name = "Philips Webcam", /* Filled in later */ |
@@ -1098,7 +1096,6 @@ static int pwc_video_open(struct file *file) | |||
1098 | return -EBUSY; | 1096 | return -EBUSY; |
1099 | } | 1097 | } |
1100 | 1098 | ||
1101 | mutex_lock(&pdev->modlock); | ||
1102 | pwc_construct(pdev); /* set min/max sizes correct */ | 1099 | pwc_construct(pdev); /* set min/max sizes correct */ |
1103 | if (!pdev->usb_init) { | 1100 | if (!pdev->usb_init) { |
1104 | PWC_DEBUG_OPEN("Doing first time initialization.\n"); | 1101 | PWC_DEBUG_OPEN("Doing first time initialization.\n"); |
@@ -1130,7 +1127,6 @@ static int pwc_video_open(struct file *file) | |||
1130 | if (i < 0) { | 1127 | if (i < 0) { |
1131 | PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); | 1128 | PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); |
1132 | pwc_free_buffers(pdev); | 1129 | pwc_free_buffers(pdev); |
1133 | mutex_unlock(&pdev->modlock); | ||
1134 | return i; | 1130 | return i; |
1135 | } | 1131 | } |
1136 | 1132 | ||
@@ -1171,7 +1167,6 @@ static int pwc_video_open(struct file *file) | |||
1171 | if (i) { | 1167 | if (i) { |
1172 | PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); | 1168 | PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); |
1173 | pwc_free_buffers(pdev); | 1169 | pwc_free_buffers(pdev); |
1174 | mutex_unlock(&pdev->modlock); | ||
1175 | return i; | 1170 | return i; |
1176 | } | 1171 | } |
1177 | 1172 | ||
@@ -1181,7 +1176,6 @@ static int pwc_video_open(struct file *file) | |||
1181 | 1176 | ||
1182 | pdev->vopen++; | 1177 | pdev->vopen++; |
1183 | file->private_data = vdev; | 1178 | file->private_data = vdev; |
1184 | mutex_unlock(&pdev->modlock); | ||
1185 | PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); | 1179 | PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); |
1186 | return 0; | 1180 | return 0; |
1187 | } | 1181 | } |
@@ -1210,7 +1204,6 @@ static int pwc_video_close(struct file *file) | |||
1210 | PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); | 1204 | PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); |
1211 | 1205 | ||
1212 | pdev = video_get_drvdata(vdev); | 1206 | pdev = video_get_drvdata(vdev); |
1213 | mutex_lock(&pdev->modlock); | ||
1214 | if (pdev->vopen == 0) | 1207 | if (pdev->vopen == 0) |
1215 | PWC_DEBUG_MODULE("video_close() called on closed device?\n"); | 1208 | PWC_DEBUG_MODULE("video_close() called on closed device?\n"); |
1216 | 1209 | ||
@@ -1248,7 +1241,6 @@ static int pwc_video_close(struct file *file) | |||
1248 | if (device_hint[hint].pdev == pdev) | 1241 | if (device_hint[hint].pdev == pdev) |
1249 | device_hint[hint].pdev = NULL; | 1242 | device_hint[hint].pdev = NULL; |
1250 | } | 1243 | } |
1251 | mutex_unlock(&pdev->modlock); | ||
1252 | 1244 | ||
1253 | return 0; | 1245 | return 0; |
1254 | } | 1246 | } |
@@ -1283,7 +1275,6 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1283 | if (pdev == NULL) | 1275 | if (pdev == NULL) |
1284 | return -EFAULT; | 1276 | return -EFAULT; |
1285 | 1277 | ||
1286 | mutex_lock(&pdev->modlock); | ||
1287 | if (pdev->error_status) { | 1278 | if (pdev->error_status) { |
1288 | rv = -pdev->error_status; /* Something happened, report what. */ | 1279 | rv = -pdev->error_status; /* Something happened, report what. */ |
1289 | goto err_out; | 1280 | goto err_out; |
@@ -1318,8 +1309,10 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1318 | rv = -ERESTARTSYS; | 1309 | rv = -ERESTARTSYS; |
1319 | goto err_out; | 1310 | goto err_out; |
1320 | } | 1311 | } |
1312 | mutex_unlock(&pdev->modlock); | ||
1321 | schedule(); | 1313 | schedule(); |
1322 | set_current_state(TASK_INTERRUPTIBLE); | 1314 | set_current_state(TASK_INTERRUPTIBLE); |
1315 | mutex_lock(&pdev->modlock); | ||
1323 | } | 1316 | } |
1324 | remove_wait_queue(&pdev->frameq, &wait); | 1317 | remove_wait_queue(&pdev->frameq, &wait); |
1325 | set_current_state(TASK_RUNNING); | 1318 | set_current_state(TASK_RUNNING); |
@@ -1352,10 +1345,8 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1352 | pdev->image_read_pos = 0; | 1345 | pdev->image_read_pos = 0; |
1353 | pwc_next_image(pdev); | 1346 | pwc_next_image(pdev); |
1354 | } | 1347 | } |
1355 | mutex_unlock(&pdev->modlock); | ||
1356 | return count; | 1348 | return count; |
1357 | err_out: | 1349 | err_out: |
1358 | mutex_unlock(&pdev->modlock); | ||
1359 | return rv; | 1350 | return rv; |
1360 | } | 1351 | } |
1361 | 1352 | ||
@@ -1372,9 +1363,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | |||
1372 | return -EFAULT; | 1363 | return -EFAULT; |
1373 | 1364 | ||
1374 | /* Start the stream (if not already started) */ | 1365 | /* Start the stream (if not already started) */ |
1375 | mutex_lock(&pdev->modlock); | ||
1376 | ret = pwc_isoc_init(pdev); | 1366 | ret = pwc_isoc_init(pdev); |
1377 | mutex_unlock(&pdev->modlock); | ||
1378 | if (ret) | 1367 | if (ret) |
1379 | return ret; | 1368 | return ret; |
1380 | 1369 | ||
@@ -1387,25 +1376,6 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | |||
1387 | return 0; | 1376 | return 0; |
1388 | } | 1377 | } |
1389 | 1378 | ||
1390 | static long pwc_video_ioctl(struct file *file, | ||
1391 | unsigned int cmd, unsigned long arg) | ||
1392 | { | ||
1393 | struct video_device *vdev = file->private_data; | ||
1394 | struct pwc_device *pdev; | ||
1395 | long r = -ENODEV; | ||
1396 | |||
1397 | if (!vdev) | ||
1398 | goto out; | ||
1399 | pdev = video_get_drvdata(vdev); | ||
1400 | |||
1401 | mutex_lock(&pdev->modlock); | ||
1402 | if (!pdev->unplugged) | ||
1403 | r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl); | ||
1404 | mutex_unlock(&pdev->modlock); | ||
1405 | out: | ||
1406 | return r; | ||
1407 | } | ||
1408 | |||
1409 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | 1379 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) |
1410 | { | 1380 | { |
1411 | struct video_device *vdev = file->private_data; | 1381 | struct video_device *vdev = file->private_data; |
@@ -1754,6 +1724,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1754 | } | 1724 | } |
1755 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1725 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); |
1756 | pdev->vdev->parent = &intf->dev; | 1726 | pdev->vdev->parent = &intf->dev; |
1727 | pdev->vdev->lock = &pdev->modlock; | ||
1728 | pdev->vdev->ioctl_ops = &pwc_ioctl_ops; | ||
1757 | strcpy(pdev->vdev->name, name); | 1729 | strcpy(pdev->vdev->name, name); |
1758 | video_set_drvdata(pdev->vdev, pdev); | 1730 | video_set_drvdata(pdev->vdev, pdev); |
1759 | 1731 | ||