* [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps
@ 2022-07-04 18:46 Christophe JAILLET
2022-07-08 9:07 ` Zhihao Cheng
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-07-04 18:46 UTC (permalink / raw)
To: Richard Weinberger, Miquel Raynal, Vignesh Raghavendra,
Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mtd,
linux-stm32, linux-arm-kernel
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
It is less verbose and it improves the semantic.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mtd/ubi/fastmap.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 6e95c4b1473e..ca2d9efe62c3 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
if (!ubi_dbg_chk_fastmap(ubi))
return NULL;
- ret = kcalloc(BITS_TO_LONGS(ubi->peb_count), sizeof(unsigned long),
- GFP_KERNEL);
+ ret = bitmap_zalloc(ubi->peb_count, GFP_KERNEL);
if (!ret)
return ERR_PTR(-ENOMEM);
@@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
*/
static inline void free_seen(unsigned long *seen)
{
- kfree(seen);
+ bitmap_free(seen);
}
/**
@@ -1108,8 +1107,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
if (!ubi->fast_attach)
return 0;
- vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
- GFP_KERNEL);
+ vol->checkmap = bitmap_zalloc(leb_count, GFP_KERNEL);
if (!vol->checkmap)
return -ENOMEM;
@@ -1118,7 +1116,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
{
- kfree(vol->checkmap);
+ bitmap_free(vol->checkmap);
}
/**
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps
2022-07-04 18:46 [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps Christophe JAILLET
@ 2022-07-08 9:07 ` Zhihao Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Zhihao Cheng @ 2022-07-08 9:07 UTC (permalink / raw)
To: Christophe JAILLET, Richard Weinberger, Miquel Raynal,
Vignesh Raghavendra, Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, kernel-janitors, linux-mtd, linux-stm32, linux-arm-kernel
在 2022/7/5 2:46, Christophe JAILLET 写道:
> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
>
> It is less verbose and it improves the semantic.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/mtd/ubi/fastmap.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
> index 6e95c4b1473e..ca2d9efe62c3 100644
> --- a/drivers/mtd/ubi/fastmap.c
> +++ b/drivers/mtd/ubi/fastmap.c
> @@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
> if (!ubi_dbg_chk_fastmap(ubi))
> return NULL;
>
> - ret = kcalloc(BITS_TO_LONGS(ubi->peb_count), sizeof(unsigned long),
> - GFP_KERNEL);
> + ret = bitmap_zalloc(ubi->peb_count, GFP_KERNEL);
> if (!ret)
> return ERR_PTR(-ENOMEM);
>
> @@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
> */
> static inline void free_seen(unsigned long *seen)
> {
> - kfree(seen);
> + bitmap_free(seen);
> }
>
> /**
> @@ -1108,8 +1107,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
> if (!ubi->fast_attach)
> return 0;
>
> - vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
> - GFP_KERNEL);
> + vol->checkmap = bitmap_zalloc(leb_count, GFP_KERNEL);
> if (!vol->checkmap)
> return -ENOMEM;
>
> @@ -1118,7 +1116,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
>
> void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
> {
> - kfree(vol->checkmap);
> + bitmap_free(vol->checkmap);
> }
>
> /**
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-08 9:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 18:46 [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08 9:07 ` Zhihao Cheng
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).