Re: kobject_init rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



One minor documentation update:

> /**
>  * kobject_init - initialize a kobject structure
>  * @kobj: pointer to the kobject to initialize
>  * @ktype: pointer to the ktype for this kobject.
>  * @fmt: the name of the kobject
>  *
>  * This function will properly initialize a kobject such that it can then
>  * be passed to the kobject_add() call.
>  *
>  * If the function returns an error, the memory allocated by the kobject
>  * can be safely freed, no other functions need to be called.

If the function does not return an error, the only way the kobject's
memory can be properly freed is with a call to kobject_put().  kfree()
should never be called on a kobject after this function has been called,
execept from the ktype's release function.

>  */
> int kobject_init(struct kobject *kobj, struct kobj_type *ktype, const char *fmt, ...)
> {
> 	va_list args;
> 	int retval;
> 
> 	if (!kobj)
> 		return -EINVAL;
> 
> 	if (!ktype)
> 		return -EINVAL;
> 
> 	WARN_ON(atomic_read(&kobj->kref.refcount));
> 	kref_init(&kobj->kref);
> 	INIT_LIST_HEAD(&kobj->entry);
> 	kobj->ktype = ktype;
> 
> 	va_start(args, fmt);
> 	retval = kobject_set_name_vargs(kobj, fmt, args);
> 	va_end(args);
> 
> 	return retval;
> }
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux