* [PATCH] dmaengine: stm32-dmamux: Simplify code and save a few bytes of memory
@ 2022-07-30 20:07 Christophe JAILLET
2022-09-05 6:22 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-07-30 20:07 UTC (permalink / raw)
To: Vinod Koul, Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, dmaengine,
linux-stm32, linux-arm-kernel
STM32_DMAMUX_MAX_DMA_REQUESTS is small (i.e. 32) and when the 'dma_inuse'
bitmap is allocated, there is already a check that 'dma_req' is <= this
limit.
So, there is no good reason to dynamically allocate this bitmap. This
just waste some memory and some cycles.
Use DECLARE_BITMAP with the maximum bitmap size instead.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/dma/stm32-dmamux.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index eee0c5aa5fb5..212c332f14f9 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -39,7 +39,7 @@ struct stm32_dmamux_data {
u32 dma_requests; /* Number of DMA requests connected to DMAMUX */
u32 dmamux_requests; /* Number of DMA requests routed toward DMAs */
spinlock_t lock; /* Protects register access */
- unsigned long *dma_inuse; /* Used DMA channel */
+ DECLARE_BITMAP(dma_inuse, STM32_DMAMUX_MAX_DMA_REQUESTS); /* Used DMA channel */
u32 ccr[STM32_DMAMUX_MAX_DMA_REQUESTS]; /* Used to backup CCR register
* in suspend
*/
@@ -229,12 +229,6 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
stm32_dmamux->dma_requests = dma_req;
stm32_dmamux->dma_reqs[0] = count;
- stm32_dmamux->dma_inuse = devm_kcalloc(&pdev->dev,
- BITS_TO_LONGS(dma_req),
- sizeof(unsigned long),
- GFP_KERNEL);
- if (!stm32_dmamux->dma_inuse)
- return -ENOMEM;
if (device_property_read_u32(&pdev->dev, "dma-requests",
&stm32_dmamux->dmamux_requests)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: stm32-dmamux: Simplify code and save a few bytes of memory
2022-07-30 20:07 [PATCH] dmaengine: stm32-dmamux: Simplify code and save a few bytes of memory Christophe JAILLET
@ 2022-09-05 6:22 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-09-05 6:22 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Maxime Coquelin, Alexandre Torgue, linux-kernel, kernel-janitors,
dmaengine, linux-stm32, linux-arm-kernel
On 30-07-22, 22:07, Christophe JAILLET wrote:
> STM32_DMAMUX_MAX_DMA_REQUESTS is small (i.e. 32) and when the 'dma_inuse'
> bitmap is allocated, there is already a check that 'dma_req' is <= this
> limit.
>
> So, there is no good reason to dynamically allocate this bitmap. This
> just waste some memory and some cycles.
>
> Use DECLARE_BITMAP with the maximum bitmap size instead.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-05 6:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30 20:07 [PATCH] dmaengine: stm32-dmamux: Simplify code and save a few bytes of memory Christophe JAILLET
2022-09-05 6:22 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).