Skip to content

Commit 9413b8d

Browse files
khoa-nguyen-18nashif
authored andcommitted
drivers: spi: Add condition to check buffer pointer
Add condition to check context buffer pointer for Renesas RA SPI and SPI_B driver Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
1 parent 7f78eb7 commit 9413b8d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/spi/spi_b_renesas_ra8.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ static int transceive(const struct device *dev, const struct spi_config *config,
313313

314314
spi_context_cs_control(&data->ctx, true);
315315

316+
if ((!spi_context_tx_buf_on(&data->ctx)) && (!spi_context_rx_buf_on(&data->ctx))) {
317+
/* If current buffer has no data, do nothing */
318+
goto end;
319+
}
320+
316321
#ifdef CONFIG_SPI_B_INTERRUPT
317322
spi_bit_width_t spi_width =
318323
(spi_bit_width_t)(SPI_WORD_SIZE_GET(data->ctx.config->operation) - 1);

drivers/spi/spi_renesas_ra.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ static int transceive(const struct device *dev, const struct spi_config *config,
355355

356356
spi_context_cs_control(&data->ctx, true);
357357

358+
if ((!spi_context_tx_buf_on(&data->ctx)) && (!spi_context_rx_buf_on(&data->ctx))) {
359+
/* If current buffer has no data, do nothing */
360+
goto end;
361+
}
362+
358363
#ifdef CONFIG_SPI_INTERRUPT
359364
if (data->ctx.rx_len == 0) {
360365
data->data_len = spi_context_is_slave(&data->ctx)

0 commit comments

Comments
 (0)