staging: comedi: addi_apci_3501: rewrite the analog output support

Currently the analog output subdevice has two support functions:
  (*insn_config) - i_APCI3501_ConfigAnalogOutput()
  (*insn_write)  - i_APCI3501_WriteAnalogOutput()

The (*insn_config) function is used to configure the analog outputs
in either bipolar or unipolar mode. This function abuses the comedi
API since it treats the data[0] value as a parameter instead of as
the config "instruction".

The (*insn_write) function then writes a single value to the desired
analog output channel after doing some sanity checking on the channel
number. The sanity checking is not required since the comedi core has
already done it. Also, the (*insn_write) functions are supposed to
write all the data, indicated by insn->n, to the channel not just a
single value.

Rewrite the support code so it works properly with the comedi API.

The bipolar/unipolar configuration can be determine in the (*insn_write)
by checking the passed insn->chanspec.

Since the unipolar configuration only has 13-bit resolution, we need
to check that the data is in range because the subdevice 'maxdata' is
set to 14-bits for the bipolar mode. If the data is out of range,
output a dev_warn() and return -EINVAL.

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>
2 files changed