mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings
@ 2025-12-17  8:15 Amelie Delaunay
  2025-12-23 11:28 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Amelie Delaunay @ 2025-12-17  8:15 UTC (permalink / raw)
  To: Vinod Koul, Maxime Coquelin, Alexandre Torgue, Clément Le Goffic
  Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel,
	Clément Le Goffic, Amelie Delaunay

From: Clément Le Goffic <clement.legoffic@foss.st.com>

m2m_hw_period is initialized only when chan_config->m2m_hw is true. This
triggers a warning:
‘m2m_hw_period’ may be used uninitialized [-Wmaybe-uninitialized]
Although m2m_hw_period is only used when chan_config->m2m_hw is true and
ignored otherwise, initialize it unconditionally to 0.

ccr is initialized by stm32_mdma_set_xfer_param() when the sg list is not
empty. This triggers a warning:
‘ccr’ may be used uninitialized [-Wmaybe-uninitialized]
Indeed, it could be used uninitialized if the sg list is empty. Initialize
it to 0.

Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com>
Reviewed-by: Clément Le Goffic <legoffic.clement@gmail.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
Changes in v2:
- Added code-review trailer
- Rebased on top of v6.19-rc1 
- Link to v1: https://lore.kernel.org/r/20251030-mdma_warnings_fix-v1-1-987f67c75794@foss.st.com
---
 drivers/dma/stm32/stm32-mdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index 080c1c725216..b87d41b234df 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -731,7 +731,7 @@ static int stm32_mdma_setup_xfer(struct stm32_mdma_chan *chan,
 	struct stm32_mdma_chan_config *chan_config = &chan->chan_config;
 	struct scatterlist *sg;
 	dma_addr_t src_addr, dst_addr;
-	u32 m2m_hw_period, ccr, ctcr, ctbr;
+	u32 m2m_hw_period = 0, ccr = 0, ctcr, ctbr;
 	int i, ret = 0;
 
 	if (chan_config->m2m_hw)

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251030-mdma_warnings_fix-df4b3d1405ed

Best regards,
-- 
Amelie Delaunay <amelie.delaunay@foss.st.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings
  2025-12-17  8:15 [PATCH v2] dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings Amelie Delaunay
@ 2025-12-23 11:28 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2025-12-23 11:28 UTC (permalink / raw)
  To: Maxime Coquelin, Alexandre Torgue, Clément Le Goffic,
	Amelie Delaunay
  Cc: dmaengine, linux-stm32, linux-arm-kernel, linux-kernel,
	Clément Le Goffic


On Wed, 17 Dec 2025 09:15:03 +0100, Amelie Delaunay wrote:
> m2m_hw_period is initialized only when chan_config->m2m_hw is true. This
> triggers a warning:
> ‘m2m_hw_period’ may be used uninitialized [-Wmaybe-uninitialized]
> Although m2m_hw_period is only used when chan_config->m2m_hw is true and
> ignored otherwise, initialize it unconditionally to 0.
> 
> ccr is initialized by stm32_mdma_set_xfer_param() when the sg list is not
> empty. This triggers a warning:
> ‘ccr’ may be used uninitialized [-Wmaybe-uninitialized]
> Indeed, it could be used uninitialized if the sg list is empty. Initialize
> it to 0.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings
      commit: aaf3bc0265744adbc2d364964ef409cf118d193d

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-23 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-17  8:15 [PATCH v2] dmaengine: stm32-mdma: initialize m2m_hw_period and ccr to fix warnings Amelie Delaunay
2025-12-23 11:28 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®