spi: Only call transfer_one() if we have buffers to transfer
Client drivers such as the ChomeOS EC driver sometimes use transfers with no buffers and only a delay specified in order to allow a delay after the assertion of /CS. Rather than require controller drivers handle this noop case gracefully put checks in the core to ensure that we don't call into the controller for such transfers. Reported-by: Addy Ke <addy.ke@rock-chips.com> Tested-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
7d1311b93e
commit
38ec10f60d
1 changed files with 25 additions and 17 deletions
|
@ -789,6 +789,7 @@ static int spi_transfer_one_message(struct spi_master *master,
|
||||||
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
|
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
|
||||||
trace_spi_transfer_start(msg, xfer);
|
trace_spi_transfer_start(msg, xfer);
|
||||||
|
|
||||||
|
if (xfer->tx_buf || xfer->rx_buf) {
|
||||||
reinit_completion(&master->xfer_completion);
|
reinit_completion(&master->xfer_completion);
|
||||||
|
|
||||||
ret = master->transfer_one(master, msg->spi, xfer);
|
ret = master->transfer_one(master, msg->spi, xfer);
|
||||||
|
@ -808,9 +809,16 @@ static int spi_transfer_one_message(struct spi_master *master,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms == 0) {
|
if (ms == 0) {
|
||||||
dev_err(&msg->spi->dev, "SPI transfer timed out\n");
|
dev_err(&msg->spi->dev,
|
||||||
|
"SPI transfer timed out\n");
|
||||||
msg->status = -ETIMEDOUT;
|
msg->status = -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (xfer->len)
|
||||||
|
dev_err(&msg->spi->dev,
|
||||||
|
"Bufferless transfer has length %u\n",
|
||||||
|
xfer->len);
|
||||||
|
}
|
||||||
|
|
||||||
trace_spi_transfer_stop(msg, xfer);
|
trace_spi_transfer_stop(msg, xfer);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue