From 51b540292a349b380ccc0572401c6ac343acdf4a Mon Sep 17 00:00:00 2001 From: Matthias Kaehlcke Date: Mon, 2 Jul 2007 10:19:38 -0300 Subject: V4L/DVB (5811): Use mutex instead of semaphore in Virtual Video driver The Virtual Video driver uses a semaphore as mutex. Use the mutex API instead of the (binary) semaphore. Signed-off-by: Matthias Kaehlcke Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/vivi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 582c6ba7c608..f6d3a9460ccc 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #ifdef CONFIG_VIDEO_V4L1_COMPAT @@ -165,7 +166,7 @@ static LIST_HEAD(vivi_devlist); struct vivi_dev { struct list_head vivi_devlist; - struct semaphore lock; + struct mutex lock; int users; @@ -738,16 +739,16 @@ static struct videobuf_queue_ops vivi_video_qops = { static int res_get(struct vivi_dev *dev, struct vivi_fh *fh) { /* is it free? */ - down(&dev->lock); + mutex_lock(&dev->lock); if (dev->resources) { /* no, someone else uses it */ - up(&dev->lock); + mutex_unlock(&dev->lock); return 0; } /* it's free, grab it */ dev->resources =1; dprintk(1,"res: get\n"); - up(&dev->lock); + mutex_unlock(&dev->lock); return 1; } @@ -758,10 +759,10 @@ static int res_locked(struct vivi_dev *dev) static void res_free(struct vivi_dev *dev, struct vivi_fh *fh) { - down(&dev->lock); + mutex_lock(&dev->lock); dev->resources = 0; dprintk(1,"res: put\n"); - up(&dev->lock); + mutex_lock(&dev->lock); } /* ------------------------------------------------------------------ @@ -1260,7 +1261,7 @@ static int __init vivi_init(void) init_waitqueue_head(&dev->vidq.wq); /* initialize locks */ - init_MUTEX(&dev->lock); + mutex_init(&dev->lock); dev->vidq.timeout.function = vivi_vid_timeout; dev->vidq.timeout.data = (unsigned long)dev; -- cgit v1.2.3