Commit 97f4289a authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: drivers: use comedi_dio_update_state() for simple cases

Use comedi_dio_update_state() to handle the boilerplate code to update
the subdevice s->state for simple cases where the hardware is updated
when any channel is modified.

Also, fix a bug in the amplc_pc263 and amplc_pci263 drivers where the
current state is not returned in data[1].
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 77e9487b
......@@ -260,18 +260,13 @@ static int apci1564_do_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, devpriv->i_IobaseAmcc + APCI1564_DIGITAL_OP +
APCI1564_DIGITAL_OP_RW);
}
data[1] = s->state;
......
......@@ -623,16 +623,11 @@ static int apci3200_do_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
struct addi_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(devpriv->i_IobaseAddon) & 0xf;
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, devpriv->i_IobaseAddon);
}
data[1] = s->state;
......
......@@ -90,16 +90,10 @@ static int apci1516_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inw(dev->iobase + APCI1516_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + APCI1516_DO_REG);
}
data[1] = s->state;
......
......@@ -57,16 +57,10 @@ static int apci2032_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(dev->iobase + APCI2032_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, dev->iobase + APCI2032_DO_REG);
}
data[1] = s->state;
......
......@@ -50,16 +50,10 @@ static int apci2200_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inw(dev->iobase + APCI2200_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + APCI2200_DO_REG);
}
data[1] = s->state;
......
......@@ -161,16 +161,10 @@ static int apci3501_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(dev->iobase + APCI3501_DO_REG);
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, dev->iobase + APCI3501_DO_REG);
}
data[1] = s->state;
......
......@@ -664,16 +664,10 @@ static int apci3xxx_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
s->state = inl(dev->iobase + 48) & 0xf;
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, dev->iobase + 48);
}
data[1] = s->state;
......
......@@ -141,15 +141,8 @@ static int pci6208_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + PCI6208_DIO);
}
data[1] = s->state;
......
......@@ -112,21 +112,10 @@ static int adl_pci7x3x_do_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
unsigned long reg = (unsigned long)s->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outl(s->state, dev->iobase + reg);
}
/*
* NOTE: The output register is not readable.
* This returned state will not be correct until all the
* outputs have been updated.
*/
data[1] = s->state;
return insn->n;
......
......@@ -813,15 +813,8 @@ static int pci9111_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + PCI9111_DIO_REG);
}
data[1] = s->state;
......
......@@ -671,13 +671,12 @@ static int pci9118_insn_bits_di(struct comedi_device *dev,
static int pci9118_insn_bits_do(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data))
outl(s->state & 0x0f, dev->iobase + PCI9118_DO);
}
data[1] = s->state;
return insn->n;
......
......@@ -544,18 +544,14 @@ static int pci171x_insn_bits_di(struct comedi_device *dev,
return insn->n;
}
/*
==============================================================================
*/
static int pci171x_insn_bits_do(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + PCI171x_DO);
}
data[1] = s->state;
return insn->n;
......
......@@ -205,19 +205,16 @@ static int pci1723_dio_insn_config(struct comedi_device *dev,
return insn->n;
}
/*
digital i/o bits read/write
*/
static int pci1723_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + PCI1723_WRITE_DIGITAL_OUTPUT_CMD);
}
data[1] = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA);
return insn->n;
}
......
......@@ -448,45 +448,39 @@ static int pci_dio_insn_bits_di_w(struct comedi_device *dev,
return insn->n;
}
/*
==============================================================================
*/
static int pci_dio_insn_bits_do_b(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
for (i = 0; i < d->regs; i++)
outb((s->state >> (8 * i)) & 0xff,
dev->iobase + d->addr + i);
}
data[1] = s->state;
return insn->n;
}
/*
==============================================================================
*/
static int pci_dio_insn_bits_do_w(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
const struct diosubd_data *d = (const struct diosubd_data *)s->private;
int i;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
for (i = 0; i < d->regs; i++)
outw((s->state >> (16 * i)) & 0xffff,
dev->iobase + d->addr + 2 * i);
}
data[1] = s->state;
return insn->n;
......@@ -641,12 +635,10 @@ static int pci1760_insn_bits_di(struct comedi_device *dev,
return insn->n;
}
/*
==============================================================================
*/
static int pci1760_insn_bits_do(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
int ret;
unsigned char omb[4] = {
......@@ -657,14 +649,13 @@ static int pci1760_insn_bits_do(struct comedi_device *dev,
};
unsigned char imb[4];
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
omb[0] = s->state;
ret = pci1760_mbxrequest(dev, omb, imb);
if (!ret)
return ret;
}
data[1] = s->state;
return insn->n;
......
......@@ -45,9 +45,7 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
if (comedi_dio_update_state(s, data)) {
outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
outb((s->state >> 8) & 0xff,
dev->iobase + AIO_IIRO_16_RELAY_8_15);
......
......@@ -57,17 +57,16 @@ static const struct pc263_board pc263_boards[] = {
static int pc263_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
/* Write out the new digital output lines */
outb(s->state & 0xFF, dev->iobase);
outb(s->state >> 8, dev->iobase + 1);
if (comedi_dio_update_state(s, data)) {
outb(s->state & 0xff, dev->iobase);
outb((s->state >> 8) & 0xff, dev->iobase + 1);
}
data[1] = s->state;
return insn->n;
}
......
......@@ -44,17 +44,16 @@ The state of the outputs can be read.
static int pci263_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
/* Write out the new digital output lines */
outb(s->state & 0xFF, dev->iobase);
outb(s->state >> 8, dev->iobase + 1);
if (comedi_dio_update_state(s, data)) {
outb(s->state & 0xff, dev->iobase);
outb((s->state >> 8) & 0xff, dev->iobase + 1);
}
data[1] = s->state;
return insn->n;
}
......
......@@ -325,14 +325,11 @@ static int das16cs_ao_rinsn(struct comedi_device *dev,
static int das16cs_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + DAS16CS_DIO);
}
data[1] = inw(dev->iobase + DAS16CS_DIO);
......
......@@ -3490,18 +3490,15 @@ static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
return insn->n;
}
static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
static int do_wbits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct pcidas64_private *devpriv = dev->private;
data[0] &= 0xf;
/* zero bits we are going to change */
s->state &= ~data[0];
/* set new bits */
s->state |= data[0] & data[1];
writeb(s->state, devpriv->dio_counter_iobase + DO_REG);
if (comedi_dio_update_state(s, data))
writeb(s->state, devpriv->dio_counter_iobase + DO_REG);
data[1] = s->state;
......@@ -3526,14 +3523,14 @@ static int dio_60xx_config_insn(struct comedi_device *dev,
return insn->n;
}
static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
static int dio_60xx_wbits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct pcidas64_private *devpriv = dev->private;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
writeb(s->state,
devpriv->dio_counter_iobase + DIO_DATA_60XX_REG);
}
......
......@@ -40,17 +40,11 @@ Configuration Options: not applicable, uses comedi PCI auto config
static int contec_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + PIO1616L_DO_REG);
}
data[1] = s->state;
......
......@@ -952,15 +952,8 @@ static int das16_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outb(s->state, dev->iobase + DAS16_DIO_REG);
}
data[1] = s->state;
......
......@@ -630,13 +630,9 @@ static int das800_do_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
struct das800_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
unsigned long irq_flags;
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data)) {
devpriv->do_bits = s->state << 4;
spin_lock_irqsave(&dev->spinlock, irq_flags);
......
......@@ -528,23 +528,23 @@ static int dt2801_ao_insn_write(struct comedi_device *dev,
static int dt2801_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)
{
int which = 0;
if (s == &dev->subdevices[3])
which = 1;
int which = (s == &dev->subdevices[3]) ? 1 : 0;
unsigned int val;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
dt2801_writecmd(dev, DT_C_WRITE_DIG);
dt2801_writedata(dev, which);
dt2801_writedata(dev, s->state);
}
dt2801_writecmd(dev, DT_C_READ_DIG);
dt2801_writedata(dev, which);
dt2801_readdata(dev, data + 1);
dt2801_readdata(dev, &val);
data[1] = val;
return insn->n;
}
......
......@@ -353,11 +353,11 @@ static int dt2811_di_insn_bits(struct comedi_device *dev,
static int dt2811_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
s->state &= ~data[0];
s->state |= data[0] & data[1];
outb(s->state, dev->iobase + DT2811_DIO);
if (comedi_dio_update_state(s, data))
outb(s->state, dev->iobase + DT2811_DIO);
data[1] = s->state;
......
......@@ -967,14 +967,12 @@ static int dt282x_ao_cancel(struct comedi_device *dev,
static int dt282x_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + DT2821_DIODAT);
}
data[1] = inw(dev->iobase + DT2821_DIODAT);
return insn->n;
......
......@@ -665,13 +665,12 @@ static int dt3k_dio_insn_config(struct comedi_device *dev,
static int dt3k_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[1] & data[0];
if (comedi_dio_update_state(s, data))
dt3k_writesingle(dev, SUBS_DOUT, 0, s->state);
}
data[1] = dt3k_readsingle(dev, SUBS_DIN, 0, 0);
return insn->n;
......
......@@ -580,15 +580,8 @@ static int dt9812_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
dt9812_digital_out(dev, s->state);
}
data[1] = s->state;
......
......@@ -147,33 +147,23 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
return insn->n;
}
/* digital output bit interface */
static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct dyna_pci10xx_private *devpriv = dev->private;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit.
* s->state contains the previous write data
*/
mutex_lock(&devpriv->mutex);
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data)) {
smp_mb();
outw_p(s->state, devpriv->BADR3);
udelay(10);
}
/*
* On return, data[1] contains the value of the digital
* input and output lines. We just return the software copy of the
* output values if it was a purely digital output subdevice.
*/
data[1] = s->state;
mutex_unlock(&devpriv->mutex);
return insn->n;
}
......
......@@ -348,18 +348,13 @@ static int icp_multi_insn_bits_di(struct comedi_device *dev,
static int icp_multi_insn_bits_do(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
struct icp_multi_private *devpriv = dev->private;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
printk(KERN_DEBUG "Digital outputs = %4x \n", s->state);
if (comedi_dio_update_state(s, data))
writew(s->state, devpriv->io_addr + ICP_MULTI_DO);
}
data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
......
......@@ -163,11 +163,11 @@ static int multiq3_di_insn_bits(struct comedi_device *dev,
static int multiq3_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outw(s->state, dev->iobase + MULTIQ3_DIGOUT_PORT);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + MULTIQ3_DIGOUT_PORT);
data[1] = s->state;
......
......@@ -136,20 +136,15 @@ static int ni_670x_ao_rinsn(struct comedi_device *dev,
static int ni_670x_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 ni_670x_private *devpriv = dev->private;
void __iomem *io_addr = devpriv->mite->daq_io_addr +
DIO_PORT0_DATA_OFFSET;
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
writel(s->state, io_addr);
}
data[1] = readl(io_addr);
......
......@@ -233,13 +233,11 @@ static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
static int atao_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + ATAO_DOUT);
}
data[1] = inw(dev->iobase + ATAO_DIN);
......
......@@ -558,13 +558,12 @@ static int atmio16d_ao_insn_write(struct comedi_device *dev,
static int atmio16d_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] | data[1]);
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + MIO_16_DIG_OUT_REG);
}
data[1] = inw(dev->iobase + MIO_16_DIG_IN_REG);
return insn->n;
......
......@@ -657,15 +657,14 @@ static int ni_pcidio_insn_config(struct comedi_device *dev,
static int ni_pcidio_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 nidio96_private *devpriv = dev->private;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
if (comedi_dio_update_state(s, data))
writel(s->state, devpriv->mite->daq_io_addr + Port_IO(0));
}
data[1] = readl(devpriv->mite->daq_io_addr + Port_IO(0));
return insn->n;
......
......@@ -509,19 +509,16 @@ static int pcl812_di_insn_bits(struct comedi_device *dev,
return insn->n;
}
/*
==============================================================================
*/
static int pcl812_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
if (comedi_dio_update_state(s, data)) {
outb(s->state & 0xff, dev->iobase + PCL812_DO_LO);
outb((s->state >> 8), dev->iobase + PCL812_DO_HI);
}
data[1] = s->state;
return insn->n;
......
......@@ -418,21 +418,15 @@ static int pcl818_di_insn_bits(struct comedi_device *dev,
return insn->n;
}
/*
==============================================================================
DIGITAL OUTPUT MODE0, 818 cards
only one sample per call is supported
*/
static int pcl818_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
struct comedi_insn *insn,
unsigned int *data)
{
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outb(s->state & 0xff, dev->iobase + PCL818_DO_LO);
outb((s->state >> 8), dev->iobase + PCL818_DO_HI);
if (comedi_dio_update_state(s, data)) {
outb(s->state & 0xff, dev->iobase + PCL818_DO_LO);
outb((s->state >> 8), dev->iobase + PCL818_DO_HI);
}
data[1] = s->state;
......
......@@ -690,18 +690,12 @@ static int daqp_do_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
struct daqp_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
if (devpriv->stop)
return -EIO;
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
outb(s->state, dev->iobase + DAQP_DIGITAL_IO);
}
data[1] = s->state;
......
......@@ -1217,15 +1217,9 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
struct rtd_private *devpriv = dev->private;
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data))
writew(s->state & 0xff, devpriv->las0 + LAS0_DIO0);
}
data[1] = readw(devpriv->las0 + LAS0_DIO0) & 0xff;
......
......@@ -267,13 +267,7 @@ static int rti800_do_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int mask = data[0];
unsigned int bits = data[1];
if (mask) {
s->state &= ~mask;
s->state |= (bits & mask);
if (comedi_dio_update_state(s, data)) {
/* Outputs are inverted... */
outb(s->state ^ 0xff, dev->iobase + RTI800_DO);
}
......
......@@ -499,14 +499,11 @@ static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
static int s526_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)
{
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
if (comedi_dio_update_state(s, data))
outw(s->state, dev->iobase + REG_DIO);
}
data[1] = inw(dev->iobase + REG_DIO) & 0xff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment