lkml.org 
[lkml]   [2022]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] scsi: qla2xxx: Use the bitmap API to allocate bitmaps
Date
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/scsi/qla2xxx/qla_edif.c | 12 +++++-------
drivers/scsi/qla2xxx/qla_os.c | 8 +++-----
2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
index 400a8b6f3982..5a7b23a5479e 100644
--- a/drivers/scsi/qla2xxx/qla_edif.c
+++ b/drivers/scsi/qla2xxx/qla_edif.c
@@ -3349,8 +3349,7 @@ void qla_edif_sadb_release(struct qla_hw_data *ha)
/* build the rx and tx sa_index free pools -- only done at fcport init */
int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
{
- ha->edif_tx_sa_id_map =
- kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
+ ha->edif_tx_sa_id_map = bitmap_zalloc(EDIF_NUM_SA_INDEX, GFP_KERNEL);

if (!ha->edif_tx_sa_id_map) {
ql_log_pci(ql_log_fatal, ha->pdev, 0x0009,
@@ -3358,10 +3357,9 @@ int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
return -ENOMEM;
}

- ha->edif_rx_sa_id_map =
- kcalloc(BITS_TO_LONGS(EDIF_NUM_SA_INDEX), sizeof(long), GFP_KERNEL);
+ ha->edif_rx_sa_id_map = bitmap_zalloc(EDIF_NUM_SA_INDEX, GFP_KERNEL);
if (!ha->edif_rx_sa_id_map) {
- kfree(ha->edif_tx_sa_id_map);
+ bitmap_free(ha->edif_tx_sa_id_map);
ha->edif_tx_sa_id_map = NULL;
ql_log_pci(ql_log_fatal, ha->pdev, 0x0009,
"Unable to allocate memory for sadb rx.\n");
@@ -3373,9 +3371,9 @@ int qla_edif_sadb_build_free_pool(struct qla_hw_data *ha)
/* release the free pool - only done during fcport teardown */
void qla_edif_sadb_release_free_pool(struct qla_hw_data *ha)
{
- kfree(ha->edif_tx_sa_id_map);
+ bitmap_free(ha->edif_tx_sa_id_map);
ha->edif_tx_sa_id_map = NULL;
- kfree(ha->edif_rx_sa_id_map);
+ bitmap_free(ha->edif_rx_sa_id_map);
ha->edif_rx_sa_id_map = NULL;
}

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 1c7fb6484db2..d5f292612cda 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4356,9 +4356,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
INIT_LIST_HEAD(&ha->vp_list);

/* Allocate memory for our loop_id bitmap */
- ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE),
- sizeof(long),
- GFP_KERNEL);
+ ha->loop_id_map = bitmap_zalloc(LOOPID_MAP_SIZE, GFP_KERNEL);
if (!ha->loop_id_map)
goto fail_loop_id_map;
else {
@@ -4418,7 +4416,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
ha->sfp_data, ha->sfp_data_dma);
fail_sfp_data:
- kfree(ha->loop_id_map);
+ bitmap_free(ha->loop_id_map);
fail_loop_id_map:
dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
fail_async_pd:
@@ -4948,7 +4946,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
ha->npiv_info = NULL;
kfree(ha->swl);
ha->swl = NULL;
- kfree(ha->loop_id_map);
+ bitmap_free(ha->loop_id_map);
ha->sf_init_cb = NULL;
ha->sf_init_cb_dma = 0;
ha->loop_id_map = NULL;
--
2.34.1
\
 
 \ /
  Last update: 2022-07-04 21:36    [W:0.028 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site