Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23633
b: refs/heads/master
c: 2ae1519
h: refs/heads/master
i:
  23631: 83d684f
v: v3
  • Loading branch information
Alan Cox authored and Mauro Carvalho Chehab committed Mar 24, 2006
1 parent dd7afc4 commit 8d460db
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc2c7c365bd18c00f5fefaf1a560c440f3ce13f3
refs/heads/master: 2ae151911e31e6a012a46431cc515cc251242573
2 changes: 1 addition & 1 deletion trunk/drivers/media/video/cpia2/cpia2.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ struct cpia2_fh {

struct camera_data {
/* locks */
struct semaphore busy_lock; /* guard against SMP multithreading */
struct mutex busy_lock; /* guard against SMP multithreading */
struct v4l2_prio_state prio;

/* camera status */
Expand Down
40 changes: 20 additions & 20 deletions trunk/drivers/media/video/cpia2/cpia2_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ struct camera_data *cpia2_init_camera_struct(void)
memset(cam, 0, sizeof(struct camera_data));

cam->present = 1;
init_MUTEX(&cam->busy_lock);
mutex_init(&cam->busy_lock);
init_waitqueue_head(&cam->wq_stream);

return cam;
Expand Down Expand Up @@ -2371,12 +2371,12 @@ long cpia2_read(struct camera_data *cam,
}

/* make this _really_ smp and multithread-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;

if (!cam->present) {
LOG("%s: camera removed\n",__FUNCTION__);
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0; /* EOF */
}

Expand All @@ -2389,42 +2389,42 @@ long cpia2_read(struct camera_data *cam,
/* Copy cam->curbuff in case it changes while we're processing */
frame = cam->curbuff;
if (noblock && frame->status != FRAME_READY) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EAGAIN;
}

if(frame->status != FRAME_READY) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->present ||
(frame = cam->curbuff)->status == FRAME_READY);
if (signal_pending(current))
return -ERESTARTSYS;
/* make this _really_ smp and multithread-safe */
if (down_interruptible(&cam->busy_lock)) {
if (mutex_lock_interruptible(&cam->busy_lock)) {
return -ERESTARTSYS;
}
if(!cam->present) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0;
}
}

/* copy data to user space */
if (frame->length > count) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EFAULT;
}
if (copy_to_user(buf, frame->data, frame->length)) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EFAULT;
}

count = frame->length;

frame->status = FRAME_EMPTY;

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return count;
}

Expand All @@ -2443,10 +2443,10 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
return POLLERR;
}

down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);

if(!cam->present) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return POLLHUP;
}

Expand All @@ -2456,16 +2456,16 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
cam->params.camera_state.stream_mode);
}

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
poll_wait(filp, &cam->wq_stream, wait);
down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);

if(!cam->present)
status = POLLHUP;
else if(cam->curbuff->status == FRAME_READY)
status = POLLIN | POLLRDNORM;

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return status;
}

Expand All @@ -2488,26 +2488,26 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
DBG("mmap offset:%ld size:%ld\n", start_offset, size);

/* make this _really_ smp-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;

if (!cam->present) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -ENODEV;
}

if (size > cam->frame_size*cam->num_frames ||
(start_offset % cam->frame_size) != 0 ||
(start_offset+size > cam->frame_size*cam->num_frames)) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EINVAL;
}

pos = ((unsigned long) (cam->frame_buffer)) + start_offset;
while (size > 0) {
page = kvirt_to_pa(pos);
if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EAGAIN;
}
start += PAGE_SIZE;
Expand All @@ -2519,7 +2519,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
}

cam->mmapped = true;
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return 0;
}

43 changes: 22 additions & 21 deletions trunk/drivers/media/video/cpia2/cpia2_v4l.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static int cpia2_open(struct inode *inode, struct file *file)
return -ENODEV;
}

if(down_interruptible(&cam->busy_lock))
if(mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;

if(!cam->present) {
Expand Down Expand Up @@ -299,7 +299,7 @@ static int cpia2_open(struct inode *inode, struct file *file)
cpia2_dbg_dump_registers(cam);

err_return:
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return retval;
}

Expand All @@ -314,7 +314,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
struct camera_data *cam = video_get_drvdata(dev);
struct cpia2_fh *fh = file->private_data;

down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);

if (cam->present &&
(cam->open_count == 1
Expand Down Expand Up @@ -347,7 +347,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
}
}

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);

return 0;
}
Expand Down Expand Up @@ -523,11 +523,11 @@ static int sync(struct camera_data *cam, int frame_nr)
return 0;
}

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->streaming ||
frame->status == FRAME_READY);
down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);
if (signal_pending(current))
return -ERESTARTSYS;
if(!cam->present)
Expand Down Expand Up @@ -1544,11 +1544,11 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file)
if(frame < 0) {
/* Wait for a frame to become available */
struct framebuf *cb=cam->curbuff;
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->present ||
(cb=cam->curbuff)->status == FRAME_READY);
down(&cam->busy_lock);
mutex_lock(&cam->busy_lock);
if (signal_pending(current))
return -ERESTARTSYS;
if(!cam->present)
Expand Down Expand Up @@ -1591,11 +1591,11 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
return -ENOTTY;

/* make this _really_ smp-safe */
if (down_interruptible(&cam->busy_lock))
if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;

if (!cam->present) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -ENODEV;
}

Expand All @@ -1608,7 +1608,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
struct cpia2_fh *fh = file->private_data;
retval = v4l2_prio_check(&cam->prio, &fh->prio);
if(retval) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return retval;
}
break;
Expand All @@ -1618,7 +1618,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
{
struct cpia2_fh *fh = file->private_data;
if(fh->prio != V4L2_PRIORITY_RECORD) {
up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return -EBUSY;
}
break;
Expand Down Expand Up @@ -1847,7 +1847,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
break;
}

up(&cam->busy_lock);
mutex_unlock(&cam->busy_lock);
return retval;
}

Expand Down Expand Up @@ -1924,14 +1924,15 @@ static void reset_camera_struct_v4l(struct camera_data *cam)
* The v4l video device structure initialized for this device
***/
static struct file_operations fops_template = {
.owner= THIS_MODULE,
.open= cpia2_open,
.release= cpia2_close,
.read= cpia2_v4l_read,
.poll= cpia2_v4l_poll,
.ioctl= cpia2_ioctl,
.llseek= no_llseek,
.mmap= cpia2_mmap,
.owner = THIS_MODULE,
.open = cpia2_open,
.release = cpia2_close,
.read = cpia2_v4l_read,
.poll = cpia2_v4l_poll,
.ioctl = cpia2_ioctl,
.llseek = no_llseek,
.compat_ioctl = v4l_compat_ioctl32,
.mmap = cpia2_mmap,
};

static struct video_device cpia2_template = {
Expand Down

0 comments on commit 8d460db

Please sign in to comment.