From: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
To: mchehab@infradead.org, video4linux-list@redhat.com
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [PATCH 4/5] use mutex instead of semaphore in Virtual Video driver
Date: Sun, 1 Jul 2007 18:33:49 +0200 [thread overview]
Message-ID: <20070701163349.GG3940@traven> (raw)
In-Reply-To: <20070701162529.GC3940@traven>
The Virtual Video driver uses a semaphore as mutex. Use the mutex API
instead of the (binary) semaphore.
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
--
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index f7e1d19..e86f4cd 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -25,6 +25,7 @@
#include <linux/pci.h>
#include <linux/random.h>
#include <linux/version.h>
+#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <linux/dma-mapping.h>
#ifdef CONFIG_VIDEO_V4L1_COMPAT
@@ -168,7 +169,7 @@ static LIST_HEAD(vivi_devlist);
struct vivi_dev {
struct list_head vivi_devlist;
- struct semaphore lock;
+ struct mutex lock;
int users;
@@ -892,16 +893,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;
}
@@ -912,10 +913,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);
}
/* ------------------------------------------------------------------
@@ -1422,7 +1423,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;
--
Matthias Kaehlcke
Linux Application Developer
Barcelona
In itself, homosexuality is as limiting as heterosexuality: the
ideal should be to be capable of loving a woman or a man; either,
a human being, without feeling fear, restraint, or obligation
(Simone de Beauvoir)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
next prev parent reply other threads:[~2007-07-01 16:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-01 16:25 [PATCH 0/5] use mutex instead of semaphore in several drivers Matthias Kaehlcke
2007-07-01 16:29 ` [PATCH 1/5] use mutex instead of semaphore in Megaraid Mailbox driver Matthias Kaehlcke
2007-07-03 18:09 ` Patro, Sumant
2007-07-03 18:09 ` Patro, Sumant
2007-07-01 16:30 ` [PATCH 2/5] use mutex instead of semaphore in Philips webcam driver Matthias Kaehlcke
2007-07-01 16:32 ` [lm-sensors] [PATCH 3/5] use mutex instead of semaphore in SMSC Matthias Kaehlcke
2007-07-01 16:32 ` [PATCH 3/5] use mutex instead of semaphore in SMSC LPC47M192 driver Matthias Kaehlcke
2007-07-01 17:26 ` [lm-sensors] [PATCH 3/5] use mutex instead of semaphore in SMSC Mark M. Hoffman
2007-07-01 17:26 ` [lm-sensors] [PATCH 3/5] use mutex instead of semaphore in SMSC LPC47M192 driver Mark M. Hoffman
2007-07-01 16:33 ` Matthias Kaehlcke [this message]
2007-07-01 16:35 ` [PATCH 5/5] use mutex instead of semaphore in VLSI 82C147 IrDA controller driver Matthias Kaehlcke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070701163349.GG3940@traven \
--to=matthias.kaehlcke@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.