Skip to content

Commit 3a7bda8

Browse files
davejiangJames Bottomley
authored andcommitted
[SCSI] isci: Adding documentation to API change and fixup sysfs registration
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 <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 4ac13e1 commit 3a7bda8

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
What: /sys/class/scsi_host/hostX/isci_id
2+
Date: June 2011
3+
Contact: Dave Jiang <dave.jiang@intel.com>
4+
Description:
5+
This file contains the enumerated host ID for the Intel
6+
SCU controller. The Intel(R) C600 Series Chipset SATA/SAS
7+
Storage Control Unit embeds up to two 4-port controllers in
8+
a single PCI device. The controllers are enumerated in order
9+
which usually means the lowest number scsi_host corresponds
10+
with the first controller, but this association is not
11+
guaranteed. The 'isci_id' attribute unambiguously identifies
12+
the controller index: '0' for the first controller,
13+
'1' for the second.

‎drivers/scsi/isci/init.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include <linux/firmware.h>
6060
#include <linux/efi.h>
6161
#include <asm/string.h>
62+
#include <scsi/scsi_host.h>
6263
#include "isci.h"
6364
#include "task.h"
6465
#include "probe_roms.h"
@@ -113,6 +114,22 @@ unsigned char max_concurr_spinup = 1;
113114
module_param(max_concurr_spinup, byte, 0);
114115
MODULE_PARM_DESC(max_concurr_spinup, "Max concurrent device spinup");
115116

117+
static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, char *buf)
118+
{
119+
struct Scsi_Host *shost = container_of(dev, typeof(*shost), shost_dev);
120+
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
121+
struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha);
122+
123+
return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id);
124+
}
125+
126+
static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
127+
128+
struct device_attribute *isci_host_attrs[] = {
129+
&dev_attr_isci_id,
130+
NULL
131+
};
132+
116133
static struct scsi_host_template isci_sht = {
117134

118135
.module = THIS_MODULE,
@@ -138,6 +155,7 @@ static struct scsi_host_template isci_sht = {
138155
.slave_alloc = sas_slave_alloc,
139156
.target_destroy = sas_target_destroy,
140157
.ioctl = sas_ioctl,
158+
.shost_attrs = isci_host_attrs,
141159
};
142160

143161
static struct sas_domain_function_template isci_transport_ops = {
@@ -232,17 +250,6 @@ static int isci_register_sas_ha(struct isci_host *isci_host)
232250
return 0;
233251
}
234252

235-
static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, char *buf)
236-
{
237-
struct Scsi_Host *shost = container_of(dev, typeof(*shost), shost_dev);
238-
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
239-
struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha);
240-
241-
return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id);
242-
}
243-
244-
static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
245-
246253
static void isci_unregister(struct isci_host *isci_host)
247254
{
248255
struct Scsi_Host *shost;
@@ -251,7 +258,6 @@ static void isci_unregister(struct isci_host *isci_host)
251258
return;
252259

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

256262
sas_unregister_ha(&isci_host->sas_ha);
257263

@@ -415,14 +421,8 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
415421
if (err)
416422
goto err_shost_remove;
417423

418-
err = device_create_file(&shost->shost_dev, &dev_attr_isci_id);
419-
if (err)
420-
goto err_unregister_ha;
421-
422424
return isci_host;
423425

424-
err_unregister_ha:
425-
sas_unregister_ha(&(isci_host->sas_ha));
426426
err_shost_remove:
427427
scsi_remove_host(shost);
428428
err_shost:

0 commit comments

Comments
 (0)