Commit 49dc9013 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

net/smc: Use the bitmap API when applicable

Using the bitmap API is less verbose than hand writing them.
It also improves the semantic.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c09f103e
...@@ -54,11 +54,7 @@ struct smc_wr_tx_pend { /* control data for a pending send request */ ...@@ -54,11 +54,7 @@ struct smc_wr_tx_pend { /* control data for a pending send request */
/* returns true if at least one tx work request is pending on the given link */ /* returns true if at least one tx work request is pending on the given link */
static inline bool smc_wr_is_tx_pend(struct smc_link *link) static inline bool smc_wr_is_tx_pend(struct smc_link *link)
{ {
if (find_first_bit(link->wr_tx_mask, link->wr_tx_cnt) != return !bitmap_empty(link->wr_tx_mask, link->wr_tx_cnt);
link->wr_tx_cnt) {
return true;
}
return false;
} }
/* wait till all pending tx work requests on the given link are completed */ /* wait till all pending tx work requests on the given link are completed */
...@@ -674,9 +670,7 @@ void smc_wr_free_link(struct smc_link *lnk) ...@@ -674,9 +670,7 @@ void smc_wr_free_link(struct smc_link *lnk)
smc_wr_wakeup_tx_wait(lnk); smc_wr_wakeup_tx_wait(lnk);
if (smc_wr_tx_wait_no_pending_sends(lnk)) if (smc_wr_tx_wait_no_pending_sends(lnk))
memset(lnk->wr_tx_mask, 0, bitmap_zero(lnk->wr_tx_mask, SMC_WR_BUF_CNT);
BITS_TO_LONGS(SMC_WR_BUF_CNT) *
sizeof(*lnk->wr_tx_mask));
wait_event(lnk->wr_reg_wait, (!atomic_read(&lnk->wr_reg_refcnt))); wait_event(lnk->wr_reg_wait, (!atomic_read(&lnk->wr_reg_refcnt)));
wait_event(lnk->wr_tx_wait, (!atomic_read(&lnk->wr_tx_refcnt))); wait_event(lnk->wr_tx_wait, (!atomic_read(&lnk->wr_tx_refcnt)));
...@@ -729,7 +723,7 @@ void smc_wr_free_link_mem(struct smc_link *lnk) ...@@ -729,7 +723,7 @@ void smc_wr_free_link_mem(struct smc_link *lnk)
lnk->wr_tx_compl = NULL; lnk->wr_tx_compl = NULL;
kfree(lnk->wr_tx_pends); kfree(lnk->wr_tx_pends);
lnk->wr_tx_pends = NULL; lnk->wr_tx_pends = NULL;
kfree(lnk->wr_tx_mask); bitmap_free(lnk->wr_tx_mask);
lnk->wr_tx_mask = NULL; lnk->wr_tx_mask = NULL;
kfree(lnk->wr_tx_sges); kfree(lnk->wr_tx_sges);
lnk->wr_tx_sges = NULL; lnk->wr_tx_sges = NULL;
...@@ -805,9 +799,7 @@ int smc_wr_alloc_link_mem(struct smc_link *link) ...@@ -805,9 +799,7 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
GFP_KERNEL); GFP_KERNEL);
if (!link->wr_rx_sges) if (!link->wr_rx_sges)
goto no_mem_wr_tx_sges; goto no_mem_wr_tx_sges;
link->wr_tx_mask = kcalloc(BITS_TO_LONGS(SMC_WR_BUF_CNT), link->wr_tx_mask = bitmap_zalloc(SMC_WR_BUF_CNT, GFP_KERNEL);
sizeof(*link->wr_tx_mask),
GFP_KERNEL);
if (!link->wr_tx_mask) if (!link->wr_tx_mask)
goto no_mem_wr_rx_sges; goto no_mem_wr_rx_sges;
link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT, link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT,
...@@ -920,8 +912,7 @@ int smc_wr_create_link(struct smc_link *lnk) ...@@ -920,8 +912,7 @@ int smc_wr_create_link(struct smc_link *lnk)
goto dma_unmap; goto dma_unmap;
} }
smc_wr_init_sge(lnk); smc_wr_init_sge(lnk);
memset(lnk->wr_tx_mask, 0, bitmap_zero(lnk->wr_tx_mask, SMC_WR_BUF_CNT);
BITS_TO_LONGS(SMC_WR_BUF_CNT) * sizeof(*lnk->wr_tx_mask));
init_waitqueue_head(&lnk->wr_tx_wait); init_waitqueue_head(&lnk->wr_tx_wait);
atomic_set(&lnk->wr_tx_refcnt, 0); atomic_set(&lnk->wr_tx_refcnt, 0);
init_waitqueue_head(&lnk->wr_reg_wait); init_waitqueue_head(&lnk->wr_reg_wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment