summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-01-20 12:00:22 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-25 19:59:09 +0800
commit53c0bee80f975cb095796e3676fd6a98e32f1beb (patch)
tree3b96f4d9ec50beb078ff2fd2748067e75e51b328
parentbe8e89087ec2d2c8a1ad1e3db64bf4efdfc3c298 (diff)
staging: comedi: aio_iiro_16: return input state in async command sample
Modify the sample data returned by the async command to include the current state of the digital inputs. Otherwise the command needs to be canceled in order for the user to do an (*insn_bits) operation to check the digital inputs. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/aio_iiro_16.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c
index d8884a39867e..1c7b325a373c 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -27,11 +27,14 @@
*
* The board supports interrupts on change of state of the digital inputs.
* The sample data returned by the async command indicates which inputs
- * changed state:
+ * changed state and the current state of the inputs:
*
- * Bit 7 - IRQ Enable (1) / Disable (0)
- * Bit 1 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
- * Bit 0 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 23 - IRQ Enable (1) / Disable (0)
+ * Bit 17 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
+ * Bit 16 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
+ * Bit 15 - Digital input 15
+ * ...
+ * Bit 0 - Digital input 0
*/
#include <linux/module.h>
@@ -51,17 +54,31 @@
#define AIO_IIRO_16_STATUS_INPUT_8_15 BIT(1)
#define AIO_IIRO_16_STATUS_INPUT_0_7 BIT(0)
+static unsigned int aio_iiro_16_read_inputs(struct comedi_device *dev)
+{
+ unsigned int val;
+
+ val = inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
+ val |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
+
+ return val;
+}
+
static irqreturn_t aio_iiro_16_cos(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
unsigned int status;
+ unsigned int val;
status = inb(dev->iobase + AIO_IIRO_16_STATUS);
if (!(status & AIO_IIRO_16_STATUS_IRQE))
return IRQ_NONE;
- comedi_buf_write_samples(s, &status, 1);
+ val = aio_iiro_16_read_inputs(dev);
+ val |= (status << 16);
+
+ comedi_buf_write_samples(s, &val, 1);
comedi_handle_events(dev, s);
return IRQ_HANDLED;
@@ -150,9 +167,7 @@ static int aio_iiro_16_di_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
- data[1] = 0;
- data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
- data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
+ data[1] = aio_iiro_16_read_inputs(dev);
return insn->n;
}
@@ -207,7 +222,7 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
s->insn_bits = aio_iiro_16_di_insn_bits;
if (dev->irq) {
dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
+ s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL;
s->len_chanlist = 1;
s->do_cmdtest = aio_iiro_16_cos_cmdtest;
s->do_cmd = aio_iiro_16_cos_cmd;