aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_allocator.c
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2021-11-24 21:41:36 +0100
committerJason Gunthorpe <jgg@nvidia.com>2021-11-25 13:29:05 -0400
commita277f383217a2c03f96166c5b33304c8b939532e (patch)
tree0f09e5d608b56ac2678c8a369fe77d9de6c29791 /drivers/infiniband/hw/mthca/mthca_allocator.c
parentIB/mthca: Use bitmap_zalloc() when applicable (diff)
downloadlinux-dev-a277f383217a2c03f96166c5b33304c8b939532e.tar.xz
linux-dev-a277f383217a2c03f96166c5b33304c8b939532e.zip
IB/mthca: Use bitmap_set() when applicable
The 'alloc->table' bitmap has just been allocated, so this is safe to use the faster and non-atomic 'bitmap_set()' function. There is no need to hand-write it. Link: https://lore.kernel.org/r/f1bd33f6ea6c8ad519a222db6e9aa17c55610557.1637785902.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_allocator.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_allocator.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
index 06fc8a2e0bd4..57fa1cc202bc 100644
--- a/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
@@ -79,8 +79,6 @@ void mthca_free(struct mthca_alloc *alloc, u32 obj)
int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
u32 reserved)
{
- int i;
-
/* num must be a power of 2 */
if (num != 1 << (ffs(num) - 1))
return -EINVAL;
@@ -94,8 +92,7 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
if (!alloc->table)
return -ENOMEM;
- for (i = 0; i < reserved; ++i)
- set_bit(i, alloc->table);
+ bitmap_set(alloc->table, 0, reserved);
return 0;
}