aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ipr.c
diff options
context:
space:
mode:
authorWayne Boyer <wayneb@linux.vnet.ibm.com>2010-08-11 10:15:17 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-09-05 13:33:42 -0400
commit46d7456324766cd291d7ccd5b4927cbd3c28fb1b (patch)
treef77d0cd8507a560ad626328af75b9ecc3cf8de63 /drivers/scsi/ipr.c
parent6f7efaabefebfbc523ea9776e3663a2d81b86399 (diff)
[SCSI] ipr: fix resource address formatting and add attribute for device ID
This patch fixes a resource address formatting problem where the first byte was being zeroed out. Also, the device ID is now made available as a sysfs attribute. Signed-off-by: Wayne Boyer <wayneb@linux.vnet.ibm.com> Acked-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/ipr.c')
-rw-r--r--drivers/scsi/ipr.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 52568588039f..67875d41345f 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -1096,6 +1096,7 @@ static void ipr_init_res_entry(struct ipr_resource_entry *res,
1096 res->bus = cfgtew->u.cfgte->res_addr.bus; 1096 res->bus = cfgtew->u.cfgte->res_addr.bus;
1097 res->target = cfgtew->u.cfgte->res_addr.target; 1097 res->target = cfgtew->u.cfgte->res_addr.target;
1098 res->lun = cfgtew->u.cfgte->res_addr.lun; 1098 res->lun = cfgtew->u.cfgte->res_addr.lun;
1099 res->lun_wwn = get_unaligned_be64(cfgtew->u.cfgte->lun_wwn);
1099 } 1100 }
1100 1101
1101 ipr_update_ata_class(res, proto); 1102 ipr_update_ata_class(res, proto);
@@ -1142,7 +1143,7 @@ static char *ipr_format_res_path(u8 *res_path, char *buffer, int len)
1142 int i; 1143 int i;
1143 char *p = buffer; 1144 char *p = buffer;
1144 1145
1145 res_path[0] = '\0'; 1146 *p = '\0';
1146 p += snprintf(p, buffer + len - p, "%02X", res_path[0]); 1147 p += snprintf(p, buffer + len - p, "%02X", res_path[0]);
1147 for (i = 1; res_path[i] != 0xff && ((i * 3) < len); i++) 1148 for (i = 1; res_path[i] != 0xff && ((i * 3) < len); i++)
1148 p += snprintf(p, buffer + len - p, "-%02X", res_path[i]); 1149 p += snprintf(p, buffer + len - p, "-%02X", res_path[i]);
@@ -4089,6 +4090,7 @@ static int ipr_change_queue_type(struct scsi_device *sdev, int tag_type)
4089/** 4090/**
4090 * ipr_show_adapter_handle - Show the adapter's resource handle for this device 4091 * ipr_show_adapter_handle - Show the adapter's resource handle for this device
4091 * @dev: device struct 4092 * @dev: device struct
4093 * @attr: device attribute structure
4092 * @buf: buffer 4094 * @buf: buffer
4093 * 4095 *
4094 * Return value: 4096 * Return value:
@@ -4122,6 +4124,7 @@ static struct device_attribute ipr_adapter_handle_attr = {
4122 * ipr_show_resource_path - Show the resource path or the resource address for 4124 * ipr_show_resource_path - Show the resource path or the resource address for
4123 * this device. 4125 * this device.
4124 * @dev: device struct 4126 * @dev: device struct
4127 * @attr: device attribute structure
4125 * @buf: buffer 4128 * @buf: buffer
4126 * 4129 *
4127 * Return value: 4130 * Return value:
@@ -4159,8 +4162,45 @@ static struct device_attribute ipr_resource_path_attr = {
4159}; 4162};
4160 4163
4161/** 4164/**
4165 * ipr_show_device_id - Show the device_id for this device.
4166 * @dev: device struct
4167 * @attr: device attribute structure
4168 * @buf: buffer
4169 *
4170 * Return value:
4171 * number of bytes printed to buffer
4172 **/
4173static ssize_t ipr_show_device_id(struct device *dev, struct device_attribute *attr, char *buf)
4174{
4175 struct scsi_device *sdev = to_scsi_device(dev);
4176 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata;
4177 struct ipr_resource_entry *res;
4178 unsigned long lock_flags = 0;
4179 ssize_t len = -ENXIO;
4180
4181 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
4182 res = (struct ipr_resource_entry *)sdev->hostdata;
4183 if (res && ioa_cfg->sis64)
4184 len = snprintf(buf, PAGE_SIZE, "0x%llx\n", res->dev_id);
4185 else if (res)
4186 len = snprintf(buf, PAGE_SIZE, "0x%llx\n", res->lun_wwn);
4187
4188 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
4189 return len;
4190}
4191
4192static struct device_attribute ipr_device_id_attr = {
4193 .attr = {
4194 .name = "device_id",
4195 .mode = S_IRUGO,
4196 },
4197 .show = ipr_show_device_id
4198};
4199
4200/**
4162 * ipr_show_resource_type - Show the resource type for this device. 4201 * ipr_show_resource_type - Show the resource type for this device.
4163 * @dev: device struct 4202 * @dev: device struct
4203 * @attr: device attribute structure
4164 * @buf: buffer 4204 * @buf: buffer
4165 * 4205 *
4166 * Return value: 4206 * Return value:
@@ -4195,6 +4235,7 @@ static struct device_attribute ipr_resource_type_attr = {
4195static struct device_attribute *ipr_dev_attrs[] = { 4235static struct device_attribute *ipr_dev_attrs[] = {
4196 &ipr_adapter_handle_attr, 4236 &ipr_adapter_handle_attr,
4197 &ipr_resource_path_attr, 4237 &ipr_resource_path_attr,
4238 &ipr_device_id_attr,
4198 &ipr_resource_type_attr, 4239 &ipr_resource_type_attr,
4199 NULL, 4240 NULL,
4200}; 4241};