public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sh: Use bitmap_zalloc() when applicable
@ 2021-11-23 21:26 Christophe JAILLET
  2021-12-13  9:22 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-23 21:26 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-kernel, kernel-janitors, Christophe JAILLET

'shdma_slave_used' is a bitmap. So use 'bitmap_zalloc()' to simplify code,
improve the semantic and avoid some open-coded arithmetic in allocator
arguments.

Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
consistency.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/dma/sh/shdma-base.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 7f72b3f4cd1a..0a2eb5f5a6e8 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -1042,9 +1042,7 @@ EXPORT_SYMBOL(shdma_cleanup);
 
 static int __init shdma_enter(void)
 {
-	shdma_slave_used = kcalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG),
-				   sizeof(long),
-				   GFP_KERNEL);
+	shdma_slave_used = bitmap_zalloc(slave_num, GFP_KERNEL);
 	if (!shdma_slave_used)
 		return -ENOMEM;
 	return 0;
@@ -1053,7 +1051,7 @@ module_init(shdma_enter);
 
 static void __exit shdma_exit(void)
 {
-	kfree(shdma_slave_used);
+	bitmap_free(shdma_slave_used);
 }
 module_exit(shdma_exit);
 
-- 
2.30.2


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

* Re: [PATCH] dmaengine: sh: Use bitmap_zalloc() when applicable
  2021-11-23 21:26 [PATCH] dmaengine: sh: Use bitmap_zalloc() when applicable Christophe JAILLET
@ 2021-12-13  9:22 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2021-12-13  9:22 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: dmaengine, linux-kernel, kernel-janitors

On 23-11-21, 22:26, Christophe JAILLET wrote:
> 'shdma_slave_used' is a bitmap. So use 'bitmap_zalloc()' to simplify code,
> improve the semantic and avoid some open-coded arithmetic in allocator
> arguments.
> 
> Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
> consistency.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-12-13  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-23 21:26 [PATCH] dmaengine: sh: Use bitmap_zalloc() when applicable Christophe JAILLET
2021-12-13  9: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