From: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
To: "Jonathan Corbet" <corbet@lwn.net>
Cc: "Rolf Eike Beer" <eike-kernel@sf-tec.de>,
"Alexey Dobriyan" <adobriyan@gmail.com>,
"Andrew Morton" <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: cdev documentation (was Drop second arg of unregister_chrdev())
Date: Fri, 18 Aug 2006 09:49:45 -0400 [thread overview]
Message-ID: <d120d5000608180649s20dfa64ldcc3dae1ebc97012@mail.gmail.com> (raw)
In-Reply-To: <20060818130242.12410.qmail@lwn.net>
On 8/18/06, Jonathan Corbet <corbet@lwn.net> wrote:
> Rolf Eike Beer <eike-kernel@sf-tec.de> wrote:
>
> > Nevertheless, I ported my driver to the new interface. I see it cdev_add()
> > succeeding, but the device never shows up in sysfs. Do I have to do any more
> > tricks with class devices and stuff?
>
> Yes, cdevs do not, themselves, show up in sysfs. A simple class is what
> you want for that part of the job.
>
> > While I was sneaking around in the code I found this drivers/char/tty_io:3093
> >
> > cdev_init(&driver->cdev, &tty_fops);
> > driver->cdev.owner = driver->owner;
> > error = cdev_add(&driver->cdev, dev, driver->num);
> > if (error) {
> > cdev_del(&driver->cdev);
> >
> > Isn't the call to cdev_del() just wrong here?
>
> It is correct, in that it returns the reference you hold to the cdev's
> internal kobject. If you got the cdev with cdev_alloc(), that's the
> only way it will get returned to the system. For a cdev allocated
> elsewhere (as is the case here) it probably doesn't make any difference.
>
This is not a good practice though because it will attempt to unmap
device that is not mapped. Depeneding on changes in kmap code (for
example adding checks for regions being busy) blindly calling unmap
could unmap some other cdev. For dynamically allocated objects calling
kobject_put(&cdev->kobj) would be more correct but not very nice.
--
Dmitry
prev parent reply other threads:[~2006-08-18 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-15 3:35 [PATCH] Drop second arg of unregister_chrdev() Alexey Dobriyan
2006-08-15 3:48 ` Andrew Morton
2006-08-15 4:18 ` Alexey Dobriyan
2006-08-15 19:52 ` Jonathan Corbet
2006-08-16 7:03 ` Rolf Eike Beer
2006-08-16 15:42 ` Jonathan Corbet
2006-08-17 21:22 ` cdev documentation (was Drop second arg of unregister_chrdev()) Jonathan Corbet
2006-08-18 7:15 ` Rolf Eike Beer
2006-08-18 12:32 ` Dmitry Torokhov
2006-08-18 12:46 ` [TTY] Remove bogus call to cdev_del() Rolf Eike Beer
2006-08-18 13:02 ` cdev documentation (was Drop second arg of unregister_chrdev()) Jonathan Corbet
2006-08-18 13:49 ` Dmitry Torokhov [this message]
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=d120d5000608180649s20dfa64ldcc3dae1ebc97012@mail.gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=corbet@lwn.net \
--cc=eike-kernel@sf-tec.de \
--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
Powered by JetHome