diff options
author | Wayne Boyer <wayneb@linux.vnet.ibm.com> | 2010-07-14 13:50:14 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:05:40 -0400 |
commit | 75576bb9b208d7c66822f310cdef9ca2d72c879c (patch) | |
tree | 3923b4c3604edcc37589bd140ea2ffc6afa5b1ca | |
parent | 1df79ca4223632113f14618833b8bb1727a8ca15 (diff) |
[SCSI] ipr: fix resource type update and add sdev and shost attributes
Setting the resource type in the ipr_update_res_entry function was incorrect in
that the top 4 bits were masked off. The assignment has been updated to no
longer mask those bits.
Then, two new attributes were added to allow the user space utilities to more
easily get information. The resource_type sdev attribute is set for all devices
in the adapter's configuration table and indicates the type of device. The
fw_type shost attribute indicates the firmware type supported by the adapter.
Finally, the resource_path attribute was changed to be mode S_IRUGO.
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>
-rw-r--r-- | drivers/scsi/ipr.c | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index f73007db2bec..52568588039f 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -1168,7 +1168,7 @@ static void ipr_update_res_entry(struct ipr_resource_entry *res, | |||
1168 | if (res->ioa_cfg->sis64) { | 1168 | if (res->ioa_cfg->sis64) { |
1169 | res->flags = cfgtew->u.cfgte64->flags; | 1169 | res->flags = cfgtew->u.cfgte64->flags; |
1170 | res->res_flags = cfgtew->u.cfgte64->res_flags; | 1170 | res->res_flags = cfgtew->u.cfgte64->res_flags; |
1171 | res->type = cfgtew->u.cfgte64->res_type & 0x0f; | 1171 | res->type = cfgtew->u.cfgte64->res_type; |
1172 | 1172 | ||
1173 | memcpy(&res->std_inq_data, &cfgtew->u.cfgte64->std_inq_data, | 1173 | memcpy(&res->std_inq_data, &cfgtew->u.cfgte64->std_inq_data, |
1174 | sizeof(struct ipr_std_inq_data)); | 1174 | sizeof(struct ipr_std_inq_data)); |
@@ -3762,6 +3762,36 @@ static struct device_attribute ipr_update_fw_attr = { | |||
3762 | .store = ipr_store_update_fw | 3762 | .store = ipr_store_update_fw |
3763 | }; | 3763 | }; |
3764 | 3764 | ||
3765 | /** | ||
3766 | * ipr_show_fw_type - Show the adapter's firmware type. | ||
3767 | * @dev: class device struct | ||
3768 | * @buf: buffer | ||
3769 | * | ||
3770 | * Return value: | ||
3771 | * number of bytes printed to buffer | ||
3772 | **/ | ||
3773 | static ssize_t ipr_show_fw_type(struct device *dev, | ||
3774 | struct device_attribute *attr, char *buf) | ||
3775 | { | ||
3776 | struct Scsi_Host *shost = class_to_shost(dev); | ||
3777 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; | ||
3778 | unsigned long lock_flags = 0; | ||
3779 | int len; | ||
3780 | |||
3781 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
3782 | len = snprintf(buf, PAGE_SIZE, "%d\n", ioa_cfg->sis64); | ||
3783 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
3784 | return len; | ||
3785 | } | ||
3786 | |||
3787 | static struct device_attribute ipr_ioa_fw_type_attr = { | ||
3788 | .attr = { | ||
3789 | .name = "fw_type", | ||
3790 | .mode = S_IRUGO, | ||
3791 | }, | ||
3792 | .show = ipr_show_fw_type | ||
3793 | }; | ||
3794 | |||
3765 | static struct device_attribute *ipr_ioa_attrs[] = { | 3795 | static struct device_attribute *ipr_ioa_attrs[] = { |
3766 | &ipr_fw_version_attr, | 3796 | &ipr_fw_version_attr, |
3767 | &ipr_log_level_attr, | 3797 | &ipr_log_level_attr, |
@@ -3769,6 +3799,7 @@ static struct device_attribute *ipr_ioa_attrs[] = { | |||
3769 | &ipr_ioa_state_attr, | 3799 | &ipr_ioa_state_attr, |
3770 | &ipr_ioa_reset_attr, | 3800 | &ipr_ioa_reset_attr, |
3771 | &ipr_update_fw_attr, | 3801 | &ipr_update_fw_attr, |
3802 | &ipr_ioa_fw_type_attr, | ||
3772 | NULL, | 3803 | NULL, |
3773 | }; | 3804 | }; |
3774 | 3805 | ||
@@ -4122,14 +4153,49 @@ static ssize_t ipr_show_resource_path(struct device *dev, struct device_attribut | |||
4122 | static struct device_attribute ipr_resource_path_attr = { | 4153 | static struct device_attribute ipr_resource_path_attr = { |
4123 | .attr = { | 4154 | .attr = { |
4124 | .name = "resource_path", | 4155 | .name = "resource_path", |
4125 | .mode = S_IRUSR, | 4156 | .mode = S_IRUGO, |
4126 | }, | 4157 | }, |
4127 | .show = ipr_show_resource_path | 4158 | .show = ipr_show_resource_path |
4128 | }; | 4159 | }; |
4129 | 4160 | ||
4161 | /** | ||
4162 | * ipr_show_resource_type - Show the resource type for this device. | ||
4163 | * @dev: device struct | ||
4164 | * @buf: buffer | ||
4165 | * | ||
4166 | * Return value: | ||
4167 | * number of bytes printed to buffer | ||
4168 | **/ | ||
4169 | static ssize_t ipr_show_resource_type(struct device *dev, struct device_attribute *attr, char *buf) | ||
4170 | { | ||
4171 | struct scsi_device *sdev = to_scsi_device(dev); | ||
4172 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata; | ||
4173 | struct ipr_resource_entry *res; | ||
4174 | unsigned long lock_flags = 0; | ||
4175 | ssize_t len = -ENXIO; | ||
4176 | |||
4177 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
4178 | res = (struct ipr_resource_entry *)sdev->hostdata; | ||
4179 | |||
4180 | if (res) | ||
4181 | len = snprintf(buf, PAGE_SIZE, "%x\n", res->type); | ||
4182 | |||
4183 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
4184 | return len; | ||
4185 | } | ||
4186 | |||
4187 | static struct device_attribute ipr_resource_type_attr = { | ||
4188 | .attr = { | ||
4189 | .name = "resource_type", | ||
4190 | .mode = S_IRUGO, | ||
4191 | }, | ||
4192 | .show = ipr_show_resource_type | ||
4193 | }; | ||
4194 | |||
4130 | static struct device_attribute *ipr_dev_attrs[] = { | 4195 | static struct device_attribute *ipr_dev_attrs[] = { |
4131 | &ipr_adapter_handle_attr, | 4196 | &ipr_adapter_handle_attr, |
4132 | &ipr_resource_path_attr, | 4197 | &ipr_resource_path_attr, |
4198 | &ipr_resource_type_attr, | ||
4133 | NULL, | 4199 | NULL, |
4134 | }; | 4200 | }; |
4135 | 4201 | ||