Skip to content

Commit ef867e4

Browse files
Jeppe Odgaardcarlescufi
authored andcommitted
drivers: spi: align dspi and lpspi spi_mcux_transfer_next_packet
Add return code to lpspi spi_mcux_transfer_next_packet and print the kStatus_* return code since it information is lost when translated to errno. Signed-off-by: Jeppe Odgaard <[email protected]>
1 parent e517af4 commit ef867e4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

drivers/spi/spi_mcux_dspi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ static int spi_mcux_transfer_next_packet(const struct device *dev)
195195

196196
status = DSPI_MasterTransferNonBlocking(base, &data->handle, &transfer);
197197
if (status != kStatus_Success) {
198-
LOG_ERR("Transfer could not start");
198+
LOG_ERR("Transfer could not start on %s: %d", dev->name, status);
199+
return status == kDSPI_Busy ? -EBUSY : -EINVAL;
199200
}
200201

201-
return status == kStatus_Success ? 0 :
202-
status == kDSPI_Busy ? -EBUSY : -EINVAL;
202+
return 0;
203203
}
204204

205205
static void spi_mcux_isr(const struct device *dev)

drivers/spi/spi_mcux_lpspi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct spi_mcux_data {
8181
#endif
8282
};
8383

84-
static void spi_mcux_transfer_next_packet(const struct device *dev)
84+
static int spi_mcux_transfer_next_packet(const struct device *dev)
8585
{
8686
const struct spi_mcux_config *config = dev->config;
8787
struct spi_mcux_data *data = dev->data;
@@ -94,7 +94,7 @@ static void spi_mcux_transfer_next_packet(const struct device *dev)
9494
/* nothing left to rx or tx, we're done! */
9595
spi_context_cs_control(&data->ctx, false);
9696
spi_context_complete(&data->ctx, dev, 0);
97-
return;
97+
return 0;
9898
}
9999

100100
transfer.configFlags = kLPSPI_MasterPcsContinuous |
@@ -144,8 +144,11 @@ static void spi_mcux_transfer_next_packet(const struct device *dev)
144144
status = LPSPI_MasterTransferNonBlocking(base, &data->handle,
145145
&transfer);
146146
if (status != kStatus_Success) {
147-
LOG_ERR("Transfer could not start");
147+
LOG_ERR("Transfer could not start on %s: %d", dev->name, status);
148+
return status == kStatus_LPSPI_Busy ? -EBUSY : -EINVAL;
148149
}
150+
151+
return 0;
149152
}
150153

151154
static void spi_mcux_isr(const struct device *dev)
@@ -582,7 +585,10 @@ static int transceive(const struct device *dev,
582585

583586
spi_context_cs_control(&data->ctx, true);
584587

585-
spi_mcux_transfer_next_packet(dev);
588+
ret = spi_mcux_transfer_next_packet(dev);
589+
if (ret) {
590+
goto out;
591+
}
586592

587593
ret = spi_context_wait_for_completion(&data->ctx);
588594
out:

0 commit comments

Comments
 (0)