staging: comedi: addi_apci_1564: add subdevice to check diagnostic status
authorChase Southwood <chase.southwood@gmail.com>
Fri, 1 Aug 2014 01:56:15 +0000 (20:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2014 22:37:22 +0000 (15:37 -0700)
This board provides VCC/CC diagnostic information, and it also supports
diagnostic interrupts.  However, as per Ian, these interrupts aren't very
useful and it is enough to simply provide an interface for accessing the
diagnostic status on-demand.  This patch adds a 2-channel digital input
subdevice with an insn_bits handler to access this information.

Signed-off-by: Chase Southwood <chase.southwood@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_1564.c

index 190b02663bd00870fef388b3d1960c46e0f89c0d..819255b2d67c0118ff4d6596364be263c705ced1 100644 (file)
@@ -157,6 +157,18 @@ static int apci1564_do_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
+static int apci1564_diag_insn_bits(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
+{
+       struct apci1564_private *devpriv = dev->private;
+
+       data[1] = inl(devpriv->amcc_iobase + APCI1564_DO_INT_STATUS_REG) & 3;
+
+       return insn->n;
+}
+
 /*
  * Change-Of-State (COS) interrupt configuration
  *
@@ -373,7 +385,7 @@ static int apci1564_auto_attach(struct comedi_device *dev,
                        dev->irq = pcidev->irq;
        }
 
-       ret = comedi_alloc_subdevices(dev, 5);
+       ret = comedi_alloc_subdevices(dev, 6);
        if (ret)
                return ret;
 
@@ -434,6 +446,15 @@ static int apci1564_auto_attach(struct comedi_device *dev,
        if (ret)
                return ret;
 
+       /* Initialize the diagnostic status subdevice */
+       s = &dev->subdevices[5];
+       s->type = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan = 2;
+       s->maxdata = 1;
+       s->range_table = &range_digital;
+       s->insn_bits = apci1564_diag_insn_bits;
+
        return 0;
 }