summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-03-07 16:02:25 -0800
committerDan Williams <dan.j.williams@intel.com>2011-07-03 03:55:29 -0700
commitb329aff107543c3c4db26c1572405034c3baf906 (patch)
tree96a9a1f4faa899f8b384a50172bd49f160acb7f7
parent52bed8eab5d392183b77426b96551011f3521ef8 (diff)
downloadop-kernel-dev-b329aff107543c3c4db26c1572405034c3baf906.zip
op-kernel-dev-b329aff107543c3c4db26c1572405034c3baf906.tar.gz
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>
-rw-r--r--drivers/scsi/isci/host.c3
-rw-r--r--drivers/scsi/isci/host.h10
-rw-r--r--drivers/scsi/isci/init.c25
3 files changed, 14 insertions, 24 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 40614e9..da0c0da 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)
struct pci_dev *pdev = data;
struct isci_host *ihost;
irqreturn_t ret = IRQ_NONE;
+ int i;
- for_each_isci_host(ihost, pdev) {
+ for_each_isci_host(i, ihost, pdev) {
struct scic_sds_controller *scic = ihost->core_controller;
if (scic_sds_controller_isr(scic)) {
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index ef3e7d1..7c1f0b5 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -117,7 +117,6 @@ struct isci_host {
struct list_head requests_to_complete;
struct list_head requests_to_abort;
spinlock_t scic_lock;
- struct isci_host *next;
};
@@ -131,7 +130,7 @@ struct isci_host {
struct isci_pci_info {
struct msix_entry msix_entries[SCI_MAX_MSIX_INT];
int core_lib_array_index;
- struct isci_host *hosts;
+ struct isci_host *hosts[SCI_MAX_CONTROLLERS];
};
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)
return pci_get_drvdata(pdev);
}
-#define for_each_isci_host(isci_host, pdev) \
- for (isci_host = to_pci_info(pdev)->hosts;\
- isci_host; isci_host = isci_host->next)
+#define for_each_isci_host(id, ihost, pdev) \
+ for (id = 0, ihost = to_pci_info(pdev)->hosts[id]; \
+ id < ARRAY_SIZE(to_pci_info(pdev)->hosts) && ihost; \
+ ihost = to_pci_info(pdev)->hosts[++id])
static inline
enum isci_status isci_host_get_state(
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index d01c44f..f1b8a51 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)
return 0;
}
-static struct isci_host *isci_host_by_id(struct pci_dev *pdev, int id)
-{
- struct isci_host *h;
-
- for_each_isci_host(h, pdev)
- if (h->id == id)
- return h;
- return NULL;
-}
-
static int num_controllers(struct pci_dev *pdev)
{
/* 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)
for (i = 0; i < num_msix; i++) {
int id = i / SCI_NUM_MSI_X_INT;
struct msix_entry *msix = &pci_info->msix_entries[i];
- struct isci_host *isci_host = isci_host_by_id(pdev, id);
+ struct isci_host *isci_host = pci_info->hosts[id];
irq_handler_t isr;
/* odd numbered vectors are error interrupts */
@@ -351,7 +341,7 @@ static int isci_setup_interrupts(struct pci_dev *pdev)
dev_info(&pdev->dev, "msix setup failed falling back to intx\n");
while (i--) {
id = i / SCI_NUM_MSI_X_INT;
- isci_host = isci_host_by_id(pdev, id);
+ isci_host = pci_info->hosts[id];
msix = &pci_info->msix_entries[i];
devm_free_irq(&pdev->dev, msix->vector, isci_host);
}
@@ -634,22 +624,20 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
err = -ENOMEM;
goto err_host_alloc;
}
-
- h->next = pci_info->hosts;
- pci_info->hosts = h;
+ pci_info->hosts[i] = h;
}
err = isci_setup_interrupts(pdev);
if (err)
goto err_host_alloc;
- for_each_isci_host(isci_host, pdev)
+ for_each_isci_host(i, isci_host, pdev)
scsi_scan_host(isci_host->shost);
return 0;
err_host_alloc:
- for_each_isci_host(isci_host, pdev)
+ for_each_isci_host(i, isci_host, pdev)
isci_unregister_sas_ha(isci_host);
return err;
}
@@ -657,8 +645,9 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
static void __devexit isci_pci_remove(struct pci_dev *pdev)
{
struct isci_host *isci_host;
+ int i;
- for_each_isci_host(isci_host, pdev) {
+ for_each_isci_host(i, isci_host, pdev) {
isci_unregister_sas_ha(isci_host);
isci_host_deinit(isci_host);
scic_controller_disable_interrupts(isci_host->core_controller);
OpenPOWER on IntegriCloud