drivers: spim: Move the length check to beginning

This check has to be done independent of whether RAM is used for buffers
or not and depends on device maximum length property.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
Chaitanya Tata 2023-08-25 17:45:17 +05:30 committed by Carles Cufí
commit 0a1eff8d97

View file

@ -312,6 +312,11 @@ static void transfer_next_chunk(const struct device *dev)
nrfx_spim_xfer_desc_t xfer;
nrfx_err_t result;
const uint8_t *tx_buf = ctx->tx_buf;
if (chunk_len > dev_config->max_chunk_len) {
chunk_len = dev_config->max_chunk_len;
}
#if (CONFIG_SPI_NRFX_RAM_BUFFER_SIZE > 0)
if (spi_context_tx_buf_on(ctx) &&
!nrf_dma_accessible_check(&dev_config->spim.p_reg, tx_buf)) {
@ -323,10 +328,6 @@ static void transfer_next_chunk(const struct device *dev)
tx_buf = dev_data->buffer;
}
#endif
if (chunk_len > dev_config->max_chunk_len) {
chunk_len = dev_config->max_chunk_len;
}
dev_data->chunk_len = chunk_len;
xfer.p_tx_buffer = tx_buf;