From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: vb@vsbe.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: associating miscdevice with inode
Date: Thu, 4 Feb 2010 11:13:37 +0000 [thread overview]
Message-ID: <20100204111337.0c474c94@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <f608b67d1002032224r74450689ge416382a1db8e4cf@mail.gmail.com>
On Wed, 3 Feb 2010 22:24:46 -0800
vb@vsbe.com wrote:
> guys,
>
> say I have a misc device driver which instantiates several devices.
> When a file operation on this device is invoked, I need to be able to
> figure out which device is being accessed. All available information
> are
>
> struct inode and struct file. Is there a way to find the address of
> the miscdevice structure passed to misc_register() when this device
> was created?
Not really. If you have a single misc device which each open creates a
new context of some sort then use filp->private_data to store your own
cotntext pointer.
Misc doesn't expect people to be registering lots of devices - its for
one offs and weirdnesses. You could I guess work backwards from
minor = iminor(inode);
and see which of your miscdevs has c->minor == minor.
If you have more than a couple of instances being put into misc you
should probably register an anonymous device major/minor range instead
and go direct.
Alan
next prev parent reply other threads:[~2010-02-04 11:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 6:24 vb
2010-02-04 11:13 ` Alan Cox [this message]
2010-02-04 15:00 ` vb
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=20100204111337.0c474c94@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=vb@vsbe.com \
/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®