[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20071130103143.52d2bd2b@gondolin.boeblingen.de.ibm.com>
Date: Fri, 30 Nov 2007 10:31:43 +0100
From: Cornelia Huck <cornelia.huck@...ibm.com>
To: Greg KH <greg@...ah.com>
Cc: Kay Sievers <kay.sievers@...y.org>,
Alan Stern <stern@...land.harvard.edu>,
Kernel development list <linux-kernel@...r.kernel.org>,
Jonathan Corbet <corbet@....net>,
Randy Dunlap <randy.dunlap@...cle.com>
Subject: Re: kobject_init rewrite
On Thu, 29 Nov 2007 13:54:55 -0800,
Greg KH <greg@...ah.com> wrote:
> 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;
> > }
> >
Yes, this looks fine.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists