// SPDX-License-Identifier: GPL-2.0-or-later /* * item.c - library routines for handling generic config items * * Based on kobject: * kobject is Copyright (c) 2002-2003 Patrick Mochel * * configfs Copyright (C) 2005 Oracle. All rights reserved. * * Please see the file Documentation/filesystems/configfs.rst for * critical information about using the config_item interface. */ #include <linux/string.h> #include <linux/module.h> #include <linux/stat.h> #include <linux/slab.h> #include <linux/configfs.h> static inline struct config_item *to_item(struct list_head *entry) { … } /* Evil kernel */ static void config_item_release(struct kref *kref); /** * config_item_init - initialize item. * @item: item in question. */ static void config_item_init(struct config_item *item) { … } /** * config_item_set_name - Set the name of an item * @item: item. * @fmt: The vsnprintf()'s format string. * * If strlen(name) >= CONFIGFS_ITEM_NAME_LEN, then use a * dynamically allocated string that @item->ci_name points to. * Otherwise, use the static @item->ci_namebuf array. */ int config_item_set_name(struct config_item *item, const char *fmt, ...) { … } EXPORT_SYMBOL(…); void config_item_init_type_name(struct config_item *item, const char *name, const struct config_item_type *type) { … } EXPORT_SYMBOL(…); void config_group_init_type_name(struct config_group *group, const char *name, const struct config_item_type *type) { … } EXPORT_SYMBOL(…); struct config_item *config_item_get(struct config_item *item) { … } EXPORT_SYMBOL(…); struct config_item *config_item_get_unless_zero(struct config_item *item) { … } EXPORT_SYMBOL(…); static void config_item_cleanup(struct config_item *item) { … } static void config_item_release(struct kref *kref) { … } /** * config_item_put - decrement refcount for item. * @item: item. * * Decrement the refcount, and if 0, call config_item_cleanup(). */ void config_item_put(struct config_item *item) { … } EXPORT_SYMBOL(…); /** * config_group_init - initialize a group for use * @group: config_group */ void config_group_init(struct config_group *group) { … } EXPORT_SYMBOL(…); /** * config_group_find_item - search for item in group. * @group: group we're looking in. * @name: item's name. * * Iterate over @group->cg_list, looking for a matching config_item. * If matching item is found take a reference and return the item. * Caller must have locked group via @group->cg_subsys->su_mtx. */ struct config_item *config_group_find_item(struct config_group *group, const char *name) { … } EXPORT_SYMBOL(…);