aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-03-10 03:01:43 -0500
committerDan Williams <dan.j.williams@intel.com>2011-07-03 06:55:30 -0400
commit34cad85d18d6da1cc11e410046d7572e65b19fcf (patch)
tree546ff7939cff6a7e61249f0e284f47835e6f4958
parent6e2802a7fc246b53f919efbf1c011da2d0a4ff30 (diff)
isci: add "isci_id" attribute
Allow each controller to be identified via sysfs. # cat /sys/class/scsi_host/host13/isci_id 1 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/init.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index 2838beff43b8..3f2bb137bcb1 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -229,12 +229,28 @@ static int isci_register_sas_ha(struct isci_host *isci_host)
229 return 0; 229 return 0;
230} 230}
231 231
232static void isci_unregister_sas_ha(struct isci_host *isci_host) 232static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, char *buf)
233{ 233{
234 struct Scsi_Host *shost = container_of(dev, typeof(*shost), shost_dev);
235 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
236 struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha);
237
238 return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id);
239}
240
241static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
242
243static void isci_unregister(struct isci_host *isci_host)
244{
245 struct Scsi_Host *shost;
246
234 if (!isci_host) 247 if (!isci_host)
235 return; 248 return;
236 249
237 sas_unregister_ha(&(isci_host->sas_ha)); 250 shost = isci_host->shost;
251 device_remove_file(&shost->shost_dev, &dev_attr_isci_id);
252
253 sas_unregister_ha(&isci_host->sas_ha);
238 254
239 sas_remove_host(isci_host->shost); 255 sas_remove_host(isci_host->shost);
240 scsi_remove_host(isci_host->shost); 256 scsi_remove_host(isci_host->shost);
@@ -477,8 +493,14 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
477 if (err) 493 if (err)
478 goto err_shost_remove; 494 goto err_shost_remove;
479 495
496 err = device_create_file(&shost->shost_dev, &dev_attr_isci_id);
497 if (err)
498 goto err_unregister_ha;
499
480 return isci_host; 500 return isci_host;
481 501
502 err_unregister_ha:
503 sas_unregister_ha(&(isci_host->sas_ha));
482 err_shost_remove: 504 err_shost_remove:
483 scsi_remove_host(shost); 505 scsi_remove_host(shost);
484 err_shost: 506 err_shost:
@@ -640,7 +662,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
640 662
641 err_host_alloc: 663 err_host_alloc:
642 for_each_isci_host(i, isci_host, pdev) 664 for_each_isci_host(i, isci_host, pdev)
643 isci_unregister_sas_ha(isci_host); 665 isci_unregister(isci_host);
644 return err; 666 return err;
645} 667}
646 668
@@ -650,7 +672,7 @@ static void __devexit isci_pci_remove(struct pci_dev *pdev)
650 int i; 672 int i;
651 673
652 for_each_isci_host(i, isci_host, pdev) { 674 for_each_isci_host(i, isci_host, pdev) {
653 isci_unregister_sas_ha(isci_host); 675 isci_unregister(isci_host);
654 isci_host_deinit(isci_host); 676 isci_host_deinit(isci_host);
655 scic_controller_disable_interrupts(isci_host->core_controller); 677 scic_controller_disable_interrupts(isci_host->core_controller);
656 } 678 }