spi: mcux flexcomm: Convert dma to use DEVICE_DT_GET

Replace device_get_binding with DEVICE_DT_GET for getting access
to the dma controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2021-02-25 07:21:32 -06:00 committed by Kumar Gala
commit 3b8ea186fd

View file

@ -38,7 +38,6 @@ struct spi_mcux_config {
(SPI_MCUX_FLEXCOMM_DMA_RX_DONE_FLAG | SPI_MCUX_FLEXCOMM_DMA_TX_DONE_FLAG) (SPI_MCUX_FLEXCOMM_DMA_RX_DONE_FLAG | SPI_MCUX_FLEXCOMM_DMA_TX_DONE_FLAG)
struct stream { struct stream {
const char *dma_name;
const struct device *dma_dev; const struct device *dma_dev;
uint32_t channel; /* stores the channel for dma */ uint32_t channel; /* stores the channel for dma */
struct dma_config dma_cfg; struct dma_config dma_cfg;
@ -647,12 +646,7 @@ static int spi_mcux_transceive(const struct device *dev,
const struct spi_buf_set *rx_bufs) const struct spi_buf_set *rx_bufs)
{ {
#ifdef CONFIG_SPI_MCUX_FLEXCOMM_DMA #ifdef CONFIG_SPI_MCUX_FLEXCOMM_DMA
struct spi_mcux_data *data = dev->data; return transceive_dma(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL);
if ((data->dma_tx.dma_name != NULL)
&& (data->dma_rx.dma_name != NULL)) {
return transceive_dma(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL);
}
#endif #endif
return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL); return transceive(dev, spi_cfg, tx_bufs, rx_bufs, false, NULL);
} }
@ -688,22 +682,15 @@ static int spi_mcux_init(const struct device *dev)
data->dev = dev; data->dev = dev;
#ifdef CONFIG_SPI_MCUX_FLEXCOMM_DMA #ifdef CONFIG_SPI_MCUX_FLEXCOMM_DMA
if (data->dma_tx.dma_name != NULL) { if (!device_is_ready(data->dma_tx.dma_dev)) {
/* Get the binding to the DMA device */ LOG_ERR("%s device is not ready", data->dma_tx.dma_dev->name);
data->dma_tx.dma_dev = device_get_binding(data->dma_tx.dma_name); return -ENODEV;
if (!data->dma_tx.dma_dev) { }
LOG_ERR("%s device not found", data->dma_tx.dma_name);
return -ENODEV;
}
}
if (data->dma_rx.dma_name != NULL) { if (!device_is_ready(data->dma_rx.dma_dev)) {
data->dma_rx.dma_dev = device_get_binding(data->dma_rx.dma_name); LOG_ERR("%s device is not ready", data->dma_rx.dma_dev->name);
if (!data->dma_rx.dma_dev) { return -ENODEV;
LOG_ERR("%s device not found", data->dma_rx.dma_name); }
return -ENODEV;
}
}
#endif /* CONFIG_SPI_MCUX_FLEXCOMM_DMA */ #endif /* CONFIG_SPI_MCUX_FLEXCOMM_DMA */
spi_context_unlock_unconditionally(&data->ctx); spi_context_unlock_unconditionally(&data->ctx);
@ -738,7 +725,7 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
#else #else
#define SPI_DMA_CHANNELS(id) \ #define SPI_DMA_CHANNELS(id) \
.dma_tx = { \ .dma_tx = { \
.dma_name = DT_INST_DMAS_LABEL_BY_NAME(id, tx), \ .dma_dev = DEVICE_DT_GET(DT_INST_DMAS_CTLR_BY_NAME(id, tx)), \
.channel = \ .channel = \
DT_INST_DMAS_CELL_BY_NAME(id, tx, channel), \ DT_INST_DMAS_CELL_BY_NAME(id, tx, channel), \
.dma_cfg = { \ .dma_cfg = { \
@ -749,7 +736,7 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
} \ } \
}, \ }, \
.dma_rx = { \ .dma_rx = { \
.dma_name = DT_INST_DMAS_LABEL_BY_NAME(id, rx), \ .dma_dev = DEVICE_DT_GET(DT_INST_DMAS_CTLR_BY_NAME(id, rx)), \
.channel = \ .channel = \
DT_INST_DMAS_CELL_BY_NAME(id, rx, channel), \ DT_INST_DMAS_CELL_BY_NAME(id, rx, channel), \
.dma_cfg = { \ .dma_cfg = { \