diff --git a/drivers/spi/spi_nrfx_spi.c b/drivers/spi/spi_nrfx_spi.c index c47fe20323a..97977a69084 100644 --- a/drivers/spi/spi_nrfx_spi.c +++ b/drivers/spi/spi_nrfx_spi.c @@ -172,11 +172,15 @@ static void transfer_next_chunk(struct device *dev) static int transceive(struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) + const struct spi_buf_set *rx_bufs, + bool asynchronous, + struct k_poll_signal *signal) { struct spi_nrfx_data *dev_data = get_dev_data(dev); int error; + spi_context_lock(&dev_data->ctx, asynchronous, signal); + error = configure(dev, spi_cfg); if (error == 0) { dev_data->busy = true; @@ -199,8 +203,7 @@ static int spi_nrfx_transceive(struct device *dev, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) { - spi_context_lock(&get_dev_data(dev)->ctx, false, NULL); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL); } #ifdef CONFIG_SPI_ASYNC @@ -210,8 +213,7 @@ static int spi_nrfx_transceive_async(struct device *dev, const struct spi_buf_set *rx_bufs, struct k_poll_signal *async) { - spi_context_lock(&get_dev_data(dev)->ctx, true, async); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, true, async); } #endif /* CONFIG_SPI_ASYNC */ diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index 1b67788ceef..709694e1a7f 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -211,11 +211,15 @@ static void transfer_next_chunk(struct device *dev) static int transceive(struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) + const struct spi_buf_set *rx_bufs, + bool asynchronous, + struct k_poll_signal *signal) { struct spi_nrfx_data *dev_data = get_dev_data(dev); int error; + spi_context_lock(&dev_data->ctx, asynchronous, signal); + error = configure(dev, spi_cfg); if (error == 0) { dev_data->busy = true; @@ -238,8 +242,7 @@ static int spi_nrfx_transceive(struct device *dev, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) { - spi_context_lock(&get_dev_data(dev)->ctx, false, NULL); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL); } #ifdef CONFIG_SPI_ASYNC @@ -249,8 +252,7 @@ static int spi_nrfx_transceive_async(struct device *dev, const struct spi_buf_set *rx_bufs, struct k_poll_signal *async) { - spi_context_lock(&get_dev_data(dev)->ctx, true, async); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, true, async); } #endif /* CONFIG_SPI_ASYNC */ diff --git a/drivers/spi/spi_nrfx_spis.c b/drivers/spi/spi_nrfx_spis.c index f95ba5b22d2..90c80bc3097 100644 --- a/drivers/spi/spi_nrfx_spis.c +++ b/drivers/spi/spi_nrfx_spis.c @@ -144,11 +144,15 @@ static void prepare_for_transfer(struct device *dev) static int transceive(struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) + const struct spi_buf_set *rx_bufs, + bool asynchronous, + struct k_poll_signal *signal) { struct spi_nrfx_data *dev_data = get_dev_data(dev); int error; + spi_context_lock(&dev_data->ctx, asynchronous, signal); + error = configure(dev, spi_cfg); if (error != 0) { /* Invalid configuration. */ @@ -178,8 +182,7 @@ static int spi_nrfx_transceive(struct device *dev, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) { - spi_context_lock(&get_dev_data(dev)->ctx, false, NULL); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL); } #ifdef CONFIG_SPI_ASYNC @@ -189,8 +192,7 @@ static int spi_nrfx_transceive_async(struct device *dev, const struct spi_buf_set *rx_bufs, struct k_poll_signal *async) { - spi_context_lock(&get_dev_data(dev)->ctx, true, async); - return transceive(dev, spi_cfg, tx_bufs, rx_bufs); + return transceive(dev, spi_cfg, tx_bufs, rx_bufs, true, async); } #endif /* CONFIG_SPI_ASYNC */