diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-03-10 00:01:43 -0800 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 03:55:30 -0700 |
commit | 34cad85d18d6da1cc11e410046d7572e65b19fcf (patch) | |
tree | 546ff7939cff6a7e61249f0e284f47835e6f4958 | |
parent | 6e2802a7fc246b53f919efbf1c011da2d0a4ff30 (diff) | |
download | linux-34cad85d18d6da1cc11e410046d7572e65b19fcf.tar.bz2 |
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.c | 30 |
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) return 0; } -static void isci_unregister_sas_ha(struct isci_host *isci_host) +static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, char *buf) { + struct Scsi_Host *shost = container_of(dev, typeof(*shost), shost_dev); + struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); + struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha); + + return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id); +} + +static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL); + +static void isci_unregister(struct isci_host *isci_host) +{ + struct Scsi_Host *shost; + if (!isci_host) return; - sas_unregister_ha(&(isci_host->sas_ha)); + shost = isci_host->shost; + device_remove_file(&shost->shost_dev, &dev_attr_isci_id); + + sas_unregister_ha(&isci_host->sas_ha); sas_remove_host(isci_host->shost); scsi_remove_host(isci_host->shost); @@ -477,8 +493,14 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) if (err) goto err_shost_remove; + err = device_create_file(&shost->shost_dev, &dev_attr_isci_id); + if (err) + goto err_unregister_ha; + return isci_host; + err_unregister_ha: + sas_unregister_ha(&(isci_host->sas_ha)); err_shost_remove: scsi_remove_host(shost); err_shost: @@ -640,7 +662,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic err_host_alloc: for_each_isci_host(i, isci_host, pdev) - isci_unregister_sas_ha(isci_host); + isci_unregister(isci_host); return err; } @@ -650,7 +672,7 @@ static void __devexit isci_pci_remove(struct pci_dev *pdev) int i; for_each_isci_host(i, isci_host, pdev) { - isci_unregister_sas_ha(isci_host); + isci_unregister(isci_host); isci_host_deinit(isci_host); scic_controller_disable_interrupts(isci_host->core_controller); } |