diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2006-03-20 13:59:42 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-03-24 16:26:52 -0300 |
commit | 2ae151911e31e6a012a46431cc515cc251242573 (patch) | |
tree | b0c10dad3622738f9f3e08d14f817d53c143dd59 /drivers/media/video | |
parent | bc2c7c365bd18c00f5fefaf1a560c440f3ce13f3 (diff) | |
download | op-kernel-dev-2ae151911e31e6a012a46431cc515cc251242573.zip op-kernel-dev-2ae151911e31e6a012a46431cc515cc251242573.tar.gz |
V4L/DVB (3569): PATCH: switch cpia2 to mutexes and use ioctl 32 compat lib func
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/cpia2/cpia2.h | 2 | ||||
-rw-r--r-- | drivers/media/video/cpia2/cpia2_core.c | 40 | ||||
-rw-r--r-- | drivers/media/video/cpia2/cpia2_v4l.c | 43 |
3 files changed, 43 insertions, 42 deletions
diff --git a/drivers/media/video/cpia2/cpia2.h b/drivers/media/video/cpia2/cpia2.h index 95d3afa..8394283 100644 --- a/drivers/media/video/cpia2/cpia2.h +++ b/drivers/media/video/cpia2/cpia2.h @@ -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 */ diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c index 5dfb242..fd771c7 100644 --- a/drivers/media/video/cpia2/cpia2_core.c +++ b/drivers/media/video/cpia2/cpia2_core.c @@ -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; @@ -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 */ } @@ -2389,34 +2389,34 @@ 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; } @@ -2424,7 +2424,7 @@ long cpia2_read(struct camera_data *cam, frame->status = FRAME_EMPTY; - up(&cam->busy_lock); + mutex_unlock(&cam->busy_lock); return count; } @@ -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; } @@ -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; } @@ -2488,18 +2488,18 @@ 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; } @@ -2507,7 +2507,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma) 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; @@ -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; } diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 08f8be3..481e178 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c @@ -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) { @@ -299,7 +299,7 @@ skip_init: cpia2_dbg_dump_registers(cam); err_return: - up(&cam->busy_lock); + mutex_unlock(&cam->busy_lock); return retval; } @@ -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 @@ -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; } @@ -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) @@ -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) @@ -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; } @@ -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; @@ -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; @@ -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; } @@ -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 = { |