diff options
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs_unit.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_sysfs_unit.c | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c deleted file mode 100644 index 587d9e3e12d2..000000000000 --- a/drivers/s390/scsi/zfcp_sysfs_unit.c +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /* | ||
2 | * zfcp device driver | ||
3 | * | ||
4 | * sysfs interface for zfcp unit. | ||
5 | * | ||
6 | * Copyright IBM Corporation 2002, 2008 | ||
7 | */ | ||
8 | |||
9 | #include "zfcp_ext.h" | ||
10 | |||
11 | /** | ||
12 | * zfcp_sysfs_unit_release - gets called when a struct device unit is released | ||
13 | * @dev: pointer to belonging device | ||
14 | */ | ||
15 | void | ||
16 | zfcp_sysfs_unit_release(struct device *dev) | ||
17 | { | ||
18 | kfree(dev); | ||
19 | } | ||
20 | |||
21 | /** | ||
22 | * ZFCP_DEFINE_UNIT_ATTR | ||
23 | * @_name: name of show attribute | ||
24 | * @_format: format string | ||
25 | * @_value: value to print | ||
26 | * | ||
27 | * Generates attribute for a unit. | ||
28 | */ | ||
29 | #define ZFCP_DEFINE_UNIT_ATTR(_name, _format, _value) \ | ||
30 | static ssize_t zfcp_sysfs_unit_##_name##_show(struct device *dev, struct device_attribute *attr, \ | ||
31 | char *buf) \ | ||
32 | { \ | ||
33 | struct zfcp_unit *unit; \ | ||
34 | \ | ||
35 | unit = dev_get_drvdata(dev); \ | ||
36 | return sprintf(buf, _format, _value); \ | ||
37 | } \ | ||
38 | \ | ||
39 | static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_unit_##_name##_show, NULL); | ||
40 | |||
41 | ZFCP_DEFINE_UNIT_ATTR(status, "0x%08x\n", atomic_read(&unit->status)); | ||
42 | ZFCP_DEFINE_UNIT_ATTR(in_recovery, "%d\n", atomic_test_mask | ||
43 | (ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status)); | ||
44 | ZFCP_DEFINE_UNIT_ATTR(access_denied, "%d\n", atomic_test_mask | ||
45 | (ZFCP_STATUS_COMMON_ACCESS_DENIED, &unit->status)); | ||
46 | ZFCP_DEFINE_UNIT_ATTR(access_shared, "%d\n", atomic_test_mask | ||
47 | (ZFCP_STATUS_UNIT_SHARED, &unit->status)); | ||
48 | ZFCP_DEFINE_UNIT_ATTR(access_readonly, "%d\n", atomic_test_mask | ||
49 | (ZFCP_STATUS_UNIT_READONLY, &unit->status)); | ||
50 | |||
51 | /** | ||
52 | * zfcp_sysfs_unit_failed_store - failed state of unit | ||
53 | * @dev: pointer to belonging device | ||
54 | * @buf: pointer to input buffer | ||
55 | * @count: number of bytes in buffer | ||
56 | * | ||
57 | * Store function of the "failed" attribute of a unit. | ||
58 | * If a "0" gets written to "failed", error recovery will be | ||
59 | * started for the belonging unit. | ||
60 | */ | ||
61 | static ssize_t | ||
62 | zfcp_sysfs_unit_failed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
63 | { | ||
64 | struct zfcp_unit *unit; | ||
65 | unsigned int val; | ||
66 | char *endp; | ||
67 | int retval = 0; | ||
68 | |||
69 | down(&zfcp_data.config_sema); | ||
70 | unit = dev_get_drvdata(dev); | ||
71 | if (atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status)) { | ||
72 | retval = -EBUSY; | ||
73 | goto out; | ||
74 | } | ||
75 | |||
76 | val = simple_strtoul(buf, &endp, 0); | ||
77 | if (((endp + 1) < (buf + count)) || (val != 0)) { | ||
78 | retval = -EINVAL; | ||
79 | goto out; | ||
80 | } | ||
81 | |||
82 | zfcp_erp_modify_unit_status(unit, 46, NULL, | ||
83 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); | ||
84 | zfcp_erp_unit_reopen(unit, ZFCP_STATUS_COMMON_ERP_FAILED, 97, NULL); | ||
85 | zfcp_erp_wait(unit->port->adapter); | ||
86 | out: | ||
87 | up(&zfcp_data.config_sema); | ||
88 | return retval ? retval : (ssize_t) count; | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * zfcp_sysfs_unit_failed_show - failed state of unit | ||
93 | * @dev: pointer to belonging device | ||
94 | * @buf: pointer to input buffer | ||
95 | * | ||
96 | * Show function of "failed" attribute of unit. Will be | ||
97 | * "0" if unit is working, otherwise "1". | ||
98 | */ | ||
99 | static ssize_t | ||
100 | zfcp_sysfs_unit_failed_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
101 | { | ||
102 | struct zfcp_unit *unit; | ||
103 | |||
104 | unit = dev_get_drvdata(dev); | ||
105 | if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_FAILED, &unit->status)) | ||
106 | return sprintf(buf, "1\n"); | ||
107 | else | ||
108 | return sprintf(buf, "0\n"); | ||
109 | } | ||
110 | |||
111 | static DEVICE_ATTR(failed, S_IWUSR | S_IRUGO, zfcp_sysfs_unit_failed_show, | ||
112 | zfcp_sysfs_unit_failed_store); | ||
113 | |||
114 | static struct attribute *zfcp_unit_attrs[] = { | ||
115 | &dev_attr_failed.attr, | ||
116 | &dev_attr_in_recovery.attr, | ||
117 | &dev_attr_status.attr, | ||
118 | &dev_attr_access_denied.attr, | ||
119 | &dev_attr_access_shared.attr, | ||
120 | &dev_attr_access_readonly.attr, | ||
121 | NULL | ||
122 | }; | ||
123 | |||
124 | static struct attribute_group zfcp_unit_attr_group = { | ||
125 | .attrs = zfcp_unit_attrs, | ||
126 | }; | ||
127 | |||
128 | /** | ||
129 | * zfcp_sysfs_create_unit_files - create sysfs unit files | ||
130 | * @dev: pointer to belonging device | ||
131 | * | ||
132 | * Create all attributes of the sysfs representation of a unit. | ||
133 | */ | ||
134 | int | ||
135 | zfcp_sysfs_unit_create_files(struct device *dev) | ||
136 | { | ||
137 | return sysfs_create_group(&dev->kobj, &zfcp_unit_attr_group); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * zfcp_sysfs_remove_unit_files - remove sysfs unit files | ||
142 | * @dev: pointer to belonging device | ||
143 | * | ||
144 | * Remove all attributes of the sysfs representation of a unit. | ||
145 | */ | ||
146 | void | ||
147 | zfcp_sysfs_unit_remove_files(struct device *dev) | ||
148 | { | ||
149 | sysfs_remove_group(&dev->kobj, &zfcp_unit_attr_group); | ||
150 | } | ||