mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RFC: Attributes in /sys/cdev
Date: Mon, 22 Sep 2003 22:00:21 +0100	[thread overview]
Message-ID: <20030922210021.GH7665@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20030922164609.5929.qmail@lwn.net>

On Mon, Sep 22, 2003 at 10:46:09AM -0600, Jonathan Corbet wrote:
> > > I have no idea whether this follows the original plan for /sys/cdev.
> > 
> > They are more of a side effect.
> 
> So...to be sure I have things straight.../sys/cdev isn't really meant to be
> there, and char devices wanting to do things in sysfs should be working
> under /sys/devices or /sys/class or /sys/somethingelse?

<nod>

For block devices we really have non-trivial properties associated with them -
struct gendisk and request queue, for one thing.  And these are uniform across
the entire set.

Character devices per se have *no* meaningful properties common to the entire
class.  To put it another way, while block devices do form a natural class,
character ones do not.
 
> > 	* driver has embedded struct cdev in its data structures
> 
> > 	* ->open() can use ->i_cdev to get whatever data structure driver
> > had intended and avoid any lookups of its own
> 
> I noticed there's no "private" member in the cdev structure.  So drivers
> should embed the structure and use container_of to get their real structure
> of interest?

Yes, if they bother with cdev of their own in the first place.

> [Forgive my ignorance here...] 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.  NOTE: as always,
embedding kobject into one of your objects requires serious thinking about
lifetime rules for your objects.  Until they are cleaned up you'd better
*not* mess with that.  OTOH, in a lot of cases cleanup is needed anyway -
e.g. if you declare per-object sysctls/procfs entries/whatnot, you have
the same sort of problems already (plus you need to deal with the same
sort of races in your code that finds object by major:minor; many drivers
are FUBAR in that area).

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-19 23:10 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 [this message]
2003-09-22 21:15       ` Jonathan Corbet
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=20030922210021.GH7665@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®