public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Matthew Wilcox <willy@debian.org>
Cc: Patrick Mochel <mochel@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: kobjects, sysfs and the driver model make my head hurt
Date: Sun, 6 Jul 2003 09:46:26 -0700	[thread overview]
Message-ID: <20030706164626.GA17596@kroah.com> (raw)
In-Reply-To: <20030706163353.GU23597@parcelfarce.linux.theplanet.co.uk>

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

  parent reply	other threads:[~2003-07-06 16:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-06 16:33 kobjects, sysfs and the driver model make my head hurt Matthew Wilcox
2003-07-06 16:42 ` Davide Libenzi
2003-07-06 17:03   ` James Morris
2003-07-06 17:15     ` Jeff Garzik
2003-07-07  7:05   ` Johan.Adolfsson
2003-07-06 16:46 ` Greg KH [this message]
2003-07-06 16:54   ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030706164626.GA17596@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    --cc=willy@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox