/* Called from the 'insn_write' function to perform a single write.  */
static void pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data)
/* Called from the 'insn_write' function to perform a single write.  */
static void pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data)
{
	unsigned short mangled;
	devpriv->ao_readback[chan] = data;
	outw(1 << chan, dev->iobase + PCI224_DACCEN);
	devpriv->daccon = COMBINE(devpriv->daccon, devpriv->hwrange[range],
				  (PCI224_DACCON_POLAR_MASK |
				   PCI224_DACCON_VREF_MASK));
	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
	     dev->iobase + PCI224_DACCON);
	mangled = (unsigned short)data << (16 - thisboard->ao_bits);
	if ((devpriv->daccon & PCI224_DACCON_POLAR_MASK) ==
	    PCI224_DACCON_POLAR_BI) {
		mangled ^= 0x8000;
	}
	outw(mangled, dev->iobase + PCI224_DACDATA);
	inw(dev->iobase + PCI224_SOFTTRIG);
}