lkml.org 
[lkml]   [2003]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kobjects, sysfs and the driver model make my head hurt
On Sun, Jul 06, 2003 at 05:33:53PM +0100, Matthew Wilcox wrote:
>
> struct kobject * kobject_get(struct kobject * kobj)
> {
> if (kobj) {
> WARN_ON(!atomic_read(&kobj->refcount));
> atomic_inc(&kobj->refcount);
> }
> return kobj;
> }

That's nice. Remember, we used to have a lock in there, that's why the
code doesn't look that clean after it was removed.

> But why return anything? Which looks clearer?
>
> (a) kobj = kobject_get(kobj);

This is the way to call kobject_get(), as the object we get after the
function returns is the one we can then safely use.

> The first one makes me think that kobject_get might return a different
> kobject than the one I passed in. That doesn't make much sense.

Think of it as, "now we can use this kobject, not the one before calling
kobject_get()".

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.054 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site