Skip to content

Commit 5a0d983

Browse files
decsnynashif
authored andcommitted
drivers: spi_mcux_lpspi: Move init to end of file
Move init function to bottom of file by custom. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent 0727566 commit 5a0d983

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

drivers/spi/spi_mcux_lpspi.c

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -650,53 +650,6 @@ static int spi_mcux_release(const struct device *dev, const struct spi_config *s
650650
return 0;
651651
}
652652

653-
static int spi_mcux_init(const struct device *dev)
654-
{
655-
int err;
656-
const struct spi_mcux_config *config = dev->config;
657-
struct spi_mcux_data *data = dev->data;
658-
659-
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
660-
661-
config->irq_config_func(dev);
662-
663-
err = spi_context_cs_configure_all(&data->ctx);
664-
if (err < 0) {
665-
return err;
666-
}
667-
668-
spi_context_unlock_unconditionally(&data->ctx);
669-
670-
data->dev = dev;
671-
672-
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
673-
if (data->dma_tx.dma_dev && data->dma_rx.dma_dev) {
674-
if (!device_is_ready(data->dma_tx.dma_dev)) {
675-
LOG_ERR("%s device is not ready", data->dma_tx.dma_dev->name);
676-
return -ENODEV;
677-
}
678-
679-
if (!device_is_ready(data->dma_rx.dma_dev)) {
680-
LOG_ERR("%s device is not ready", data->dma_rx.dma_dev->name);
681-
return -ENODEV;
682-
}
683-
}
684-
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
685-
686-
#ifdef CONFIG_SPI_RTIO
687-
spi_rtio_init(data->rtio_ctx, dev);
688-
#endif
689-
690-
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
691-
if (err) {
692-
return err;
693-
}
694-
695-
spi_context_unlock_unconditionally(&data->ctx);
696-
697-
return 0;
698-
}
699-
700653
#ifdef CONFIG_SPI_RTIO
701654

702655
static inline void spi_mcux_iodev_prepare_start(const struct device *dev)
@@ -796,6 +749,53 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status)
796749

797750
#endif
798751

752+
static int spi_mcux_init(const struct device *dev)
753+
{
754+
int err;
755+
const struct spi_mcux_config *config = dev->config;
756+
struct spi_mcux_data *data = dev->data;
757+
758+
DEVICE_MMIO_NAMED_MAP(dev, reg_base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
759+
760+
config->irq_config_func(dev);
761+
762+
err = spi_context_cs_configure_all(&data->ctx);
763+
if (err < 0) {
764+
return err;
765+
}
766+
767+
spi_context_unlock_unconditionally(&data->ctx);
768+
769+
data->dev = dev;
770+
771+
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA
772+
if (data->dma_tx.dma_dev && data->dma_rx.dma_dev) {
773+
if (!device_is_ready(data->dma_tx.dma_dev)) {
774+
LOG_ERR("%s device is not ready", data->dma_tx.dma_dev->name);
775+
return -ENODEV;
776+
}
777+
778+
if (!device_is_ready(data->dma_rx.dma_dev)) {
779+
LOG_ERR("%s device is not ready", data->dma_rx.dma_dev->name);
780+
return -ENODEV;
781+
}
782+
}
783+
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
784+
785+
#ifdef CONFIG_SPI_RTIO
786+
spi_rtio_init(data->rtio_ctx, dev);
787+
#endif
788+
789+
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT);
790+
if (err) {
791+
return err;
792+
}
793+
794+
spi_context_unlock_unconditionally(&data->ctx);
795+
796+
return 0;
797+
}
798+
799799
static const struct spi_driver_api spi_mcux_driver_api = {
800800
.transceive = spi_mcux_transceive,
801801
#ifdef CONFIG_SPI_ASYNC

0 commit comments

Comments
 (0)