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()
90 count = sprintf(page, "%u %u\n", policy_node->first_master, in stp_policy_node_masters_show()
91 policy_node->last_master); in stp_policy_node_masters_show()
104 ssize_t ret = -ENODEV; in stp_policy_node_masters_store()
107 return -EINVAL; in stp_policy_node_masters_store()
110 stm = policy_node->policy->stm; in stp_policy_node_masters_store()
115 if (first > last || first < stm->data->sw_start || in stp_policy_node_masters_store()
116 last > stm->data->sw_end) { in stp_policy_node_masters_store()
117 ret = -ERANGE; in stp_policy_node_masters_store()
122 policy_node->first_master = first; in stp_policy_node_masters_store()
123 policy_node->last_master = last; in stp_policy_node_masters_store()
137 count = sprintf(page, "%u %u\n", policy_node->first_channel, in stp_policy_node_channels_show()
138 policy_node->last_channel); in stp_policy_node_channels_show()
151 ssize_t ret = -ENODEV; in stp_policy_node_channels_store()
154 return -EINVAL; in stp_policy_node_channels_store()
157 stm = policy_node->policy->stm; in stp_policy_node_channels_store()
162 last >= stm->data->sw_nchannels) { in stp_policy_node_channels_store()
163 ret = -ERANGE; in stp_policy_node_channels_store()
168 policy_node->first_channel = first; in stp_policy_node_channels_store()
169 policy_node->last_channel = last; in stp_policy_node_channels_store()
204 struct configfs_attribute **merged; in get_policy_node_type() local
211 merged = memcat_p(stp_policy_node_attrs, attrs); in get_policy_node_type()
212 if (!merged) { in get_policy_node_type()
217 type->ct_attrs = merged; in get_policy_node_type()
230 if (group->cg_item.ci_type == &stp_policy_type) { in stp_policy_node_make()
235 policy = parent_node->policy; in stp_policy_node_make()
238 if (!policy->stm) in stp_policy_node_make()
239 return ERR_PTR(-ENODEV); in stp_policy_node_make()
241 pdrv = policy->stm->pdrv; in stp_policy_node_make()
243 kzalloc(offsetof(struct stp_policy_node, priv[pdrv->priv_sz]), in stp_policy_node_make()
246 return ERR_PTR(-ENOMEM); in stp_policy_node_make()
248 if (pdrv->policy_node_init) in stp_policy_node_make()
249 pdrv->policy_node_init((void *)policy_node->priv); in stp_policy_node_make()
251 if (policy->stm->pdrv_node_type) in stp_policy_node_make()
252 type = policy->stm->pdrv_node_type; in stp_policy_node_make()
254 config_group_init_type_name(&policy_node->group, name, type); in stp_policy_node_make()
256 policy_node->policy = policy; in stp_policy_node_make()
259 policy_node->first_master = policy->stm->data->sw_start; in stp_policy_node_make()
260 policy_node->last_master = policy->stm->data->sw_end; in stp_policy_node_make()
261 policy_node->first_channel = 0; in stp_policy_node_make()
262 policy_node->last_channel = policy->stm->data->sw_nchannels - 1; in stp_policy_node_make()
264 return &policy_node->group; in stp_policy_node_make()
294 count = sprintf(page, "%s\n", in stp_policy_device_show()
295 (policy && policy->stm) ? in stp_policy_device_show()
296 policy->stm->data->name : in stp_policy_device_show()
310 count = sprintf(page, "%s\n", in stp_policy_protocol_show()
311 (policy && policy->stm) ? in stp_policy_protocol_show()
312 policy->stm->pdrv->name : in stp_policy_protocol_show()
328 struct stm_device *stm = policy->stm; in stp_policy_unbind()
335 if (WARN_ON_ONCE(!policy->stm)) in stp_policy_unbind()
338 lockdep_assert_held(&stm->policy_mutex); in stp_policy_unbind()
340 stm->policy = NULL; in stp_policy_unbind()
341 policy->stm = NULL; in stp_policy_unbind()
346 stm_put_protocol(stm->pdrv); in stp_policy_unbind()
347 stm->pdrv = NULL; in stp_policy_unbind()
354 struct stm_device *stm = policy->stm; in stp_policy_release()
360 mutex_lock(&stm->policy_mutex); in stp_policy_release()
362 mutex_unlock(&stm->policy_mutex); in stp_policy_release()
392 devname = kasprintf(GFP_KERNEL, "%s", name); in stp_policy_make()
394 return ERR_PTR(-ENOMEM); in stp_policy_make()
406 return ERR_PTR(-EINVAL); in stp_policy_make()
423 return ERR_PTR(-ENODEV); in stp_policy_make()
431 return ERR_PTR(-ENODEV); in stp_policy_make()
434 mutex_lock(&stm->policy_mutex); in stp_policy_make()
435 if (stm->policy) { in stp_policy_make()
436 ret = ERR_PTR(-EBUSY); in stp_policy_make()
440 stm->policy = kzalloc(sizeof(*stm->policy), GFP_KERNEL); in stp_policy_make()
441 if (!stm->policy) { in stp_policy_make()
442 ret = ERR_PTR(-ENOMEM); in stp_policy_make()
446 config_group_init_type_name(&stm->policy->group, name, in stp_policy_make()
449 stm->pdrv = pdrv; in stp_policy_make()
450 stm->pdrv_node_type = pdrv_node_type; in stp_policy_make()
451 stm->policy->stm = stm; in stp_policy_make()
452 ret = &stm->policy->group; in stp_policy_make()
455 mutex_unlock(&stm->policy_mutex); in stp_policy_make()
459 * pdrv and stm->pdrv at this point can be quite different, in stp_policy_make()
481 .ci_namebuf = "stp-policy",
491 __stp_policy_node_lookup(struct stp_policy *policy, char *s) in __stp_policy_node_lookup() argument
494 struct list_head *head = &policy->group.cg_children; in __stp_policy_node_lookup()
496 char *start, *end = s; in __stp_policy_node_lookup()
514 policy_node->group.cg_item.ci_name)) { in __stp_policy_node_lookup()
520 head = &policy_node->group.cg_children; in __stp_policy_node_lookup()
533 stp_policy_node_lookup(struct stm_device *stm, char *s) in stp_policy_node_lookup() argument
539 mutex_lock(&stm->policy_mutex); in stp_policy_node_lookup()
540 if (stm->policy) in stp_policy_node_lookup()
541 policy_node = __stp_policy_node_lookup(stm->policy, s); in stp_policy_node_lookup()
542 mutex_unlock(&stm->policy_mutex); in stp_policy_node_lookup()
545 config_item_get(&policy_node->group.cg_item); in stp_policy_node_lookup()
557 config_item_put(&policy_node->group.cg_item); in stp_policy_node_put()