Skip to content

Commit

Permalink
infiniband: use for_each_set_bit()
Browse files Browse the repository at this point in the history
Replace open-coded loop with for_each_set_bit().

Signed-off-by: Akinobu Mita <[email protected]>
Acked-by: Roland Dreier <[email protected]>
Cc: Sean Hefty <[email protected]>
Cc: Hal Rosenstock <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Mar 6, 2010
1 parent 984b3f5 commit 19b629f
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions drivers/infiniband/core/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,10 +1193,7 @@ static int method_in_use(struct ib_mad_mgmt_method_table **method,
{
int i;

for (i = find_first_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS);
i < IB_MGMT_MAX_METHODS;
i = find_next_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS,
1+i)) {
for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS) {
if ((*method)->agent[i]) {
printk(KERN_ERR PFX "Method %d already in use\n", i);
return -EINVAL;
Expand Down Expand Up @@ -1330,13 +1327,9 @@ static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
goto error3;

/* Finally, add in methods being registered */
for (i = find_first_bit(mad_reg_req->method_mask,
IB_MGMT_MAX_METHODS);
i < IB_MGMT_MAX_METHODS;
i = find_next_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS,
1+i)) {
for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
(*method)->agent[i] = agent_priv;
}

return 0;

error3:
Expand Down Expand Up @@ -1429,13 +1422,9 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
goto error4;

/* Finally, add in methods being registered */
for (i = find_first_bit(mad_reg_req->method_mask,
IB_MGMT_MAX_METHODS);
i < IB_MGMT_MAX_METHODS;
i = find_next_bit(mad_reg_req->method_mask, IB_MGMT_MAX_METHODS,
1+i)) {
for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
(*method)->agent[i] = agent_priv;
}

return 0;

error4:
Expand Down

0 comments on commit 19b629f

Please sign in to comment.