Skip to content

Commit

Permalink
[SCSI] isci: Adding documentation to API change and fixup sysfs regis…
Browse files Browse the repository at this point in the history
…tration

Adding API update for adding isci_id entry scsi_host sysfs entry.
Also fixing up the sysfs registration to the scsi_host template

Signed-off-by: Dave Jiang <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
davejiang authored and James Bottomley committed Aug 24, 2011
1 parent 4ac13e1 commit 3a7bda8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
13 changes: 13 additions & 0 deletions Documentation/ABI/testing/sysfs-class-scsi_host
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
What: /sys/class/scsi_host/hostX/isci_id
Date: June 2011
Contact: Dave Jiang <[email protected]>
Description:
This file contains the enumerated host ID for the Intel
SCU controller. The Intel(R) C600 Series Chipset SATA/SAS
Storage Control Unit embeds up to two 4-port controllers in
a single PCI device. The controllers are enumerated in order
which usually means the lowest number scsi_host corresponds
with the first controller, but this association is not
guaranteed. The 'isci_id' attribute unambiguously identifies
the controller index: '0' for the first controller,
'1' for the second.
36 changes: 18 additions & 18 deletions drivers/scsi/isci/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <linux/firmware.h>
#include <linux/efi.h>
#include <asm/string.h>
#include <scsi/scsi_host.h>
#include "isci.h"
#include "task.h"
#include "probe_roms.h"
Expand Down Expand Up @@ -113,6 +114,22 @@ unsigned char max_concurr_spinup = 1;
module_param(max_concurr_spinup, byte, 0);
MODULE_PARM_DESC(max_concurr_spinup, "Max concurrent device spinup");

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);

struct device_attribute *isci_host_attrs[] = {
&dev_attr_isci_id,
NULL
};

static struct scsi_host_template isci_sht = {

.module = THIS_MODULE,
Expand All @@ -138,6 +155,7 @@ static struct scsi_host_template isci_sht = {
.slave_alloc = sas_slave_alloc,
.target_destroy = sas_target_destroy,
.ioctl = sas_ioctl,
.shost_attrs = isci_host_attrs,
};

static struct sas_domain_function_template isci_transport_ops = {
Expand Down Expand Up @@ -232,17 +250,6 @@ static int isci_register_sas_ha(struct isci_host *isci_host)
return 0;
}

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;
Expand All @@ -251,7 +258,6 @@ static void isci_unregister(struct isci_host *isci_host)
return;

shost = isci_host->shost;
device_remove_file(&shost->shost_dev, &dev_attr_isci_id);

sas_unregister_ha(&isci_host->sas_ha);

Expand Down Expand Up @@ -415,14 +421,8 @@ 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:
Expand Down

0 comments on commit 3a7bda8

Please sign in to comment.