mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xen-blkfront: Use the bitmap API when applicable
@ 2021-12-01 21:10 Christophe JAILLET
  2021-12-02  6:12 ` Juergen Gross
  0 siblings, 1 reply; 12+ messages in thread
From: Christophe JAILLET @ 2021-12-01 21:10 UTC (permalink / raw)
  To: boris.ostrovsky, jgross, sstabellini, roger.pau, axboe
  Cc: xen-devel, linux-block, linux-kernel, kernel-janitors,
	Christophe JAILLET

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.

Use 'bitmap_copy()' to avoid an explicit 'memcpy()'

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/block/xen-blkfront.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 700c765a759a..fe4d69cf9469 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -442,16 +442,14 @@ static int xlbd_reserve_minors(unsigned int minor, unsigned int nr)
 	if (end > nr_minors) {
 		unsigned long *bitmap, *old;
 
-		bitmap = kcalloc(BITS_TO_LONGS(end), sizeof(*bitmap),
-				 GFP_KERNEL);
+		bitmap = bitmap_zalloc(end, GFP_KERNEL);
 		if (bitmap == NULL)
 			return -ENOMEM;
 
 		spin_lock(&minor_lock);
 		if (end > nr_minors) {
 			old = minors;
-			memcpy(bitmap, minors,
-			       BITS_TO_LONGS(nr_minors) * sizeof(*bitmap));
+			bitmap_copy(bitmap, minors, nr_minors);
 			minors = bitmap;
 			nr_minors = BITS_TO_LONGS(end) * BITS_PER_LONG;
 		} else
@@ -2610,7 +2608,7 @@ static void __exit xlblk_exit(void)
 
 	xenbus_unregister_driver(&blkfront_driver);
 	unregister_blkdev(XENVBD_MAJOR, DEV_NAME);
-	kfree(minors);
+	bitmap_free(minors);
 }
 module_exit(xlblk_exit);
 
-- 
2.30.2


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 21:10 [PATCH] xen-blkfront: Use the bitmap API when applicable Christophe JAILLET
2021-12-02  6:12 ` Juergen Gross
2021-12-02 18:12   ` Christophe JAILLET
2021-12-02 18:16     ` Joe Perches
2021-12-02 19:07       ` Christophe JAILLET
2021-12-03  3:03         ` Joe Perches
2021-12-03 15:54           ` Christophe JAILLET
2021-12-03 16:10             ` Joe Perches
2021-12-03 21:04             ` Boris Ostrovsky
2021-12-04  6:57               ` Christophe JAILLET
2021-12-04  7:05                 ` Joe Perches
2021-12-06 13:31                 ` Boris Ostrovsky

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®