[media] pwc: convert to core-assisted locking

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Hans Verkuil 2011-01-13 05:05:36 -03:00 committed by Mauro Carvalho Chehab
parent 5b2830298d
commit b577f962d2
2 changed files with 5 additions and 13 deletions

View file

@ -1098,7 +1098,6 @@ static int pwc_video_open(struct file *file)
return -EBUSY; return -EBUSY;
} }
mutex_lock(&pdev->modlock);
pwc_construct(pdev); /* set min/max sizes correct */ pwc_construct(pdev); /* set min/max sizes correct */
if (!pdev->usb_init) { if (!pdev->usb_init) {
PWC_DEBUG_OPEN("Doing first time initialization.\n"); PWC_DEBUG_OPEN("Doing first time initialization.\n");
@ -1130,7 +1129,6 @@ static int pwc_video_open(struct file *file)
if (i < 0) { if (i < 0) {
PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n");
pwc_free_buffers(pdev); pwc_free_buffers(pdev);
mutex_unlock(&pdev->modlock);
return i; return i;
} }
@ -1171,7 +1169,6 @@ static int pwc_video_open(struct file *file)
if (i) { if (i) {
PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n");
pwc_free_buffers(pdev); pwc_free_buffers(pdev);
mutex_unlock(&pdev->modlock);
return i; return i;
} }
@ -1181,7 +1178,6 @@ static int pwc_video_open(struct file *file)
pdev->vopen++; pdev->vopen++;
file->private_data = vdev; file->private_data = vdev;
mutex_unlock(&pdev->modlock);
PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); PWC_DEBUG_OPEN("<< video_open() returns 0.\n");
return 0; return 0;
} }
@ -1210,7 +1206,6 @@ static int pwc_video_close(struct file *file)
PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev);
pdev = video_get_drvdata(vdev); pdev = video_get_drvdata(vdev);
mutex_lock(&pdev->modlock);
if (pdev->vopen == 0) if (pdev->vopen == 0)
PWC_DEBUG_MODULE("video_close() called on closed device?\n"); PWC_DEBUG_MODULE("video_close() called on closed device?\n");
@ -1248,7 +1243,6 @@ static int pwc_video_close(struct file *file)
if (device_hint[hint].pdev == pdev) if (device_hint[hint].pdev == pdev)
device_hint[hint].pdev = NULL; device_hint[hint].pdev = NULL;
} }
mutex_unlock(&pdev->modlock);
return 0; return 0;
} }
@ -1283,7 +1277,6 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
if (pdev == NULL) if (pdev == NULL)
return -EFAULT; return -EFAULT;
mutex_lock(&pdev->modlock);
if (pdev->error_status) { if (pdev->error_status) {
rv = -pdev->error_status; /* Something happened, report what. */ rv = -pdev->error_status; /* Something happened, report what. */
goto err_out; goto err_out;
@ -1318,8 +1311,10 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
rv = -ERESTARTSYS; rv = -ERESTARTSYS;
goto err_out; goto err_out;
} }
mutex_unlock(&pdev->modlock);
schedule(); schedule();
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
mutex_lock(&pdev->modlock);
} }
remove_wait_queue(&pdev->frameq, &wait); remove_wait_queue(&pdev->frameq, &wait);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
@ -1352,10 +1347,8 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf,
pdev->image_read_pos = 0; pdev->image_read_pos = 0;
pwc_next_image(pdev); pwc_next_image(pdev);
} }
mutex_unlock(&pdev->modlock);
return count; return count;
err_out: err_out:
mutex_unlock(&pdev->modlock);
return rv; return rv;
} }
@ -1372,9 +1365,7 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
return -EFAULT; return -EFAULT;
/* Start the stream (if not already started) */ /* Start the stream (if not already started) */
mutex_lock(&pdev->modlock);
ret = pwc_isoc_init(pdev); ret = pwc_isoc_init(pdev);
mutex_unlock(&pdev->modlock);
if (ret) if (ret)
return ret; return ret;
@ -1398,10 +1389,8 @@ static long pwc_video_ioctl(struct file *file,
goto out; goto out;
pdev = video_get_drvdata(vdev); pdev = video_get_drvdata(vdev);
mutex_lock(&pdev->modlock);
if (!pdev->unplugged) if (!pdev->unplugged)
r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl); r = video_usercopy(file, cmd, arg, pwc_video_do_ioctl);
mutex_unlock(&pdev->modlock);
out: out:
return r; return r;
} }
@ -1754,6 +1743,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
} }
memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template));
pdev->vdev->parent = &intf->dev; pdev->vdev->parent = &intf->dev;
pdev->vdev->lock = &pdev->modlock;
strcpy(pdev->vdev->name, name); strcpy(pdev->vdev->name, name);
video_set_drvdata(pdev->vdev, pdev); video_set_drvdata(pdev->vdev, pdev);

View file

@ -830,8 +830,10 @@ long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
mutex_unlock(&pdev->modlock);
schedule(); schedule();
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
mutex_lock(&pdev->modlock);
} }
remove_wait_queue(&pdev->frameq, &wait); remove_wait_queue(&pdev->frameq, &wait);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);