drivers: spi_mcux_lpspi: Clean up init function
Do initializations in a more logical order, remove unnecessarily duplicated code, reorder stack variables to be in reverse christmas tree order. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
5a0d9831b1
commit
d76ccdbdea
1 changed files with 10 additions and 13 deletions
|
@ -751,21 +751,12 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status)
|
||||||
|
|
||||||
static int spi_mcux_init(const struct device *dev)
|
static int spi_mcux_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
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;
|
||||||
|
int err;
|
||||||
|
|
||||||
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
|
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
|
||||||
|
|
||||||
config->irq_config_func(dev);
|
|
||||||
|
|
||||||
err = spi_context_cs_configure_all(&data->ctx);
|
|
||||||
if (err < 0) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
spi_context_unlock_unconditionally(&data->ctx);
|
|
||||||
|
|
||||||
data->dev = dev;
|
data->dev = dev;
|
||||||
|
|
||||||
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
|
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
|
||||||
|
@ -782,15 +773,21 @@ static int spi_mcux_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
|
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
|
||||||
|
|
||||||
#ifdef CONFIG_SPI_RTIO
|
err = spi_context_cs_configure_all(&data->ctx);
|
||||||
spi_rtio_init(data->rtio_ctx, dev);
|
if (err < 0) {
|
||||||
#endif
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config->irq_config_func(dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPI_RTIO
|
||||||
|
spi_rtio_init(data->rtio_ctx, dev);
|
||||||
|
#endif
|
||||||
spi_context_unlock_unconditionally(&data->ctx);
|
spi_context_unlock_unconditionally(&data->ctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue