drivers: spi: stm32: add error checking to polled mode
With some other issues in polled mode now resolved, add error handling and report a valid error status when releasing the context. Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
This commit is contained in:
parent
d5ee0cfbf9
commit
4298772248
1 changed files with 6 additions and 4 deletions
|
@ -305,7 +305,6 @@ static int transceive(struct spi_config *config,
|
||||||
|
|
||||||
ret = spi_context_wait_for_completion(&data->ctx);
|
ret = spi_context_wait_for_completion(&data->ctx);
|
||||||
#else
|
#else
|
||||||
ret = 0; /* FIXME: add error checking. */
|
|
||||||
do {
|
do {
|
||||||
/* Keep transmitting NOP data until RX data left */
|
/* Keep transmitting NOP data until RX data left */
|
||||||
if ((spi_context_tx_on(&data->ctx) ||
|
if ((spi_context_tx_on(&data->ctx) ||
|
||||||
|
@ -318,13 +317,16 @@ static int transceive(struct spi_config *config,
|
||||||
LL_SPI_IsActiveFlag_RXNE(spi)) {
|
LL_SPI_IsActiveFlag_RXNE(spi)) {
|
||||||
spi_stm32_receive(spi, data);
|
spi_stm32_receive(spi, data);
|
||||||
}
|
}
|
||||||
} while (spi_context_tx_on(&data->ctx) ||
|
|
||||||
spi_context_rx_on(&data->ctx));
|
ret = spi_stm32_get_err(spi);
|
||||||
|
} while (!ret &&
|
||||||
|
(spi_context_tx_on(&data->ctx) ||
|
||||||
|
spi_context_rx_on(&data->ctx)));
|
||||||
|
|
||||||
spi_stm32_complete(data, spi, ret);
|
spi_stm32_complete(data, spi, ret);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spi_context_release(&data->ctx, 0);
|
spi_context_release(&data->ctx, ret);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SYS_LOG_ERR("error mask 0x%x", ret);
|
SYS_LOG_ERR("error mask 0x%x", ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue