Skip to content

Commit 8af63ea

Browse files
committed
drivers: dma: stm32u5: Clean up stream offset code
STM32_DMA_STREAM_OFFSET is defined as 0 in case "dma u5" is in use. Clean up code relating to this define. Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
1 parent 39a4267 commit 8af63ea

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

drivers/dma/dma_stm32u5.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id)
265265
dma_stm32_clear_stream_irq(dev, id);
266266
return;
267267
}
268-
callback_arg = id + STM32_DMA_STREAM_OFFSET;
268+
callback_arg = id;
269269

270-
/* The dma stream id is in range from STM32_DMA_STREAM_OFFSET..<dma-requests> */
270+
/* The dma stream id is in range from 0..<dma-requests> */
271271
if (stm32_dma_is_ht_irq_active(dma, id)) {
272272
/* Let HAL DMA handle flags on its own */
273273
if (!stream->hal_override) {
@@ -349,16 +349,12 @@ static int dma_stm32_configure(const struct device *dev,
349349
struct dma_config *config)
350350
{
351351
const struct dma_stm32_config *dev_config = dev->config;
352-
struct dma_stm32_stream *stream =
353-
&dev_config->streams[id - STM32_DMA_STREAM_OFFSET];
352+
struct dma_stm32_stream *stream = &dev_config->streams[id];
354353
DMA_TypeDef *dma = (DMA_TypeDef *)dev_config->base;
355354
uint32_t ll_priority;
356355
uint32_t ll_direction;
357356
int ret;
358357

359-
/* Give channel from index 0 */
360-
id = id - STM32_DMA_STREAM_OFFSET;
361-
362358
if (id >= dev_config->max_streams) {
363359
LOG_ERR("cannot configure the dma stream %d.", id);
364360
return -EINVAL;
@@ -553,9 +549,6 @@ static int dma_stm32_reload(const struct device *dev, uint32_t id,
553549
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
554550
struct dma_stm32_stream *stream;
555551

556-
/* Give channel from index 0 */
557-
id = id - STM32_DMA_STREAM_OFFSET;
558-
559552
if (id >= config->max_streams) {
560553
return -EINVAL;
561554
}
@@ -590,9 +583,6 @@ static int dma_stm32_start(const struct device *dev, uint32_t id)
590583
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
591584
struct dma_stm32_stream *stream;
592585

593-
/* Give channel from index 0 */
594-
id = id - STM32_DMA_STREAM_OFFSET;
595-
596586
/* Only M2P or M2M mode can be started manually. */
597587
if (id >= config->max_streams) {
598588
return -EINVAL;
@@ -619,9 +609,6 @@ static int dma_stm32_suspend(const struct device *dev, uint32_t id)
619609
const struct dma_stm32_config *config = dev->config;
620610
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
621611

622-
/* Give channel from index 0 */
623-
id = id - STM32_DMA_STREAM_OFFSET;
624-
625612
if (id >= config->max_streams) {
626613
return -EINVAL;
627614
}
@@ -642,9 +629,6 @@ static int dma_stm32_resume(const struct device *dev, uint32_t id)
642629
const struct dma_stm32_config *config = dev->config;
643630
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
644631

645-
/* Give channel from index 0 */
646-
id = id - STM32_DMA_STREAM_OFFSET;
647-
648632
if (id >= config->max_streams) {
649633
return -EINVAL;
650634
}
@@ -658,12 +642,9 @@ static int dma_stm32_resume(const struct device *dev, uint32_t id)
658642
static int dma_stm32_stop(const struct device *dev, uint32_t id)
659643
{
660644
const struct dma_stm32_config *config = dev->config;
661-
struct dma_stm32_stream *stream = &config->streams[id - STM32_DMA_STREAM_OFFSET];
645+
struct dma_stm32_stream *stream = &config->streams[id];
662646
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
663647

664-
/* Give channel from index 0 */
665-
id = id - STM32_DMA_STREAM_OFFSET;
666-
667648
if (id >= config->max_streams) {
668649
return -EINVAL;
669650
}
@@ -723,8 +704,6 @@ static int dma_stm32_get_status(const struct device *dev,
723704
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
724705
struct dma_stm32_stream *stream;
725706

726-
/* Give channel from index 0 */
727-
id = id - STM32_DMA_STREAM_OFFSET;
728707
if (id >= config->max_streams) {
729708
return -EINVAL;
730709
}

0 commit comments

Comments
 (0)