kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Strategies for accessing driver data from file operations!?
Date: Thu, 14 Aug 2014 05:40:54 +0800	[thread overview]
Message-ID: <20140813214054.GA7214@kroah.com> (raw)
In-Reply-To: <53EB5E3B.20508@gmail.com>

On Wed, Aug 13, 2014 at 09:46:51AM -0300, Daniel Hilst Selli wrote:
> One last question, supposing I need to create multiple /dev nodes, do I need to
> allocate one struct cdev for each major:minor pair (cdev_alloc(), cdev_init(), cdev_add())?

No, you can allocate multiple minor numbers with a single set of cdev
calls.  But watch out, you also need to create a 'struct device' for
_each_ minor number you are actually using if you want the device nodes
to show up in /dev automatically.

Yeah, it's a pain, sorry, but this way you can allocate a whole range of
major:minor pairs but don't actually expose them to userspace until you
really need them (i.e. the hardware is present in the system.)  This
keeps /dev looking like only the devices that are present in the system,
not the "old" way of "every possible device that could ever be possibly
present".

Hope this helps,

greg k-h

  reply	other threads:[~2014-08-13 21:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 13:47 Strategies for accessing driver data from file operations!? Daniel Hilst Selli
2014-08-12 19:53 ` Greg KH
2014-08-13 12:46   ` Daniel Hilst Selli
2014-08-13 21:40     ` Greg KH [this message]
2014-08-25 18:34       ` Daniel Hilst Selli

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=20140813214054.GA7214@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).