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: Sat, 20 Sep 2003 02:28:44 +0100 [thread overview]
Message-ID: <20030920012844.GD7665@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20030919231046.4626.qmail@lwn.net>
On Fri, Sep 19, 2003 at 05:10:46PM -0600, Jonathan Corbet wrote:
> I assume that the (empty, currently) entries in /sys/cdev are there for
> some purpose... for purposes of my own, I've been thinking that it would
> be nice to be able to find which device numbers got assigned when using the
> new char dev registration functions. Thus, the following patch, which adds
> default "dev" and "count" attributes to /sys/cdev entries.
>
> I have no idea whether this follows the original plan for /sys/cdev.
> There *is* a plan for it, no...?
They are more of a side effect. The thing is, expected setup for character
devices is the following:
* driver has embedded struct cdev in its data structures
* it has the thing registered in global search structure - as tty
does, for example.
* open() on a character device finds the kobject of that cdev (same
as block device open() finds kobject of gendisk) and uses it for the rest of
work. Namely, file_operations() are picked from it and inode->i_cdev /
inode->i_cindex are set. Then we call ->open().
* ->open() can use ->i_cdev to get whatever data structure driver
had intended and avoid any lookups of its own (of course it's still perfectly
free to look at the minor, mess with its own arrya/lists/whatnot - it's not
mandatory anymore, but it certainly won't break).
To avoid breaking the old drivers we do the following: register_chrdev()
allocates a cdev itself, inserts it in search tree, etc., so open() on
character device registered that way will work with the new scheme. We'll
find the cdev allocated by register_chrdev(), take the file_operations from
it (register_chrdev() had stored the pointer when it had created cdev), set
->i_cindex (potentially useful for ->open()) and ->i_cdev (useless for ->open(),
since it has no relationship to any driver objects). And call ->open().
FWIW, I would be just fine with not seeing these guys in sysfs - they don't
have any intrinsic sense from the driver POV and they exist only for those
who use old scheme, so putting them to any universal use is hopeless.
Real driver-registered cdevs are different story - they should bear whatever
attributes driver wants them to bear. Note that even for tty conversion is
not complete - we still have sucky refcounting there and it has to be fixed
first. Once it's done, get_tty_driver() goes to hell and tty_driver embedded
cdev will get sane attributes.
BTW, I suspect that we need a way to say "this kobject and its children
will *never* have any attributes and will never be seen in sysfs". There
are quite a few uses when we keep kobject as a refcounting vehicle, etc.,
but have nothing meaningful to show in sysfs tree. Keep in mind that
sysfs nodes (including attributes) are not free - it's struct inode +
struct dentry at the very least. Both pinned down and permanently mapped...
next prev parent reply other threads:[~2003-09-20 1:28 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 [this message]
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
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=20030920012844.GD7665@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