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 <jeppe.odgaard@prevas.dk>
This commit is contained in:
parent
e517af4cff
commit
ef867e4c7e
2 changed files with 13 additions and 7 deletions
|
@ -195,11 +195,11 @@ static int spi_mcux_transfer_next_packet(const struct device *dev)
|
||||||
|
|
||||||
status = DSPI_MasterTransferNonBlocking(base, &data->handle, &transfer);
|
status = DSPI_MasterTransferNonBlocking(base, &data->handle, &transfer);
|
||||||
if (status != kStatus_Success) {
|
if (status != kStatus_Success) {
|
||||||
LOG_ERR("Transfer could not start");
|
LOG_ERR("Transfer could not start on %s: %d", dev->name, status);
|
||||||
|
return status == kDSPI_Busy ? -EBUSY : -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status == kStatus_Success ? 0 :
|
return 0;
|
||||||
status == kDSPI_Busy ? -EBUSY : -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spi_mcux_isr(const struct device *dev)
|
static void spi_mcux_isr(const struct device *dev)
|
||||||
|
|
|
@ -81,7 +81,7 @@ struct spi_mcux_data {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static void spi_mcux_transfer_next_packet(const struct device *dev)
|
static int spi_mcux_transfer_next_packet(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct spi_mcux_config *config = dev->config;
|
const struct spi_mcux_config *config = dev->config;
|
||||||
struct spi_mcux_data *data = dev->data;
|
struct spi_mcux_data *data = dev->data;
|
||||||
|
@ -94,7 +94,7 @@ static void spi_mcux_transfer_next_packet(const struct device *dev)
|
||||||
/* nothing left to rx or tx, we're done! */
|
/* nothing left to rx or tx, we're done! */
|
||||||
spi_context_cs_control(&data->ctx, false);
|
spi_context_cs_control(&data->ctx, false);
|
||||||
spi_context_complete(&data->ctx, dev, 0);
|
spi_context_complete(&data->ctx, dev, 0);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer.configFlags = kLPSPI_MasterPcsContinuous |
|
transfer.configFlags = kLPSPI_MasterPcsContinuous |
|
||||||
|
@ -144,8 +144,11 @@ static void spi_mcux_transfer_next_packet(const struct device *dev)
|
||||||
status = LPSPI_MasterTransferNonBlocking(base, &data->handle,
|
status = LPSPI_MasterTransferNonBlocking(base, &data->handle,
|
||||||
&transfer);
|
&transfer);
|
||||||
if (status != kStatus_Success) {
|
if (status != kStatus_Success) {
|
||||||
LOG_ERR("Transfer could not start");
|
LOG_ERR("Transfer could not start on %s: %d", dev->name, status);
|
||||||
|
return status == kStatus_LPSPI_Busy ? -EBUSY : -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spi_mcux_isr(const struct device *dev)
|
static void spi_mcux_isr(const struct device *dev)
|
||||||
|
@ -582,7 +585,10 @@ static int transceive(const struct device *dev,
|
||||||
|
|
||||||
spi_context_cs_control(&data->ctx, true);
|
spi_context_cs_control(&data->ctx, true);
|
||||||
|
|
||||||
spi_mcux_transfer_next_packet(dev);
|
ret = spi_mcux_transfer_next_packet(dev);
|
||||||
|
if (ret) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = spi_context_wait_for_completion(&data->ctx);
|
ret = spi_context_wait_for_completion(&data->ctx);
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue