Skip to content

Commit

Permalink
scsi: elx: Use 'bitmap_zalloc()' when applicable
Browse files Browse the repository at this point in the history
'sli4->ext[i].use_map' is a bitmap. 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.

Link: https://lore.kernel.org/r/2a0a83949fb896a0a236dcca94dfdc8486d489f5.1635104793.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Christophe JAILLET authored and Martin K. Petersen committed Oct 27, 2021
1 parent 1ea7d80 commit 2c2934c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/scsi/elx/libefc_sli/sli4.c
Original file line number Diff line number Diff line change
Expand Up @@ -4145,7 +4145,7 @@ static int
sli_get_read_config(struct sli4 *sli4)
{
struct sli4_rsp_read_config *conf = sli4->bmbx.virt;
u32 i, total, total_size;
u32 i, total;
u32 *base;

if (sli_cmd_read_config(sli4, sli4->bmbx.virt)) {
Expand Down Expand Up @@ -4203,8 +4203,7 @@ sli_get_read_config(struct sli4 *sli4)

for (i = 0; i < SLI4_RSRC_MAX; i++) {
total = sli4->ext[i].number * sli4->ext[i].size;
total_size = BITS_TO_LONGS(total) * sizeof(long);
sli4->ext[i].use_map = kzalloc(total_size, GFP_KERNEL);
sli4->ext[i].use_map = bitmap_zalloc(total, GFP_KERNEL);
if (!sli4->ext[i].use_map) {
efc_log_err(sli4, "bitmap memory allocation failed %d\n",
i);
Expand Down Expand Up @@ -4743,7 +4742,7 @@ sli_reset(struct sli4 *sli4)
sli4->ext[0].base = NULL;

for (i = 0; i < SLI4_RSRC_MAX; i++) {
kfree(sli4->ext[i].use_map);
bitmap_free(sli4->ext[i].use_map);
sli4->ext[i].use_map = NULL;
sli4->ext[i].base = NULL;
}
Expand Down Expand Up @@ -4784,7 +4783,7 @@ sli_teardown(struct sli4 *sli4)
for (i = 0; i < SLI4_RSRC_MAX; i++) {
sli4->ext[i].base = NULL;

kfree(sli4->ext[i].use_map);
bitmap_free(sli4->ext[i].use_map);
sli4->ext[i].use_map = NULL;
}

Expand Down

0 comments on commit 2c2934c

Please sign in to comment.