diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_vport.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_vport.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index c5918a643014..e066855b0783 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c | |||
@@ -176,16 +176,21 @@ static int | |||
176 | lpfc_unique_wwpn(struct lpfc_hba *phba, struct lpfc_vport *new_vport) | 176 | lpfc_unique_wwpn(struct lpfc_hba *phba, struct lpfc_vport *new_vport) |
177 | { | 177 | { |
178 | struct lpfc_vport *vport; | 178 | struct lpfc_vport *vport; |
179 | unsigned long flags; | ||
179 | 180 | ||
181 | spin_lock_irqsave(&phba->hbalock, flags); | ||
180 | list_for_each_entry(vport, &phba->port_list, listentry) { | 182 | list_for_each_entry(vport, &phba->port_list, listentry) { |
181 | if (vport == new_vport) | 183 | if (vport == new_vport) |
182 | continue; | 184 | continue; |
183 | /* If they match, return not unique */ | 185 | /* If they match, return not unique */ |
184 | if (memcmp(&vport->fc_sparam.portName, | 186 | if (memcmp(&vport->fc_sparam.portName, |
185 | &new_vport->fc_sparam.portName, | 187 | &new_vport->fc_sparam.portName, |
186 | sizeof(struct lpfc_name)) == 0) | 188 | sizeof(struct lpfc_name)) == 0) { |
189 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
187 | return 0; | 190 | return 0; |
191 | } | ||
188 | } | 192 | } |
193 | spin_unlock_irqrestore(&phba->hbalock, flags); | ||
189 | return 1; | 194 | return 1; |
190 | } | 195 | } |
191 | 196 | ||
@@ -524,6 +529,36 @@ out: | |||
524 | return rc; | 529 | return rc; |
525 | } | 530 | } |
526 | 531 | ||
527 | |||
528 | EXPORT_SYMBOL(lpfc_vport_create); | 532 | EXPORT_SYMBOL(lpfc_vport_create); |
529 | EXPORT_SYMBOL(lpfc_vport_delete); | 533 | EXPORT_SYMBOL(lpfc_vport_delete); |
534 | |||
535 | struct lpfc_vport ** | ||
536 | lpfc_create_vport_work_array(struct lpfc_hba *phba) | ||
537 | { | ||
538 | struct lpfc_vport *port_iterator; | ||
539 | struct lpfc_vport **vports; | ||
540 | int index = 0; | ||
541 | vports = kzalloc(LPFC_MAX_VPORTS * sizeof(struct lpfc_vport *), | ||
542 | GFP_KERNEL); | ||
543 | if (vports == NULL) | ||
544 | return NULL; | ||
545 | spin_lock_irq(&phba->hbalock); | ||
546 | list_for_each_entry(port_iterator, &phba->port_list, listentry) { | ||
547 | if (!scsi_host_get(lpfc_shost_from_vport(port_iterator))) | ||
548 | continue; | ||
549 | vports[index++] = port_iterator; | ||
550 | } | ||
551 | spin_unlock_irq(&phba->hbalock); | ||
552 | return vports; | ||
553 | } | ||
554 | |||
555 | void | ||
556 | lpfc_destroy_vport_work_array(struct lpfc_vport **vports) | ||
557 | { | ||
558 | int i; | ||
559 | if (vports == NULL) | ||
560 | return; | ||
561 | for (i=0; vports[i] != NULL && i < LPFC_MAX_VPORTS; i++) | ||
562 | scsi_host_put(lpfc_shost_from_vport(vports[i])); | ||
563 | kfree(vports); | ||
564 | } | ||