Skip to content

Commit e7f35da

Browse files
tititiou36richardweinberger
authored andcommitted
ubi: fastmap: Use the bitmap API to allocate bitmaps
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Zhihao Cheng <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent a0c5156 commit e7f35da

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/mtd/ubi/fastmap.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
2020
if (!ubi_dbg_chk_fastmap(ubi))
2121
return NULL;
2222

23-
ret = kcalloc(BITS_TO_LONGS(ubi->peb_count), sizeof(unsigned long),
24-
GFP_KERNEL);
23+
ret = bitmap_zalloc(ubi->peb_count, GFP_KERNEL);
2524
if (!ret)
2625
return ERR_PTR(-ENOMEM);
2726

@@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
3433
*/
3534
static inline void free_seen(unsigned long *seen)
3635
{
37-
kfree(seen);
36+
bitmap_free(seen);
3837
}
3938

4039
/**
@@ -1108,8 +1107,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
11081107
if (!ubi->fast_attach)
11091108
return 0;
11101109

1111-
vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
1112-
GFP_KERNEL);
1110+
vol->checkmap = bitmap_zalloc(leb_count, GFP_KERNEL);
11131111
if (!vol->checkmap)
11141112
return -ENOMEM;
11151113

@@ -1118,7 +1116,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
11181116

11191117
void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
11201118
{
1121-
kfree(vol->checkmap);
1119+
bitmap_free(vol->checkmap);
11221120
}
11231121

11241122
/**

0 commit comments

Comments
 (0)