drivers: dma: stm32: avoid clear flags if hal_override on unexpected irq

In case of using HAL_OVERRIDE, avoid clearing the FIFO ERROR flag
before calling the HAL DMA IrqHandler so that the HAL DMA code
handling can be used.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
diff --git a/drivers/dma/dma_stm32.c b/drivers/dma/dma_stm32.c
index 88c300f..4876c6a 100644
--- a/drivers/dma/dma_stm32.c
+++ b/drivers/dma/dma_stm32.c
@@ -129,7 +129,12 @@
 		}
 		stream->dma_callback(dev, stream->user_data, callback_arg, DMA_STATUS_COMPLETE);
 	} else if (stm32_dma_is_unexpected_irq_happened(dma, id)) {
-		LOG_ERR("Unexpected irq happened.");
+		/* Let HAL DMA handle flags on its own */
+		if (!stream->hal_override) {
+			LOG_ERR("Unexpected irq happened.");
+			stm32_dma_dump_stream_irq(dma, id);
+			stm32_dma_clear_stream_irq(dma, id);
+		}
 		stream->dma_callback(dev, stream->user_data,
 				     callback_arg, -EIO);
 	} else {
diff --git a/drivers/dma/dma_stm32_v1.c b/drivers/dma/dma_stm32_v1.c
index 58bd154..b02c897 100644
--- a/drivers/dma/dma_stm32_v1.c
+++ b/drivers/dma/dma_stm32_v1.c
@@ -306,9 +306,6 @@
 	if (LL_DMA_IsEnabledIT_FE(dma, dma_stm32_id_to_stream(id)) &&
 	    dma_stm32_is_fe_active(dma, id)) {
 		LOG_ERR("FiFo error.");
-		stm32_dma_dump_stream_irq(dma, id);
-		stm32_dma_clear_stream_irq(dma, id);
-
 		return true;
 	}