summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-10-25 22:11:23 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-26 16:20:03 (GMT)
commitec6521a20431723ff4fa15fdefb386184075baa2 (patch)
tree103afd7a5226bee1e1eb062cd1dcc57b1643a5bc /drivers
parent5e177c453f3dd9e43c7a407f46f8649c47a3614d (diff)
downloadlinux-fsl-qoriq-ec6521a20431723ff4fa15fdefb386184075baa2.tar.xz
staging: comedi: me_daq: cleanup me_dio_insn_bits()
This function only needs to update the output channel state when the 'mask' (data[0]) indicates that the state is changing. It's also supposed to return the state for all the input and output channels in data[1]. This function appears to work correctly but it's coded quite differently form the other comedi drivers. Rework the function so it follows the normal form. Also, use a couple local variables for the mmio addresses used to read/write the dio ports. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/me_daq.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c
index 450bee0..823fbf9 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -229,33 +229,40 @@ static int me_dio_insn_config(struct comedi_device *dev,
return insn->n;
}
-/* Digital instant input/outputs */
static int me_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+ struct comedi_insn *insn,
+ unsigned int *data)
{
struct me_private_data *dev_private = dev->private;
+ void __iomem *mmio_porta = dev_private->me_regbase + ME_DIO_PORT_A;
+ void __iomem *mmio_portb = dev_private->me_regbase + ME_DIO_PORT_B;
unsigned int mask = data[0];
+ unsigned int bits = data[1];
+ unsigned int val;
+
+ mask &= s->io_bits; /* only update the COMEDI_OUTPUT channels */
+ if (mask) {
+ s->state &= ~mask;
+ s->state |= (bits & mask);
+
+ if (mask & 0x0000ffff)
+ writew((s->state & 0xffff), mmio_porta);
+ if (mask & 0xffff0000)
+ writew(((s->state >> 16) & 0xffff), mmio_portb);
+ }
- s->state &= ~mask;
- s->state |= (mask & data[1]);
+ if (s->io_bits & 0x0000ffff)
+ val = s->state & 0xffff;
+ else
+ val = readw(mmio_porta);
- mask &= s->io_bits;
- if (mask & 0x0000ffff) { /* Port A */
- writew((s->state & 0xffff),
- dev_private->me_regbase + ME_DIO_PORT_A);
- } else {
- data[1] &= ~0x0000ffff;
- data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_A);
- }
+ if (s->io_bits & 0xffff0000)
+ val |= (s->state & 0xffff0000);
+ else
+ val |= (readw(mmio_portb) << 16);
- if (mask & 0xffff0000) { /* Port B */
- writew(((s->state >> 16) & 0xffff),
- dev_private->me_regbase + ME_DIO_PORT_B);
- } else {
- data[1] &= ~0xffff0000;
- data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_B) << 16;
- }
+ data[1] = val;
return insn->n;
}