Skip to content

Commit 4adc408

Browse files
Mikkel Jakobsenjhedberg
authored andcommitted
drivers: spi: spi_mcux_dspi: fix missing context unlock on busy bus
Error codes from DSPI_MasterTransferNonBlocking are now handled in tranceive to ensure that the context is unlocked when an busy bus is detected. Signed-off-by: Mikkel Jakobsen <[email protected]>
1 parent 55eb4a1 commit 4adc408

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/spi/spi_mcux_dspi.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct spi_mcux_data {
2929
size_t transfer_len;
3030
};
3131

32-
static void spi_mcux_transfer_next_packet(struct device *dev)
32+
static int spi_mcux_transfer_next_packet(struct device *dev)
3333
{
3434
const struct spi_mcux_config *config = dev->config->config_info;
3535
struct spi_mcux_data *data = dev->driver_data;
@@ -42,7 +42,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev)
4242
/* nothing left to rx or tx, we're done! */
4343
spi_context_cs_control(&data->ctx, false);
4444
spi_context_complete(&data->ctx, 0);
45-
return;
45+
return 0;
4646
}
4747

4848
transfer.configFlags = kDSPI_MasterCtar0 | kDSPI_MasterPcsContinuous |
@@ -93,6 +93,9 @@ static void spi_mcux_transfer_next_packet(struct device *dev)
9393
if (status != kStatus_Success) {
9494
LOG_ERR("Transfer could not start");
9595
}
96+
97+
return status == kStatus_Success ? 0 :
98+
status == kDSPI_Busy ? -EBUSY : -EINVAL;
9699
}
97100

98101
static void spi_mcux_isr(void *arg)
@@ -209,7 +212,10 @@ static int transceive(struct device *dev,
209212

210213
spi_context_cs_control(&data->ctx, true);
211214

212-
spi_mcux_transfer_next_packet(dev);
215+
ret = spi_mcux_transfer_next_packet(dev);
216+
if (ret) {
217+
goto out;
218+
}
213219

214220
ret = spi_context_wait_for_completion(&data->ctx);
215221
out:

0 commit comments

Comments
 (0)