Skip to contentSkip to conversation

usbvision: Convert semaphore to mutex

PATCH In review Matthias Kaehlcke 2 participants 2 messages Oct 24, 2007 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbvision: Convert semaphore to mutex

usbvision: Convert the usbvision->lock semaphore to the mutex API

--

drivers/media/video/usbvision/usbvision-core.c +6 -2
index c7d5f9e..2038d40 100644
@@ -2242,14 +2242,18 @@ static void call_usbvision_power_off(struct work_struct *work)
 	struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork);
 
 	PDEBUG(DBG_FUNC, "");
-	down_interruptible(&usbvision->lock);
+	if(mutex_lock_interruptible(&usbvision->lock)) {
+		return;
+	}
+
+
 	if(usbvision->user == 0) {
 		usbvision_i2c_unregister(usbvision);
 
 		usbvision_power_off(usbvision);
 		usbvision->initialized = 0;
 	}
-	up(&usbvision->lock);
+	mutex_unlock(&usbvision->lock);
 }
 
 static void usbvision_powerOffTimer(unsigned long data)
drivers/media/video/usbvision/usbvision-video.c +27 -27

200 lines not on this page · raw message

drivers/media/video/usbvision/usbvision.h +2 -1
index c5b6c50..0fe4bff 100644
@@ -34,6 +34,7 @@
 #include <linux/list.h>
 #include <linux/usb.h>
 #include <linux/i2c.h>
+#include <linux/mutex.h>
 #include <media/v4l2-common.h>
 #include <media/tuner.h>
 #include <linux/videodev2.h>
@@ -396,7 +397,7 @@ struct usb_usbvision {
 	unsigned char iface;						/* Video interface number */
 	unsigned char ifaceAlt;			/* Alt settings */
 	unsigned char Vin_Reg2_Preset;
-	struct semaphore lock;
+	struct mutex lock;
 	struct timer_list powerOffTimer;
 	struct work_struct powerOffWork;
 	int power;							/* is the device powered on? */
Signature · 12 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona

        Representation of the world, like the world itself, is
        the work of men; they describe it from their own point
         of view, which they  confuse with the absolute truth
                          (Simone de Beauvoir)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-