• Ian Abbott's avatar
    staging: comedi: dt2815: fix writing hi byte of analog output · ed87d33d
    Ian Abbott authored
    The DT2815 analog output command is 16 bits wide, consisting of the
    12-bit sample value in bits 15 to 4, the channel number in bits 3 to 1,
    and a voltage or current selector in bit 0.  Both bytes of the 16-bit
    command need to be written in turn to a single 8-bit data register.
    However, the driver currently only writes the low 8-bits.  It is broken
    and appears to have always been broken.
    
    Electronic copies of the DT2815 User's Manual seem impossible to find
    online, but looking at the source code, a best guess for the sequence
    the driver intended to use to write the analog output command is as
    follows:
    
    1. Wait for the status register to read 0x00.
    2. Write the low byte of the command to the data register.
    3. Wait for the status register to read 0x80.
    4. Write the high byte of the command to the data register.
    
    Step 4 is missing from the driver.  Add step 4 to (hopefully) fix the
    driver.
    
    Also add a "FIXME" comment about setting bit 0 of the low byte of the
    command.  Supposedly, it is used to choose between voltage output and
    current output, but the current driver always sets it to 1.
    Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200406142015.126982-1-abbotti@mev.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    ed87d33d
dt2815.c 5.76 KB