staging: comedi: rtd520: fix rtd_ao_winsn()
The "comedi range and offset conversions" in this function is incorrect. According to the hardware manual, the DAC registers are defined as: | D15 | D14-D03 | D02 | | D01 | D00 | | Sign | 12-bit data | (see manual) | The extended 'Sign' bit is only used for bipolar ranges to indicate negative 12-bit data values. The current code actually flips the sign for all bipolar data values instead of just munging the value to 2's complement and extending the sign bit. Fix the function to correctly munge the comedi offset binary values into 2's complement and extended the sign when bipolar ranges are specified. For aesthetics, rename this function and tidy it up a bit. Save the readback value after the conversion is complete. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing
Please register or sign in to comment