lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110609115215.GA14569@mail.fossee.in>
Date:	Thu, 9 Jun 2011 17:22:15 +0530
From:	"Prashant P. Shah" <pshah.mumbai@...il.com>
To:	devel@...uxdriverproject.org
Cc:	Greg Kroah-Hartman <gregkh@...e.de>,
	Frank Mori Hess <fmhess@...rs.sourceforge.net>,
	Ian Abbott <abbotti@....co.uk>, linux-kernel@...r.kernel.org
Subject: [PATCH] Staging: comedi: dyna_pci10xx: replace semaphore with mutex

- Replace all semaphores with mutex
- Check NULL value for devpriv during detach callback

Signed-off-by: Prashant P. Shah <pshah.mumbai@...il.com>
---
 drivers/staging/comedi/drivers/dyna_pci10xx.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index 7acb2ed..50abb6e 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -39,7 +39,7 @@
 
 #include "../comedidev.h"
 #include "comedi_pci.h"
-#include <linux/semaphore.h>
+#include <linux/mutex.h>
 
 #define PCI_VENDOR_ID_DYNALOG		0x10b5
 #define DRV_NAME			"dyna_pci10xx"
@@ -126,7 +126,7 @@ static struct comedi_driver driver_dyna_pci10xx = {
 struct dyna_pci10xx_private {
 	struct pci_dev *pci_dev;	/*  ptr to PCI device */
 	char valid;			/*  card is usable */
-	struct semaphore sem;
+	struct mutex mutex;
 
 	/* device base address registers */
 	unsigned long BADR0, BADR1, BADR2, BADR3, BADR4, BADR5;
@@ -152,7 +152,7 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
 	chan = CR_CHAN(insn->chanspec);
 	range = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))];
 
-	down(&devpriv->sem);
+	mutex_lock(&devpriv->mutex);
 	/* convert n samples */
 	for (n = 0; n < insn->n; n++) {
 		/* trigger conversion */
@@ -176,7 +176,7 @@ conv_finish:
 		d &= 0x0FFF;
 		data[n] = d;
 	}
-	up(&devpriv->sem);
+	mutex_unlock(&devpriv->mutex);
 
 	/* return the number of samples read/written */
 	return n;
@@ -193,13 +193,13 @@ static int dyna_pci10xx_insn_write_ao(struct comedi_device *dev,
 	chan = CR_CHAN(insn->chanspec);
 	range = thisboard->range_codes_ai[CR_RANGE((insn->chanspec))];
 
-	down(&devpriv->sem);
+	mutex_lock(&devpriv->mutex);
 	for (n = 0; n < insn->n; n++) {
 		/* trigger conversion and write data */
 		outw_p(data[n], devpriv->BADR2);
 		smp_mb(); udelay(10);
 	}
-	up(&devpriv->sem);
+	mutex_unlock(&devpriv->mutex);
 	return n;
 }
 
@@ -213,11 +213,11 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
 	if (insn->n != 2)
 		return -EINVAL;
 
-	down(&devpriv->sem);
+	mutex_lock(&devpriv->mutex);
 	smp_mb();
 	d = inw_p(devpriv->BADR3);
 	udelay(10);
-	up(&devpriv->sem);
+	mutex_unlock(&devpriv->mutex);
 
 	/* on return the data[0] contains output and data[1] contains input */
 	data[1] = d;
@@ -238,15 +238,13 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
 	 * in data[1], each channel cooresponding to a bit.
 	 * s->state contains the previous write data
 	 */
-
+	mutex_lock(&devpriv->mutex);
 	if (data[0]) {
-		down(&devpriv->sem);
 		s->state &= ~data[0];
 		s->state |= (data[0] & data[1]);
 		smp_mb();
 		outw_p(s->state, devpriv->BADR3);
 		udelay(10);
-		up(&devpriv->sem);
 	}
 
 	/*
@@ -255,7 +253,7 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
 	 * output values if it was a purely digital output subdevice.
 	 */
 	data[1] = s->state;
-
+	mutex_unlock(&devpriv->mutex);
 	return 2;
 }
 
@@ -339,7 +337,7 @@ found:
 		return -EIO;
 	}
 
-	sema_init(&devpriv->sem, 1);
+	mutex_init(&devpriv->mutex);
 	dev->board_ptr = &boardtypes[board_index];
 	devpriv->pci_dev = pcidev;
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ