diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-03-07 19:02:25 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 06:55:29 -0400 |
commit | b329aff107543c3c4db26c1572405034c3baf906 (patch) | |
tree | 96a9a1f4faa899f8b384a50172bd49f160acb7f7 /drivers/scsi/isci | |
parent | 52bed8eab5d392183b77426b96551011f3521ef8 (diff) |
isci: kill isci_host list in favor of an array
isci_host_by_id() should have been a clue that an array would have been
a simpler approach.
Reported-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r-- | drivers/scsi/isci/host.c | 3 | ||||
-rw-r--r-- | drivers/scsi/isci/host.h | 10 | ||||
-rw-r--r-- | drivers/scsi/isci/init.c | 25 |
3 files changed, 14 insertions, 24 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 40614e9ab41b..da0c0da4198f 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -78,8 +78,9 @@ irqreturn_t isci_intx_isr(int vec, void *data) | |||
78 | struct pci_dev *pdev = data; | 78 | struct pci_dev *pdev = data; |
79 | struct isci_host *ihost; | 79 | struct isci_host *ihost; |
80 | irqreturn_t ret = IRQ_NONE; | 80 | irqreturn_t ret = IRQ_NONE; |
81 | int i; | ||
81 | 82 | ||
82 | for_each_isci_host(ihost, pdev) { | 83 | for_each_isci_host(i, ihost, pdev) { |
83 | struct scic_sds_controller *scic = ihost->core_controller; | 84 | struct scic_sds_controller *scic = ihost->core_controller; |
84 | 85 | ||
85 | if (scic_sds_controller_isr(scic)) { | 86 | if (scic_sds_controller_isr(scic)) { |
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h index ef3e7d1440b0..7c1f0b5cee7d 100644 --- a/drivers/scsi/isci/host.h +++ b/drivers/scsi/isci/host.h | |||
@@ -117,7 +117,6 @@ struct isci_host { | |||
117 | struct list_head requests_to_complete; | 117 | struct list_head requests_to_complete; |
118 | struct list_head requests_to_abort; | 118 | struct list_head requests_to_abort; |
119 | spinlock_t scic_lock; | 119 | spinlock_t scic_lock; |
120 | struct isci_host *next; | ||
121 | }; | 120 | }; |
122 | 121 | ||
123 | 122 | ||
@@ -131,7 +130,7 @@ struct isci_host { | |||
131 | struct isci_pci_info { | 130 | struct isci_pci_info { |
132 | struct msix_entry msix_entries[SCI_MAX_MSIX_INT]; | 131 | struct msix_entry msix_entries[SCI_MAX_MSIX_INT]; |
133 | int core_lib_array_index; | 132 | int core_lib_array_index; |
134 | struct isci_host *hosts; | 133 | struct isci_host *hosts[SCI_MAX_CONTROLLERS]; |
135 | }; | 134 | }; |
136 | 135 | ||
137 | static inline struct isci_pci_info *to_pci_info(struct pci_dev *pdev) | 136 | static inline struct isci_pci_info *to_pci_info(struct pci_dev *pdev) |
@@ -139,9 +138,10 @@ static inline struct isci_pci_info *to_pci_info(struct pci_dev *pdev) | |||
139 | return pci_get_drvdata(pdev); | 138 | return pci_get_drvdata(pdev); |
140 | } | 139 | } |
141 | 140 | ||
142 | #define for_each_isci_host(isci_host, pdev) \ | 141 | #define for_each_isci_host(id, ihost, pdev) \ |
143 | for (isci_host = to_pci_info(pdev)->hosts;\ | 142 | for (id = 0, ihost = to_pci_info(pdev)->hosts[id]; \ |
144 | isci_host; isci_host = isci_host->next) | 143 | id < ARRAY_SIZE(to_pci_info(pdev)->hosts) && ihost; \ |
144 | ihost = to_pci_info(pdev)->hosts[++id]) | ||
145 | 145 | ||
146 | static inline | 146 | static inline |
147 | enum isci_status isci_host_get_state( | 147 | enum isci_status isci_host_get_state( |
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index d01c44f5be99..f1b8a51dd49f 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c | |||
@@ -285,16 +285,6 @@ static int __devinit isci_pci_init(struct pci_dev *pdev) | |||
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static struct isci_host *isci_host_by_id(struct pci_dev *pdev, int id) | ||
289 | { | ||
290 | struct isci_host *h; | ||
291 | |||
292 | for_each_isci_host(h, pdev) | ||
293 | if (h->id == id) | ||
294 | return h; | ||
295 | return NULL; | ||
296 | } | ||
297 | |||
298 | static int num_controllers(struct pci_dev *pdev) | 288 | static int num_controllers(struct pci_dev *pdev) |
299 | { | 289 | { |
300 | /* bar size alone can tell us if we are running with a dual controller | 290 | /* bar size alone can tell us if we are running with a dual controller |
@@ -332,7 +322,7 @@ static int isci_setup_interrupts(struct pci_dev *pdev) | |||
332 | for (i = 0; i < num_msix; i++) { | 322 | for (i = 0; i < num_msix; i++) { |
333 | int id = i / SCI_NUM_MSI_X_INT; | 323 | int id = i / SCI_NUM_MSI_X_INT; |
334 | struct msix_entry *msix = &pci_info->msix_entries[i]; | 324 | struct msix_entry *msix = &pci_info->msix_entries[i]; |
335 | struct isci_host *isci_host = isci_host_by_id(pdev, id); | 325 | struct isci_host *isci_host = pci_info->hosts[id]; |
336 | irq_handler_t isr; | 326 | irq_handler_t isr; |
337 | 327 | ||
338 | /* odd numbered vectors are error interrupts */ | 328 | /* odd numbered vectors are error interrupts */ |
@@ -351,7 +341,7 @@ static int isci_setup_interrupts(struct pci_dev *pdev) | |||
351 | dev_info(&pdev->dev, "msix setup failed falling back to intx\n"); | 341 | dev_info(&pdev->dev, "msix setup failed falling back to intx\n"); |
352 | while (i--) { | 342 | while (i--) { |
353 | id = i / SCI_NUM_MSI_X_INT; | 343 | id = i / SCI_NUM_MSI_X_INT; |
354 | isci_host = isci_host_by_id(pdev, id); | 344 | isci_host = pci_info->hosts[id]; |
355 | msix = &pci_info->msix_entries[i]; | 345 | msix = &pci_info->msix_entries[i]; |
356 | devm_free_irq(&pdev->dev, msix->vector, isci_host); | 346 | devm_free_irq(&pdev->dev, msix->vector, isci_host); |
357 | } | 347 | } |
@@ -634,22 +624,20 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic | |||
634 | err = -ENOMEM; | 624 | err = -ENOMEM; |
635 | goto err_host_alloc; | 625 | goto err_host_alloc; |
636 | } | 626 | } |
637 | 627 | pci_info->hosts[i] = h; | |
638 | h->next = pci_info->hosts; | ||
639 | pci_info->hosts = h; | ||
640 | } | 628 | } |
641 | 629 | ||
642 | err = isci_setup_interrupts(pdev); | 630 | err = isci_setup_interrupts(pdev); |
643 | if (err) | 631 | if (err) |
644 | goto err_host_alloc; | 632 | goto err_host_alloc; |
645 | 633 | ||
646 | for_each_isci_host(isci_host, pdev) | 634 | for_each_isci_host(i, isci_host, pdev) |
647 | scsi_scan_host(isci_host->shost); | 635 | scsi_scan_host(isci_host->shost); |
648 | 636 | ||
649 | return 0; | 637 | return 0; |
650 | 638 | ||
651 | err_host_alloc: | 639 | err_host_alloc: |
652 | for_each_isci_host(isci_host, pdev) | 640 | for_each_isci_host(i, isci_host, pdev) |
653 | isci_unregister_sas_ha(isci_host); | 641 | isci_unregister_sas_ha(isci_host); |
654 | return err; | 642 | return err; |
655 | } | 643 | } |
@@ -657,8 +645,9 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic | |||
657 | static void __devexit isci_pci_remove(struct pci_dev *pdev) | 645 | static void __devexit isci_pci_remove(struct pci_dev *pdev) |
658 | { | 646 | { |
659 | struct isci_host *isci_host; | 647 | struct isci_host *isci_host; |
648 | int i; | ||
660 | 649 | ||
661 | for_each_isci_host(isci_host, pdev) { | 650 | for_each_isci_host(i, isci_host, pdev) { |
662 | isci_unregister_sas_ha(isci_host); | 651 | isci_unregister_sas_ha(isci_host); |
663 | isci_host_deinit(isci_host); | 652 | isci_host_deinit(isci_host); |
664 | scic_controller_disable_interrupts(isci_host->core_controller); | 653 | scic_controller_disable_interrupts(isci_host->core_controller); |