Lines Matching refs:kobject

3  * kobject.c - library routines for handling generic kernel objects
9 * Please see the file Documentation/core-api/kobject.rst for critical information
10 * about using the kobject interface.
13 #include <linux/kobject.h>
22 * @kobj: kobject in question
28 const void *kobject_namespace(struct kobject *kobj)
40 * @kobj: kobject in question
45 * representation of given kobject. Normally used to adjust ownership of
48 void kobject_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
66 static int populate_dir(struct kobject *kobj)
83 static int create_dir(struct kobject *kobj)
129 static int get_kobj_path_length(struct kobject *kobj)
132 struct kobject *parent = kobj;
147 static int fill_kobj_path(struct kobject *kobj, char *path, int length)
149 struct kobject *parent;
162 pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
170 * @kobj: kobject in question, with which to build the path
175 char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
196 /* add the kobject to its kset's list */
197 static void kobj_kset_join(struct kobject *kobj)
208 /* remove the kobject from its kset's list */
209 static void kobj_kset_leave(struct kobject *kobj)
220 static void kobject_init_internal(struct kobject *kobj)
233 static int kobject_add_internal(struct kobject *kobj)
236 struct kobject *parent;
243 "kobject: (%p): attempted to be registered with empty name!\n",
258 pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
284 * kobject_set_name_vargs() - Set the name of a kobject.
285 * @kobj: struct kobject to set the name of
289 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
324 * kobject_set_name() - Set the name of a kobject.
325 * @kobj: struct kobject to set the name of
328 * This sets the name of the kobject. If you have already added the
329 * kobject to the system, you must call kobject_rename() in order to
330 * change the name of the kobject.
332 int kobject_set_name(struct kobject *kobj, const char *fmt, ...)
346 * kobject_init() - Initialize a kobject structure.
347 * @kobj: pointer to the kobject to initialize
348 * @ktype: pointer to the ktype for this kobject.
350 * This function will properly initialize a kobject such that it can then
353 * After this function is called, the kobject MUST be cleaned up by a call
357 void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
362 err_str = "invalid kobject pointer!";
371 pr_err("kobject (%p): tried to init an initialized object, something is seriously wrong.\n",
381 pr_err("kobject (%p): %s\n", kobj, err_str);
386 static __printf(3, 0) int kobject_add_varg(struct kobject *kobj,
387 struct kobject *parent,
394 pr_err("kobject: can not set name properly!\n");
402 * kobject_add() - The main kobject add function.
403 * @kobj: the kobject to add
404 * @parent: pointer to the parent of the kobject.
405 * @fmt: format to name the kobject with.
407 * The kobject name is set and added to the kobject hierarchy in this
412 * kobject associated with the kset assigned to this kobject. If no kset
413 * is assigned to the kobject, then the kobject will be located in the
419 * userspace is properly notified of this kobject's creation.
423 * object. Under no instance should the kobject that is passed
434 int kobject_add(struct kobject *kobj, struct kobject *parent,
444 pr_err("kobject '%s' (%p): tried to add an uninitialized object, something is seriously wrong.\n",
458 * kobject_init_and_add() - Initialize a kobject structure and add it to
459 * the kobject hierarchy.
460 * @kobj: pointer to the kobject to initialize
461 * @ktype: pointer to the ktype for this kobject.
462 * @parent: pointer to the parent of this kobject.
463 * @fmt: the name of the kobject.
469 * same type of error handling after a call to kobject_add() and kobject
472 int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
473 struct kobject *parent, const char *fmt, ...)
495 * on the same kobject and to ensure that new_name is valid and
498 int kobject_rename(struct kobject *kobj, const char *new_name)
538 /* Install the new kobject name */
562 int kobject_move(struct kobject *kobj, struct kobject *new_parent)
565 struct kobject *old_parent;
610 static void __kobject_del(struct kobject *kobj)
623 pr_debug("kobject: '%s' (%p): auto cleanup 'remove' event\n",
637 * kobject_del() - Unlink kobject from hierarchy.
643 void kobject_del(struct kobject *kobj)
645 struct kobject *parent;
660 struct kobject *kobject_get(struct kobject *kobj)
665 "kobject: '%s' (%p): is not initialized, yet kobject_get() is being called.\n",
673 struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj)
684 * kobject_cleanup - free kobject resources.
687 static void kobject_cleanup(struct kobject *kobj)
689 struct kobject *parent = kobj->parent;
693 pr_debug("kobject: '%s' (%p): %s, parent %p\n",
697 pr_debug("kobject: '%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n",
702 pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
711 pr_debug("kobject: '%s' (%p): calling ktype release\n",
718 pr_debug("kobject: '%s': free name\n", name);
729 struct kobject, release));
735 struct kobject *kobj = container_of(kref, struct kobject, kref);
738 pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n",
754 void kobject_put(struct kobject *kobj)
759 "kobject: '%s' (%p): is not initialized, yet kobject_put() is being called.\n",
766 static void dynamic_kobj_release(struct kobject *kobj)
768 pr_debug("kobject: (%p): %s\n", kobj, __func__);
778 * kobject_create() - Create a struct kobject dynamically.
780 * This function creates a kobject structure dynamically and sets it up
781 * to be a "dynamic" kobject with a default release function set up.
783 * If the kobject was not able to be created, NULL will be returned.
784 * The kobject structure returned from here must be cleaned up with a
788 struct kobject *kobject_create(void)
790 struct kobject *kobj;
801 * kobject_create_and_add() - Create a struct kobject dynamically and
803 * @name: the name for the kobject
804 * @parent: the parent kobject of this kobject, if any.
806 * This function creates a kobject structure dynamically and registers it
811 * If the kobject was not able to be created, NULL will be returned.
813 struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
815 struct kobject *kobj;
843 /* default kobject attribute operations */
844 static ssize_t kobj_attr_show(struct kobject *kobj, struct attribute *attr,
856 static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
918 * looking for a matching kobject. If matching object is found
921 struct kobject *kset_find_obj(struct kset *kset, const char *name)
923 struct kobject *k;
924 struct kobject *ret = NULL;
940 static void kset_release(struct kobject *kobj)
943 pr_debug("kobject: '%s' (%p): %s\n",
948 static void kset_get_ownership(struct kobject *kobj, kuid_t *uid, kgid_t *gid)
965 * @parent_kobj: the parent kobject of this kset, if any.
977 struct kobject *parent_kobj)
994 * The kobject of this kset will have a type of kset_ktype and belong to
1009 * @parent_kobj: the parent kobject of this kset, if any.
1020 struct kobject *parent_kobj)
1080 const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent)
1090 const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj)