spi: sc18is602: don't consider the chip select byte in sc18is602_check_transfer
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 20 May 2021 13:12:37 +0000 (16:12 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 21 May 2021 12:13:33 +0000 (13:13 +0100)
commitbda7db1d952c3ff7c24c11bc295aa72aaeb98451
tree8bbffe00047ccee7aae367f8ba0fbe51885b4fe5
parentc37fe6aff89cb0d842993fe2f69e48bf3ebe0ab0
spi: sc18is602: don't consider the chip select byte in sc18is602_check_transfer

For each spi_message, the sc18is602 I2C-to-SPI bridge driver checks the
length of each spi_transfer against 200 (the size of the chip's internal
buffer) minus hw->tlen (the number of bytes transferred so far).

The first byte of the transferred data is the Function ID (the SPI
slave's chip select) and as per the documentation of the chip:
https://www.nxp.com/docs/en/data-sheet/SC18IS602B.pdf
the data buffer is up to 200 bytes deep _without_ accounting for the
Function ID byte.

However, in sc18is602_txrx(), the driver keeps the Function ID as part
of the buffer, and increments hw->tlen from 0 to 1. Combined with the
check in sc18is602_check_transfer, this prevents us from issuing a
transfer that has exactly 200 bytes in size, but only 199.

Adjust the check function to reflect that the Function ID is not part of
the 200 byte deep data buffer.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20210520131238.2903024-2-olteanv@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sc18is602.c