aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_sysfs.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2010-09-08 08:39:53 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-09-16 22:54:16 -0400
commite4b9857fe628b453983cac89473a11a76a1f5786 (patch)
tree12ea296e5e57d71dca024b0c7464f6d663e8b26d /drivers/s390/scsi/zfcp_sysfs.c
parent1daa4eb50fa5cd4c8f9c55452606e786fd42053b (diff)
[SCSI] zfcp: Remove ZFCP_SYSFS_FAILED macro and implement fcp_lun_show without macro
These sysfs attributes will require different functions. Implement them without using macros, so that the open coded functions can be changed later. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs.c')
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c121
1 files changed, 77 insertions, 44 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 56c46e09d2d4..6b43bc46bf97 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -82,49 +82,73 @@ ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n",
82 (atomic_read(&unit->status) & 82 (atomic_read(&unit->status) &
83 ZFCP_STATUS_UNIT_READONLY) != 0); 83 ZFCP_STATUS_UNIT_READONLY) != 0);
84 84
85#define ZFCP_SYSFS_FAILED(_feat_def, _feat, _adapter, _mod_id, _reopen_id) \ 85static ssize_t zfcp_sysfs_port_failed_show(struct device *dev,
86static ssize_t zfcp_sysfs_##_feat##_failed_show(struct device *dev, \ 86 struct device_attribute *attr,
87 struct device_attribute *attr, \ 87 char *buf)
88 char *buf) \ 88{
89{ \ 89 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
90 struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \
91 \
92 if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_ERP_FAILED) \
93 return sprintf(buf, "1\n"); \
94 else \
95 return sprintf(buf, "0\n"); \
96} \
97static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
98 struct device_attribute *attr,\
99 const char *buf, size_t count)\
100{ \
101 struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \
102 unsigned long val; \
103 int retval = 0; \
104 \
105 if (!(_feat && get_device(&_feat->dev))) \
106 return -EBUSY; \
107 \
108 if (strict_strtoul(buf, 0, &val) || val != 0) { \
109 retval = -EINVAL; \
110 goto out; \
111 } \
112 \
113 zfcp_erp_modify_##_feat##_status(_feat, _mod_id, NULL, \
114 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);\
115 zfcp_erp_##_feat##_reopen(_feat, ZFCP_STATUS_COMMON_ERP_FAILED, \
116 _reopen_id, NULL); \
117 zfcp_erp_wait(_adapter); \
118out: \
119 put_device(&_feat->dev); \
120 return retval ? retval : (ssize_t) count; \
121} \
122static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \
123 zfcp_sysfs_##_feat##_failed_show, \
124 zfcp_sysfs_##_feat##_failed_store);
125 90
126ZFCP_SYSFS_FAILED(zfcp_port, port, port->adapter, "sypfai1", "sypfai2"); 91 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
127ZFCP_SYSFS_FAILED(zfcp_unit, unit, unit->port->adapter, "syufai1", "syufai2"); 92 return sprintf(buf, "1\n");
93
94 return sprintf(buf, "0\n");
95}
96
97static ssize_t zfcp_sysfs_port_failed_store(struct device *dev,
98 struct device_attribute *attr,
99 const char *buf, size_t count)
100{
101 struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
102 unsigned long val;
103
104 if (strict_strtoul(buf, 0, &val) || val != 0)
105 return -EINVAL;
106
107 zfcp_erp_modify_port_status(port, "sypfai1", NULL,
108 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
109 zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2",
110 NULL);
111 zfcp_erp_wait(port->adapter);
112
113 return count;
114}
115static ZFCP_DEV_ATTR(port, failed, S_IWUSR | S_IRUGO,
116 zfcp_sysfs_port_failed_show,
117 zfcp_sysfs_port_failed_store);
118
119static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev,
120 struct device_attribute *attr,
121 char *buf)
122{
123 struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
124
125 if (atomic_read(&unit->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
126 return sprintf(buf, "1\n");
127
128 return sprintf(buf, "0\n");
129}
130
131static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev,
132 struct device_attribute *attr,
133 const char *buf, size_t count)
134{
135 struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
136 unsigned long val;
137
138 if (strict_strtoul(buf, 0, &val) || val != 0)
139 return -EINVAL;
140
141 zfcp_erp_modify_unit_status(unit, "syufai1", NULL,
142 ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);
143 zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED,
144 "syufai2", NULL);
145 zfcp_erp_wait(unit->port->adapter);
146
147 return count;
148}
149static ZFCP_DEV_ATTR(unit, failed, S_IWUSR | S_IRUGO,
150 zfcp_sysfs_unit_failed_show,
151 zfcp_sysfs_unit_failed_store);
128 152
129static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev, 153static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev,
130 struct device_attribute *attr, 154 struct device_attribute *attr,
@@ -394,8 +418,17 @@ ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
394 dev_name(&unit->port->adapter->ccw_device->dev)); 418 dev_name(&unit->port->adapter->ccw_device->dev));
395ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", 419ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
396 (unsigned long long) unit->port->wwpn); 420 (unsigned long long) unit->port->wwpn);
397ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n", 421
398 (unsigned long long) unit->fcp_lun); 422static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
423 struct device_attribute *attr,
424 char *buf)
425{
426 struct scsi_device *sdev = to_scsi_device(dev);
427 struct zfcp_unit *unit = sdev->hostdata;
428
429 return sprintf(buf, "0x%016llx\n", (unsigned long long) unit->fcp_lun);
430}
431static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
399 432
400struct device_attribute *zfcp_sysfs_sdev_attrs[] = { 433struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
401 &dev_attr_fcp_lun, 434 &dev_attr_fcp_lun,