yangsong8-a1 opened a new pull request, #22064:
URL: https://github.com/apache/nuttx/pull/22064
## Summary
Two gaps left in spi_transfer() after #21069 and #21817:
- A sequence with keepcs was still handed to the lower-half
exchangeseqs(). Lower halves de-select at the end of the sequence,
so CS was dropped even though the caller asked to keep it (the vhost
SPI backend sets keepcs). Such sequences now use the generic loop.
- The generic loop ignored the return value of SPI_EXCHANGE(), so a
failed transfer was reported as OK. It now stops and returns the
error, and the existing abort path de-selects.
## Impact
drivers/spi/spi_transfer.c only. No API change.
## Testing
Ubuntu 22.04, gcc 13.1, sim:nsh with CONFIG_SPI=y. A test program
registers a fake SPI lower half whose exchangeseqs() handles the whole
sequence and de-selects (or returns -ENOTSUP), and whose exchange() can
be made to fail, then calls spi_transfer() with one transfer:
master:
keepcs=0 ret=0 exchangeseqs=1 exchange=0 cs_after=0
keepcs=1 ret=0 exchangeseqs=1 exchange=0 cs_after=0
keepcs=1, exchange fails ret=0 exchangeseqs=1 exchange=0 cs_after=0
ENOTSUP, exchange fails ret=0 exchangeseqs=1 exchange=1 cs_after=0
This PR:
keepcs=0 ret=0 exchangeseqs=1 exchange=0 cs_after=0
keepcs=1 ret=0 exchangeseqs=0 exchange=1 cs_after=1
keepcs=1, exchange fails ret=-5 exchangeseqs=0 exchange=1 cs_after=0
ENOTSUP, exchange fails ret=-5 exchangeseqs=1 exchange=1 cs_after=0
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]