Lines Matching +full:s +full:- +full:merged
1 // SPDX-License-Identifier: GPL-2.0
36 /* this is the one that's exposed to the attributes */
45 return pn->priv; in stp_policy_node_priv()
54 *mstart = policy_node->first_master; in stp_policy_node_get_ranges()
55 *mend = policy_node->last_master; in stp_policy_node_get_ranges()
56 *cstart = policy_node->first_channel; in stp_policy_node_get_ranges()
57 *cend = policy_node->last_channel; in stp_policy_node_get_ranges()
62 return policy_node->group.cg_item.ci_name ? : "<none>"; in stp_policy_node_name()
95 count = sprintf(page, "%u %u\n", policy_node->first_master, in stp_policy_node_masters_show()
96 policy_node->last_master); in stp_policy_node_masters_show()
109 ssize_t ret = -ENODEV; in stp_policy_node_masters_store()
112 return -EINVAL; in stp_policy_node_masters_store()
115 stm = policy_node->policy->stm; in stp_policy_node_masters_store()
120 if (first > last || first < stm->data->sw_start || in stp_policy_node_masters_store()
121 last > stm->data->sw_end) { in stp_policy_node_masters_store()
122 ret = -ERANGE; in stp_policy_node_masters_store()
127 policy_node->first_master = first; in stp_policy_node_masters_store()
128 policy_node->last_master = last; in stp_policy_node_masters_store()
142 count = sprintf(page, "%u %u\n", policy_node->first_channel, in stp_policy_node_channels_show()
143 policy_node->last_channel); in stp_policy_node_channels_show()
156 ssize_t ret = -ENODEV; in stp_policy_node_channels_store()
159 return -EINVAL; in stp_policy_node_channels_store()
162 stm = policy_node->policy->stm; in stp_policy_node_channels_store()
167 last >= stm->data->sw_nchannels) { in stp_policy_node_channels_store()
168 ret = -ERANGE; in stp_policy_node_channels_store()
173 policy_node->first_channel = first; in stp_policy_node_channels_store()
174 policy_node->last_channel = last; in stp_policy_node_channels_store()
209 struct configfs_attribute **merged; in get_policy_node_type() local
216 merged = memcat_p(stp_policy_node_attrs, attrs); in get_policy_node_type()
217 if (!merged) { in get_policy_node_type()
222 type->ct_attrs = merged; in get_policy_node_type()
235 if (group->cg_item.ci_type == &stp_policy_type) { in stp_policy_node_make()
240 policy = parent_node->policy; in stp_policy_node_make()
243 if (!policy->stm) in stp_policy_node_make()
244 return ERR_PTR(-ENODEV); in stp_policy_node_make()
246 pdrv = policy->stm->pdrv; in stp_policy_node_make()
248 kzalloc(offsetof(struct stp_policy_node, priv[pdrv->priv_sz]), in stp_policy_node_make()
251 return ERR_PTR(-ENOMEM); in stp_policy_node_make()
253 if (pdrv->policy_node_init) in stp_policy_node_make()
254 pdrv->policy_node_init((void *)policy_node->priv); in stp_policy_node_make()
256 if (policy->stm->pdrv_node_type) in stp_policy_node_make()
257 type = policy->stm->pdrv_node_type; in stp_policy_node_make()
259 config_group_init_type_name(&policy_node->group, name, type); in stp_policy_node_make()
261 policy_node->policy = policy; in stp_policy_node_make()
264 policy_node->first_master = policy->stm->data->sw_start; in stp_policy_node_make()
265 policy_node->last_master = policy->stm->data->sw_end; in stp_policy_node_make()
266 policy_node->first_channel = 0; in stp_policy_node_make()
267 policy_node->last_channel = policy->stm->data->sw_nchannels - 1; in stp_policy_node_make()
269 return &policy_node->group; in stp_policy_node_make()
299 count = sprintf(page, "%s\n", in stp_policy_device_show()
300 (policy && policy->stm) ? in stp_policy_device_show()
301 policy->stm->data->name : in stp_policy_device_show()
315 count = sprintf(page, "%s\n", in stp_policy_protocol_show()
316 (policy && policy->stm) ? in stp_policy_protocol_show()
317 policy->stm->pdrv->name : in stp_policy_protocol_show()
333 struct stm_device *stm = policy->stm; in stp_policy_unbind()
340 if (WARN_ON_ONCE(!policy->stm)) in stp_policy_unbind()
343 lockdep_assert_held(&stm->policy_mutex); in stp_policy_unbind()
345 stm->policy = NULL; in stp_policy_unbind()
346 policy->stm = NULL; in stp_policy_unbind()
351 stm_put_protocol(stm->pdrv); in stp_policy_unbind()
352 stm->pdrv = NULL; in stp_policy_unbind()
359 struct stm_device *stm = policy->stm; in stp_policy_release()
365 mutex_lock(&stm->policy_mutex); in stp_policy_release()
367 mutex_unlock(&stm->policy_mutex); in stp_policy_release()
397 devname = kasprintf(GFP_KERNEL, "%s", name); in stp_policy_make()
399 return ERR_PTR(-ENOMEM); in stp_policy_make()
411 return ERR_PTR(-EINVAL); in stp_policy_make()
428 return ERR_PTR(-ENODEV); in stp_policy_make()
436 return ERR_PTR(-ENODEV); in stp_policy_make()
439 mutex_lock(&stm->policy_mutex); in stp_policy_make()
440 if (stm->policy) { in stp_policy_make()
441 ret = ERR_PTR(-EBUSY); in stp_policy_make()
445 stm->policy = kzalloc(sizeof(*stm->policy), GFP_KERNEL); in stp_policy_make()
446 if (!stm->policy) { in stp_policy_make()
447 ret = ERR_PTR(-ENOMEM); in stp_policy_make()
451 config_group_init_type_name(&stm->policy->group, name, in stp_policy_make()
454 stm->pdrv = pdrv; in stp_policy_make()
455 stm->pdrv_node_type = pdrv_node_type; in stp_policy_make()
456 stm->policy->stm = stm; in stp_policy_make()
457 ret = &stm->policy->group; in stp_policy_make()
460 mutex_unlock(&stm->policy_mutex); in stp_policy_make()
464 * pdrv and stm->pdrv at this point can be quite different, in stp_policy_make()
486 .ci_namebuf = "stp-policy",
496 __stp_policy_node_lookup(struct stp_policy *policy, char *s) in __stp_policy_node_lookup() argument
499 struct list_head *head = &policy->group.cg_children; in __stp_policy_node_lookup()
501 char *start, *end = s; in __stp_policy_node_lookup()
519 policy_node->group.cg_item.ci_name)) { in __stp_policy_node_lookup()
525 head = &policy_node->group.cg_children; in __stp_policy_node_lookup()
538 stp_policy_node_lookup(struct stm_device *stm, char *s) in stp_policy_node_lookup() argument
544 mutex_lock(&stm->policy_mutex); in stp_policy_node_lookup()
545 if (stm->policy) in stp_policy_node_lookup()
546 policy_node = __stp_policy_node_lookup(stm->policy, s); in stp_policy_node_lookup()
547 mutex_unlock(&stm->policy_mutex); in stp_policy_node_lookup()
550 config_item_get(&policy_node->group.cg_item); in stp_policy_node_lookup()
562 config_item_put(&policy_node->group.cg_item); in stp_policy_node_put()