[RFC PATCH 33/36] staging: comedi: amplc_dio200_common: remove 'spinlock' from struct dio200_subdev_8254

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently this driver uses a spinlock in the 8254 subdevice (*insn_read), (*insn_write),
and (*insn_config) functions. The comedi core checks if the subdevice is 'busy', in
parse_insn(), before any of the subdevice functions are attempted.

Remove the unnecessary spinlock.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../staging/comedi/drivers/amplc_dio200_common.c   | 23 +++++-----------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 48cdddc..08dab1f 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -101,7 +101,6 @@ struct dio200_subdev_8254 {
 	unsigned int ofs;		/* Counter base offset */
 	unsigned int clock_src[3];	/* Current clock sources */
 	unsigned int gate_src[3];	/* Current gate sources */
-	spinlock_t spinlock;
 };
 
 struct dio200_subdev_8255 {
@@ -535,16 +534,12 @@ static int dio200_subdev_8254_read(struct comedi_device *dev,
 				   struct comedi_insn *insn,
 				   unsigned int *data)
 {
-	struct dio200_subdev_8254 *subpriv = s->private;
 	int chan = CR_CHAN(insn->chanspec);
 	unsigned int n;
-	unsigned long flags;
 
-	for (n = 0; n < insn->n; n++) {
-		spin_lock_irqsave(&subpriv->spinlock, flags);
+	for (n = 0; n < insn->n; n++)
 		data[n] = dio200_subdev_8254_read_chan(dev, s, chan);
-		spin_unlock_irqrestore(&subpriv->spinlock, flags);
-	}
+
 	return insn->n;
 }
 
@@ -553,16 +548,12 @@ static int dio200_subdev_8254_write(struct comedi_device *dev,
 				    struct comedi_insn *insn,
 				    unsigned int *data)
 {
-	struct dio200_subdev_8254 *subpriv = s->private;
 	int chan = CR_CHAN(insn->chanspec);
 	unsigned int n;
-	unsigned long flags;
 
-	for (n = 0; n < insn->n; n++) {
-		spin_lock_irqsave(&subpriv->spinlock, flags);
+	for (n = 0; n < insn->n; n++)
 		dio200_subdev_8254_write_chan(dev, s, chan, data[n]);
-		spin_unlock_irqrestore(&subpriv->spinlock, flags);
-	}
+
 	return insn->n;
 }
 
@@ -643,12 +634,9 @@ static int dio200_subdev_8254_config(struct comedi_device *dev,
 				     struct comedi_insn *insn,
 				     unsigned int *data)
 {
-	struct dio200_subdev_8254 *subpriv = s->private;
 	int ret = 0;
 	int chan = CR_CHAN(insn->chanspec);
-	unsigned long flags;
 
-	spin_lock_irqsave(&subpriv->spinlock, flags);
 	switch (data[0]) {
 	case INSN_CONFIG_SET_COUNTER_MODE:
 		if (data[1] > (I8254_MODE5 | I8254_BCD))
@@ -689,7 +677,7 @@ static int dio200_subdev_8254_config(struct comedi_device *dev,
 		ret = -EINVAL;
 		break;
 	}
-	spin_unlock_irqrestore(&subpriv->spinlock, flags);
+
 	return ret < 0 ? ret : insn->n;
 }
 
@@ -713,7 +701,6 @@ static int dio200_subdev_8254_init(struct comedi_device *dev,
 	s->insn_write = dio200_subdev_8254_write;
 	s->insn_config = dio200_subdev_8254_config;
 
-	spin_lock_init(&subpriv->spinlock);
 	subpriv->ofs = offset;
 
 	/* Initialize channels. */
-- 
2.3.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux