diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2011-01-13 03:05:36 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:31:51 -0400 |
commit | b577f962d27c055571f72ddd73ae3aded39a6261 (patch) | |
tree | ddefde5ca01ad0ffcf9a499cc495378d284f2873 /drivers/media/video/pwc | |
parent | 5b2830298dc0534eb33277a31f353bb524e2cc2e (diff) |
[media] pwc: convert to core-assisted locking
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pwc')
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 16 | ||||
-rw-r--r-- | drivers/media/video/pwc/pwc-v4l.c | 2 |
2 files changed, 5 insertions, 13 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index bd1519a4ecb..4aa70faaae8 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -1098,7 +1098,6 @@ static int pwc_video_open(struct file *file) | |||
1098 | return -EBUSY; | 1098 | return -EBUSY; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | mutex_lock(&pdev->modlock); | ||
1102 | pwc_construct(pdev); /* set min/max sizes correct */ | 1101 | pwc_construct(pdev); /* set min/max sizes correct */ |
1103 | if (!pdev->usb_init) { | 1102 | if (!pdev->usb_init) { |
1104 | PWC_DEBUG_OPEN("Doing first time initialization.\n"); | 1103 | PWC_DEBUG_OPEN("Doing first time initialization.\n"); |
@@ -1130,7 +1129,6 @@ static int pwc_video_open(struct file *file) | |||
1130 | if (i < 0) { | 1129 | if (i < 0) { |
1131 | PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); | 1130 | PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); |
1132 | pwc_free_buffers(pdev); | 1131 | pwc_free_buffers(pdev); |
1133 | mutex_unlock(&pdev->modlock); | ||
1134 | return i; | 1132 | return i; |
1135 | } | 1133 | } |
1136 | 1134 | ||
@@ -1171,7 +1169,6 @@ static int pwc_video_open(struct file *file) | |||
1171 | if (i) { | 1169 | if (i) { |
1172 | PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); | 1170 | PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); |
1173 | pwc_free_buffers(pdev); | 1171 | pwc_free_buffers(pdev); |
1174 | mutex_unlock(&pdev->modlock); | ||
1175 | return i; | 1172 | return i; |
1176 | } | 1173 | } |
1177 | 1174 | ||
@@ -1181,7 +1178,6 @@ static int pwc_video_open(struct file *file) | |||
1181 | 1178 | ||
1182 | pdev->vopen++; | 1179 | pdev->vopen++; |
1183 | file->private_data = vdev; | 1180 | file->private_data = vdev; |
1184 | mutex_unlock(&pdev->modlock); | ||
1185 | PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); | 1181 | PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); |
1186 | return 0; | 1182 | return 0; |
1187 | } | 1183 | } |
@@ -1210,7 +1206,6 @@ static int pwc_video_close(struct file *file) | |||
1210 | PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); | 1206 | PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); |
1211 | 1207 | ||
1212 | pdev = video_get_drvdata(vdev); | 1208 | pdev = video_get_drvdata(vdev); |
1213 | mutex_lock(&pdev->modlock); | ||
1214 | if (pdev->vopen == 0) | 1209 | if (pdev->vopen == 0) |
1215 | PWC_DEBUG_MODULE("video_close() called on closed device?\n"); | 1210 | PWC_DEBUG_MODULE("video_close() called on closed device?\n"); |
1216 | 1211 | ||
@@ -1248,7 +1243,6 @@ static int pwc_video_close(struct file *file) | |||
1248 | if (device_hint[hint].pdev == pdev) | 1243 | if (device_hint[hint].pdev == pdev) |
1249 | device_hint[hint].pdev = NULL; | 1244 | device_hint[hint].pdev = NULL; |
1250 | } | 1245 | } |
1251 | mutex_unlock(&pdev->modlock); | ||
1252 | 1246 | ||
1253 | return 0; | 1247 | return 0; |
1254 | } | 1248 | } |
@@ -1283,7 +1277,6 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1283 | if (pdev == NULL) | 1277 | if (pdev == NULL) |
1284 | return -EFAULT; | 1278 | return -EFAULT; |
1285 | 1279 | ||
1286 | mutex_lock(&pdev->modlock); | ||
1287 | if (pdev->error_status) { | 1280 | if (pdev->error_status) { |
1288 | rv = -pdev->error_status; /* Something happened, report what. */ | 1281 | rv = -pdev->error_status; /* Something happened, report what. */ |
1289 | goto err_out; | 1282 | goto err_out; |
@@ -1318,8 +1311,10 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1318 | rv = -ERESTARTSYS; | 1311 | rv = -ERESTARTSYS; |
1319 | goto err_out; | 1312 | goto err_out; |
1320 | } | 1313 | } |
1314 | mutex_unlock(&pdev->modlock); | ||
1321 | schedule(); | 1315 | schedule(); |
1322 | set_current_state(TASK_INTERRUPTIBLE); | 1316 | set_current_state(TASK_INTERRUPTIBLE); |
1317 | mutex_lock(&pdev->modlock); | ||
1323 | } | 1318 | } |
1324 | remove_wait_queue(&pdev->frameq, &wait); | 1319 | remove_wait_queue(&pdev->frameq, &wait); |
1325 | set_current_state(TASK_RUNNING); | 1320 | set_current_state(TASK_RUNNING); |
@@ -1352,10 +1347,8 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, | |||
1352 | pdev->image_read_pos = 0; | 1347 | pdev->image_read_pos = 0; |
1353 | pwc_next_image(pdev); | 1348 | pwc_next_image(pdev); |
1354 | } | 1349 | } |
1355 | mutex_unlock(&pdev->modlock); | ||
1356 | return count; | 1350 | return count; |
1357 | err_out: | 1351 | err_out: |
1358 | mutex_unlock(&pdev->modlock); | ||
1359 | return rv; | 1352 | return rv; |
1360 | } | 1353 | } |
1361 | 1354 | ||
@@ -1372,9 +1365,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | |||
1372 | return -EFAULT; | 1365 | return -EFAULT; |
1373 | 1366 | ||
1374 | /* Start the stream (if not already started) */ | 1367 | /* Start the stream (if not already started) */ |
1375 | mutex_lock(&pdev->modlock); | ||
1376 | ret = pwc_isoc_init(pdev); | 1368 | ret = pwc_isoc_init(pdev); |
1377 | mutex_unlock(&pdev->modlock); | ||
1378 | if (ret) | 1369 | if (ret) |
1379 | return ret; | 1370 | return ret; |
1380 | 1371 | ||
@@ -1398,10 +1389,8 @@ static long pwc_video_ioctl(struct file *file, | |||
1398 | goto out; | 1389 | goto out; |
1399 | pdev = video_get_drvdata(vdev); | 1390 | pdev = video_get_drvdata(vdev); |
1400 | 1391 | ||
1401 | mutex_lock(&pdev->modlock); | ||
1402 | if (!pdev->unplugged) | 1392 | if (!pdev->unplugged) |
1403 | r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl); | 1393 | r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl); |
1404 | mutex_unlock(&pdev->modlock); | ||
1405 | out: | 1394 | out: |
1406 | return r; | 1395 | return r; |
1407 | } | 1396 | } |
@@ -1754,6 +1743,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1754 | } | 1743 | } |
1755 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1744 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); |
1756 | pdev->vdev->parent = &intf->dev; | 1745 | pdev->vdev->parent = &intf->dev; |
1746 | pdev->vdev->lock = &pdev->modlock; | ||
1757 | strcpy(pdev->vdev->name, name); | 1747 | strcpy(pdev->vdev->name, name); |
1758 | video_set_drvdata(pdev->vdev, pdev); | 1748 | video_set_drvdata(pdev->vdev, pdev); |
1759 | 1749 | ||
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index 8ca4d22b438..8a7e52c3b8f 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -830,8 +830,10 @@ long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
830 | set_current_state(TASK_RUNNING); | 830 | set_current_state(TASK_RUNNING); |
831 | return -ERESTARTSYS; | 831 | return -ERESTARTSYS; |
832 | } | 832 | } |
833 | mutex_unlock(&pdev->modlock); | ||
833 | schedule(); | 834 | schedule(); |
834 | set_current_state(TASK_INTERRUPTIBLE); | 835 | set_current_state(TASK_INTERRUPTIBLE); |
836 | mutex_lock(&pdev->modlock); | ||
835 | } | 837 | } |
836 | remove_wait_queue(&pdev->frameq, &wait); | 838 | remove_wait_queue(&pdev->frameq, &wait); |
837 | set_current_state(TASK_RUNNING); | 839 | set_current_state(TASK_RUNNING); |