diff options
Diffstat (limited to 'drivers/hwtracing/stm/policy.c')
-rw-r--r-- | drivers/hwtracing/stm/policy.c | 105 |
1 files changed, 24 insertions, 81 deletions
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c index 6498a9dbb7bd..11ab6d01adf6 100644 --- a/drivers/hwtracing/stm/policy.c +++ b/drivers/hwtracing/stm/policy.c | |||
@@ -76,9 +76,10 @@ to_stp_policy_node(struct config_item *item) | |||
76 | NULL; | 76 | NULL; |
77 | } | 77 | } |
78 | 78 | ||
79 | static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node, | 79 | static ssize_t |
80 | char *page) | 80 | stp_policy_node_masters_show(struct config_item *item, char *page) |
81 | { | 81 | { |
82 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
82 | ssize_t count; | 83 | ssize_t count; |
83 | 84 | ||
84 | count = sprintf(page, "%u %u\n", policy_node->first_master, | 85 | count = sprintf(page, "%u %u\n", policy_node->first_master, |
@@ -88,9 +89,10 @@ static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node, | |||
88 | } | 89 | } |
89 | 90 | ||
90 | static ssize_t | 91 | static ssize_t |
91 | stp_policy_node_masters_store(struct stp_policy_node *policy_node, | 92 | stp_policy_node_masters_store(struct config_item *item, const char *page, |
92 | const char *page, size_t count) | 93 | size_t count) |
93 | { | 94 | { |
95 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
94 | unsigned int first, last; | 96 | unsigned int first, last; |
95 | struct stm_device *stm; | 97 | struct stm_device *stm; |
96 | char *p = (char *)page; | 98 | char *p = (char *)page; |
@@ -123,8 +125,9 @@ unlock: | |||
123 | } | 125 | } |
124 | 126 | ||
125 | static ssize_t | 127 | static ssize_t |
126 | stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page) | 128 | stp_policy_node_channels_show(struct config_item *item, char *page) |
127 | { | 129 | { |
130 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
128 | ssize_t count; | 131 | ssize_t count; |
129 | 132 | ||
130 | count = sprintf(page, "%u %u\n", policy_node->first_channel, | 133 | count = sprintf(page, "%u %u\n", policy_node->first_channel, |
@@ -134,9 +137,10 @@ stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page) | |||
134 | } | 137 | } |
135 | 138 | ||
136 | static ssize_t | 139 | static ssize_t |
137 | stp_policy_node_channels_store(struct stp_policy_node *policy_node, | 140 | stp_policy_node_channels_store(struct config_item *item, const char *page, |
138 | const char *page, size_t count) | 141 | size_t count) |
139 | { | 142 | { |
143 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
140 | unsigned int first, last; | 144 | unsigned int first, last; |
141 | struct stm_device *stm; | 145 | struct stm_device *stm; |
142 | char *p = (char *)page; | 146 | char *p = (char *)page; |
@@ -171,71 +175,16 @@ static void stp_policy_node_release(struct config_item *item) | |||
171 | kfree(to_stp_policy_node(item)); | 175 | kfree(to_stp_policy_node(item)); |
172 | } | 176 | } |
173 | 177 | ||
174 | struct stp_policy_node_attribute { | ||
175 | struct configfs_attribute attr; | ||
176 | ssize_t (*show)(struct stp_policy_node *, char *); | ||
177 | ssize_t (*store)(struct stp_policy_node *, const char *, size_t); | ||
178 | }; | ||
179 | |||
180 | static ssize_t stp_policy_node_attr_show(struct config_item *item, | ||
181 | struct configfs_attribute *attr, | ||
182 | char *page) | ||
183 | { | ||
184 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
185 | struct stp_policy_node_attribute *pn_attr = | ||
186 | container_of(attr, struct stp_policy_node_attribute, attr); | ||
187 | ssize_t count = 0; | ||
188 | |||
189 | if (pn_attr->show) | ||
190 | count = pn_attr->show(policy_node, page); | ||
191 | |||
192 | return count; | ||
193 | } | ||
194 | |||
195 | static ssize_t stp_policy_node_attr_store(struct config_item *item, | ||
196 | struct configfs_attribute *attr, | ||
197 | const char *page, size_t len) | ||
198 | { | ||
199 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
200 | struct stp_policy_node_attribute *pn_attr = | ||
201 | container_of(attr, struct stp_policy_node_attribute, attr); | ||
202 | ssize_t count = -EINVAL; | ||
203 | |||
204 | if (pn_attr->store) | ||
205 | count = pn_attr->store(policy_node, page, len); | ||
206 | |||
207 | return count; | ||
208 | } | ||
209 | |||
210 | static struct configfs_item_operations stp_policy_node_item_ops = { | 178 | static struct configfs_item_operations stp_policy_node_item_ops = { |
211 | .release = stp_policy_node_release, | 179 | .release = stp_policy_node_release, |
212 | .show_attribute = stp_policy_node_attr_show, | ||
213 | .store_attribute = stp_policy_node_attr_store, | ||
214 | }; | 180 | }; |
215 | 181 | ||
216 | static struct stp_policy_node_attribute stp_policy_node_attr_range = { | 182 | CONFIGFS_ATTR(stp_policy_node_, masters); |
217 | .attr = { | 183 | CONFIGFS_ATTR(stp_policy_node_, channels); |
218 | .ca_owner = THIS_MODULE, | ||
219 | .ca_name = "masters", | ||
220 | .ca_mode = S_IRUGO | S_IWUSR, | ||
221 | }, | ||
222 | .show = stp_policy_node_masters_show, | ||
223 | .store = stp_policy_node_masters_store, | ||
224 | }; | ||
225 | |||
226 | static struct stp_policy_node_attribute stp_policy_node_attr_channels = { | ||
227 | .attr = { | ||
228 | .ca_owner = THIS_MODULE, | ||
229 | .ca_name = "channels", | ||
230 | .ca_mode = S_IRUGO | S_IWUSR, | ||
231 | }, | ||
232 | .show = stp_policy_node_channels_show, | ||
233 | .store = stp_policy_node_channels_store, | ||
234 | }; | ||
235 | 184 | ||
236 | static struct configfs_attribute *stp_policy_node_attrs[] = { | 185 | static struct configfs_attribute *stp_policy_node_attrs[] = { |
237 | &stp_policy_node_attr_range.attr, | 186 | &stp_policy_node_attr_masters, |
238 | &stp_policy_node_attr_channels.attr, | 187 | &stp_policy_node_attr_channels, |
239 | NULL, | 188 | NULL, |
240 | }; | 189 | }; |
241 | 190 | ||
@@ -298,20 +247,8 @@ static struct config_item_type stp_policy_node_type = { | |||
298 | /* | 247 | /* |
299 | * Root group: policies. | 248 | * Root group: policies. |
300 | */ | 249 | */ |
301 | static struct configfs_attribute stp_policy_attr_device = { | 250 | static ssize_t stp_policy_device_show(struct config_item *item, |
302 | .ca_owner = THIS_MODULE, | 251 | char *page) |
303 | .ca_name = "device", | ||
304 | .ca_mode = S_IRUGO, | ||
305 | }; | ||
306 | |||
307 | static struct configfs_attribute *stp_policy_attrs[] = { | ||
308 | &stp_policy_attr_device, | ||
309 | NULL, | ||
310 | }; | ||
311 | |||
312 | static ssize_t stp_policy_attr_show(struct config_item *item, | ||
313 | struct configfs_attribute *attr, | ||
314 | char *page) | ||
315 | { | 252 | { |
316 | struct stp_policy *policy = to_stp_policy(item); | 253 | struct stp_policy *policy = to_stp_policy(item); |
317 | ssize_t count; | 254 | ssize_t count; |
@@ -324,6 +261,13 @@ static ssize_t stp_policy_attr_show(struct config_item *item, | |||
324 | return count; | 261 | return count; |
325 | } | 262 | } |
326 | 263 | ||
264 | CONFIGFS_ATTR_RO(stp_policy_, device); | ||
265 | |||
266 | static struct configfs_attribute *stp_policy_attrs[] = { | ||
267 | &stp_policy_attr_device, | ||
268 | NULL, | ||
269 | }; | ||
270 | |||
327 | void stp_policy_unbind(struct stp_policy *policy) | 271 | void stp_policy_unbind(struct stp_policy *policy) |
328 | { | 272 | { |
329 | struct stm_device *stm = policy->stm; | 273 | struct stm_device *stm = policy->stm; |
@@ -350,7 +294,6 @@ static void stp_policy_release(struct config_item *item) | |||
350 | 294 | ||
351 | static struct configfs_item_operations stp_policy_item_ops = { | 295 | static struct configfs_item_operations stp_policy_item_ops = { |
352 | .release = stp_policy_release, | 296 | .release = stp_policy_release, |
353 | .show_attribute = stp_policy_attr_show, | ||
354 | }; | 297 | }; |
355 | 298 | ||
356 | static struct configfs_group_operations stp_policy_group_ops = { | 299 | static struct configfs_group_operations stp_policy_group_ops = { |