Skip to content

Commit 3780f9d

Browse files
Raffael Rostagnokartben
authored andcommitted
drivers: spi: esp32: Fix NULL buffers condition
Fix condition in which both TX and RX buffers are NULL inside spi_buf_set structures. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent bb81347 commit 3780f9d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/spi/spi_esp32_spim.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ static int transceive(const struct device *dev,
413413
{
414414
const struct spi_esp32_config *cfg = dev->config;
415415
struct spi_esp32_data *data = dev->data;
416-
int ret;
417-
418-
if (!tx_bufs && !rx_bufs) {
419-
return 0;
420-
}
416+
int ret = 0;
421417

422418
#ifndef CONFIG_SPI_ESP32_INTERRUPT
423419
if (asynchronous) {
@@ -429,13 +425,17 @@ static int transceive(const struct device *dev,
429425

430426
data->dfs = spi_esp32_get_frame_size(spi_cfg);
431427

428+
spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, data->dfs);
429+
430+
if (data->ctx.tx_buf == NULL && data->ctx.rx_buf == NULL) {
431+
goto done;
432+
}
433+
432434
ret = spi_esp32_configure(dev, spi_cfg);
433435
if (ret) {
434436
goto done;
435437
}
436438

437-
spi_context_buffers_setup(&data->ctx, tx_bufs, rx_bufs, data->dfs);
438-
439439
spi_context_cs_control(&data->ctx, true);
440440

441441
#ifdef CONFIG_SPI_ESP32_INTERRUPT

0 commit comments

Comments
 (0)