mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
lib: objagg: Use the bitmap API when applicable
Use 'bitmap_zalloc()' to simplify code, improve the semantic and reduce 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> Link: https://lore.kernel.org/r/f9541b085ec68e573004e1be200c11c9c901181a.1640295165.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
7467d71658
commit
7c63f26cb5
@ -781,7 +781,6 @@ static struct objagg_tmp_graph *objagg_tmp_graph_create(struct objagg *objagg)
|
||||
struct objagg_tmp_node *node;
|
||||
struct objagg_tmp_node *pnode;
|
||||
struct objagg_obj *objagg_obj;
|
||||
size_t alloc_size;
|
||||
int i, j;
|
||||
|
||||
graph = kzalloc(sizeof(*graph), GFP_KERNEL);
|
||||
@ -793,9 +792,7 @@ static struct objagg_tmp_graph *objagg_tmp_graph_create(struct objagg *objagg)
|
||||
goto err_nodes_alloc;
|
||||
graph->nodes_count = nodes_count;
|
||||
|
||||
alloc_size = BITS_TO_LONGS(nodes_count * nodes_count) *
|
||||
sizeof(unsigned long);
|
||||
graph->edges = kzalloc(alloc_size, GFP_KERNEL);
|
||||
graph->edges = bitmap_zalloc(nodes_count * nodes_count, GFP_KERNEL);
|
||||
if (!graph->edges)
|
||||
goto err_edges_alloc;
|
||||
|
||||
@ -833,7 +830,7 @@ err_nodes_alloc:
|
||||
|
||||
static void objagg_tmp_graph_destroy(struct objagg_tmp_graph *graph)
|
||||
{
|
||||
kfree(graph->edges);
|
||||
bitmap_free(graph->edges);
|
||||
kfree(graph->nodes);
|
||||
kfree(graph);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user