• Haikun Wang's avatar
    spi: spi-fsl-dspi: Change the way of increasing spi_message->actual_length · c042af95
    Haikun Wang authored
    In current driver, we increase actual_length in the following way:
    message->actual_length += dspi_xxx_transfer()
    It has two defects.
    First, transmitting maybe in process when the function call finished and
    we don't know the transmitting result in this moment.
    Secondly, the last sentence in function before returning is accessing the
    SPI register and trigger the data transmitting. If we enable interrupt,
    interrupt may be generated before function return and we also have the same
    sentence "message->actual_length += dspi_xxx_transfer()"
    in the IRQ handler.
    And usually dspi_xxx_transfer will trigger a new IRQ.
    The original dspi_xxx_transfer call may return when no new IRQ generate.
    This may mess the variable spi_message->actual_length.
    Now we increase the variable in the IRQ handler and only when we get the
    TCF or EOQ interrupt
    And we get the transmitted data length from the SPI transfer counter
    instead of the function return value.
    Signed-off-by: default avatarHaikun Wang <haikun.wang@freescale.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    c042af95
spi-fsl-dspi.c 18.8 KB