From: Tejun Heo <tj@kernel.org>
To: Greg KH <greg@kroah.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND] char_dev: add cdev->release() and convert cdev_alloc() to use it
Date: Thu, 13 Nov 2008 17:58:54 +0900 [thread overview]
Message-ID: <491BEC4E.9030505@kernel.org> (raw)
In-Reply-To: <20080828181720.GB23898@kroah.com>
Hello, Greg.
I'm now trying to convert the cdev thing for CUSE and it just ain't
feel right.
Greg KH wrote:
>> Ah.. right, but taking cdev refcount out of the picture requires adding
>> 'severing' operation on cdev f_ops, which certainly is doable but isn't
>> it just cleaner to make cdev follow the usual lifetime management rules?
>> An object which is referenced counted requires ->release if it's gonna
>> be used in any non-simplistic way.
>
> Yes, but as you "normally" tie the cdev to the module itself, that
> handles the lifetime rules.
That "normally" is from the days when only a single or fixed number of
devices are associated with single module or driver.
> Now I really dont' like the current cdev interface, it's a bit too
> complex as it needed to support the old-style interfaces without any
> build time changes, but I think your change isn't needed as somehow all
> the current drivers that support dynamic devices don't need it.
Yes, it requires all drivers to have global device table and check
whether the device is still available at ->open. For most, drivers
usually have certain fixed number of devices which can directly be
indexed with minor. For CUSE, it gotta be a hash table or a b-tree.
I don't really see any point in not adding ->release. Time has
changed and everybody is playing with reference counts and ->release
methods. Plus, cdev_alloc() interface is half-baked anyway (no free
function for cases where cdev_add() fails, drivers call cdev_del() in
those cases risking unregistering other driver's map). It's perfectly
okay to keep it around for compatibility but there just is no reason
to cling to it.
> Actually, the kobject in cdev shouldn't be an kobject, it's not used for
> registering with sysfs at all, it should just be a kref. I sweep the
> tree for code that sets the name of the cdev every few months as people
> don't seem to realize this :)
Heh... CUSE did that too. Removing it.
Thanks.
--
tejun
next prev parent reply other threads:[~2008-11-13 8:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 16:36 [PATCH RESEND] char_dev: add cdev->release() and convert cdev_alloc() to use it Tejun Heo
2008-08-28 16:47 ` Greg KH
2008-08-28 16:56 ` Tejun Heo
2008-08-28 17:38 ` Greg KH
2008-08-28 17:44 ` Tejun Heo
2008-08-28 17:48 ` Greg KH
2008-08-28 17:55 ` Tejun Heo
2008-08-28 18:17 ` Greg KH
2008-11-13 8:58 ` Tejun Heo [this message]
[not found] ` <492136F5.8010903@kernel.org>
[not found] ` <20081117171717.GB31306@kroah.com>
[not found] ` <49221CE8.1050402@kernel.org>
2008-11-18 1:40 ` Tejun Heo
2008-11-18 13:44 ` Boaz Harrosh
2008-11-18 15:58 ` Tejun Heo
2008-11-19 17:59 ` Miklos Szeredi
2008-11-20 5:54 ` Greg KH
2008-11-20 6:28 ` Tejun Heo
2008-11-20 11:45 ` Tejun Heo
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=491BEC4E.9030505@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--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