aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-08-14 18:17:10 -0400
committerRoland Dreier <roland@purestorage.com>2012-08-16 00:05:27 -0400
commit96f17d590092ae2511adf599a252e8ed1901b7a4 (patch)
tree33a540dc18e2256d70cddb35e8df10809b42ce6e
parent3de819e6b642fdd51904f5f4d2716d7466a2f7f5 (diff)
mlx4_core: Clean up buddy bitmap allocation
- Use kcalloc() / vzalloc() instead of an extra bitmap_zero(). - Add __GFP_NOWARN to kcalloc() since we'll try vzalloc() if it fails. Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 44b8e1ea1cd8..c202d3ad2a0e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -121,7 +121,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order)
121 buddy->max_order = max_order; 121 buddy->max_order = max_order;
122 spin_lock_init(&buddy->lock); 122 spin_lock_init(&buddy->lock);
123 123
124 buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), 124 buddy->bits = kcalloc(buddy->max_order + 1, sizeof (long *),
125 GFP_KERNEL); 125 GFP_KERNEL);
126 buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free, 126 buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
127 GFP_KERNEL); 127 GFP_KERNEL);
@@ -130,13 +130,12 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order)
130 130
131 for (i = 0; i <= buddy->max_order; ++i) { 131 for (i = 0; i <= buddy->max_order; ++i) {
132 s = BITS_TO_LONGS(1 << (buddy->max_order - i)); 132 s = BITS_TO_LONGS(1 << (buddy->max_order - i));
133 buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL); 133 buddy->bits[i] = kcalloc(s, sizeof (long), GFP_KERNEL | __GFP_NOWARN);
134 if (!buddy->bits[i]) { 134 if (!buddy->bits[i]) {
135 buddy->bits[i] = vmalloc(s * sizeof(long)); 135 buddy->bits[i] = vzalloc(s * sizeof(long));
136 if (!buddy->bits[i]) 136 if (!buddy->bits[i])
137 goto err_out_free; 137 goto err_out_free;
138 } 138 }
139 bitmap_zero(buddy->bits[i], 1 << (buddy->max_order - i));
140 } 139 }
141 140
142 set_bit(0, buddy->bits[buddy->max_order]); 141 set_bit(0, buddy->bits[buddy->max_order]);