diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mid.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mid.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 821ee74aadc6..74096aaa693c 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c | |||
@@ -47,16 +47,15 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha) | |||
47 | 47 | ||
48 | /* Find an empty slot and assign an vp_id */ | 48 | /* Find an empty slot and assign an vp_id */ |
49 | down(&ha->vport_sem); | 49 | down(&ha->vport_sem); |
50 | vp_id = find_first_zero_bit((unsigned long *)ha->vp_idx_map, | 50 | vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1); |
51 | MAX_MULTI_ID_FABRIC); | 51 | if (vp_id > ha->max_npiv_vports) { |
52 | if (vp_id > MAX_MULTI_ID_FABRIC) { | 52 | DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n", |
53 | DEBUG15(printk ("vp_id %d is bigger than MAX_MULTI_ID_FABRID\n", | 53 | vp_id, ha->max_npiv_vports)); |
54 | vp_id)); | ||
55 | up(&ha->vport_sem); | 54 | up(&ha->vport_sem); |
56 | return vp_id; | 55 | return vp_id; |
57 | } | 56 | } |
58 | 57 | ||
59 | set_bit(vp_id, (unsigned long *)ha->vp_idx_map); | 58 | set_bit(vp_id, ha->vp_idx_map); |
60 | ha->num_vhosts++; | 59 | ha->num_vhosts++; |
61 | vha->vp_idx = vp_id; | 60 | vha->vp_idx = vp_id; |
62 | list_add_tail(&vha->vp_list, &ha->vp_list); | 61 | list_add_tail(&vha->vp_list, &ha->vp_list); |
@@ -73,7 +72,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha) | |||
73 | down(&ha->vport_sem); | 72 | down(&ha->vport_sem); |
74 | vp_id = vha->vp_idx; | 73 | vp_id = vha->vp_idx; |
75 | ha->num_vhosts--; | 74 | ha->num_vhosts--; |
76 | clear_bit(vp_id, (unsigned long *)ha->vp_idx_map); | 75 | clear_bit(vp_id, ha->vp_idx_map); |
77 | list_del(&vha->vp_list); | 76 | list_del(&vha->vp_list); |
78 | up(&ha->vport_sem); | 77 | up(&ha->vport_sem); |
79 | } | 78 | } |
@@ -216,11 +215,7 @@ qla2x00_alert_all_vps(scsi_qla_host_t *ha, uint16_t *mb) | |||
216 | if (ha->parent) | 215 | if (ha->parent) |
217 | return; | 216 | return; |
218 | 217 | ||
219 | i = find_next_bit((unsigned long *)ha->vp_idx_map, | 218 | for_each_mapped_vp_idx(ha, i) { |
220 | MAX_MULTI_ID_FABRIC + 1, 1); | ||
221 | for (;i <= MAX_MULTI_ID_FABRIC; | ||
222 | i = find_next_bit((unsigned long *)ha->vp_idx_map, | ||
223 | MAX_MULTI_ID_FABRIC + 1, i + 1)) { | ||
224 | vp_idx_matched = 0; | 219 | vp_idx_matched = 0; |
225 | 220 | ||
226 | list_for_each_entry(vha, &ha->vp_list, vp_list) { | 221 | list_for_each_entry(vha, &ha->vp_list, vp_list) { |
@@ -311,11 +306,7 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *ha) | |||
311 | 306 | ||
312 | clear_bit(VP_DPC_NEEDED, &ha->dpc_flags); | 307 | clear_bit(VP_DPC_NEEDED, &ha->dpc_flags); |
313 | 308 | ||
314 | i = find_next_bit((unsigned long *)ha->vp_idx_map, | 309 | for_each_mapped_vp_idx(ha, i) { |
315 | MAX_MULTI_ID_FABRIC + 1, 1); | ||
316 | for (;i <= MAX_MULTI_ID_FABRIC; | ||
317 | i = find_next_bit((unsigned long *)ha->vp_idx_map, | ||
318 | MAX_MULTI_ID_FABRIC + 1, i + 1)) { | ||
319 | vp_idx_matched = 0; | 310 | vp_idx_matched = 0; |
320 | 311 | ||
321 | list_for_each_entry(vha, &ha->vp_list, vp_list) { | 312 | list_for_each_entry(vha, &ha->vp_list, vp_list) { |
@@ -356,9 +347,9 @@ qla24xx_vport_create_req_sanity_check(struct fc_vport *fc_vport) | |||
356 | 347 | ||
357 | /* Check up max-npiv-supports */ | 348 | /* Check up max-npiv-supports */ |
358 | if (ha->num_vhosts > ha->max_npiv_vports) { | 349 | if (ha->num_vhosts > ha->max_npiv_vports) { |
359 | DEBUG15(printk("scsi(%ld): num_vhosts %d is bigger than " | 350 | DEBUG15(printk("scsi(%ld): num_vhosts %ud is bigger than " |
360 | "max_npv_vports %d.\n", ha->host_no, | 351 | "max_npv_vports %ud.\n", ha->host_no, |
361 | (uint16_t) ha->num_vhosts, (int) ha->max_npiv_vports)); | 352 | ha->num_vhosts, ha->max_npiv_vports)); |
362 | return VPCERR_UNSUPPORTED; | 353 | return VPCERR_UNSUPPORTED; |
363 | } | 354 | } |
364 | return 0; | 355 | return 0; |
@@ -450,7 +441,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) | |||
450 | num_hosts++; | 441 | num_hosts++; |
451 | 442 | ||
452 | down(&ha->vport_sem); | 443 | down(&ha->vport_sem); |
453 | set_bit(vha->vp_idx, (unsigned long *)ha->vp_idx_map); | 444 | set_bit(vha->vp_idx, ha->vp_idx_map); |
454 | ha->cur_vport_count++; | 445 | ha->cur_vport_count++; |
455 | up(&ha->vport_sem); | 446 | up(&ha->vport_sem); |
456 | 447 | ||