public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: corbet@lwn.net (Jonathan Corbet)
To: viro@parcelfarce.linux.theplanet.co.uk
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RFC: Attributes in /sys/cdev
Date: Mon, 22 Sep 2003 15:15:11 -0600	[thread overview]
Message-ID: <20030922211511.17009.qmail@lwn.net> (raw)
In-Reply-To: Your message of "Mon, 22 Sep 2003 22:00:21 BST." <20030922210021.GH7665@parcelfarce.linux.theplanet.co.uk>

Forgive my insistence here...I'm trying to figure out what LDD3 is going to
say on this subject.  If we get it right, hopefully that will head off a
lot of questions in the future...

> > If I embed a struct cdev within my own
> > device structure, how do I know when I can safely free said device
> > structure?  Will there be a release method that gets exposed at the driver
> > level, or am I missing something obvious again?
> 
> Umm...  Any kobject has ->release() method, obviously.  

Actually, as I read it, each kobject has a kobj_type pointer, and in *that*
structure is a release() method.  I had found it...:)

The struct cdev which I, as a driver author, can embed within my own
structure has a kobject in it.  If it's an embedded cdev, its ktype pointer
will be aimed at ktype_cdev_default, which sets up cdev_default_release()
as its release function.

If I understand things correctly, as long as references to the embedded
struct cdev remain, I cannot free the driver-specific structure in which
the struct cdev is embedded.  So, somehow, I need to know when that struct
cdev's release() method is called.  I could do that by changing its ktype
field to my own special type, and remembering to call cdev_purge() in my
own release function.  Somehow, however, that doesn't feel like the right
approach.  It seems to me like we need a release() method in struct cdev
that is called from the struct cdev's own release() method - at least, in
the non-dynamic case.  No?  What am I missing here?

Thanks,

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net

  reply	other threads:[~2003-09-22 21:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-19 23:10 [PATCH] RFC: Attributes in /sys/cdev Jonathan Corbet
2003-09-19 23:32 ` Greg KH
2003-09-20  1:28 ` viro
2003-09-20  2:47   ` Greg KH
2003-09-22 16:29   ` Patrick Mochel
2003-09-22 16:46   ` Jonathan Corbet
2003-09-22 21:00     ` viro
2003-09-22 21:15       ` Jonathan Corbet [this message]
2003-09-22 22:37         ` viro
2003-09-24 22:22           ` Greg KH

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=20030922211511.17009.qmail@lwn.net \
    --to=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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