From mboxrd@z Thu Jan 1 00:00:00 1970 From: danielhilst@gmail.com (Daniel Hilst Selli) Date: Mon, 25 Aug 2014 15:34:45 -0300 Subject: Strategies for accessing driver data from file operations!? In-Reply-To: <20140813214054.GA7214@kroah.com> References: <53EA1AE8.1030509@gmail.com> <20140812195328.GA20273@kroah.com> <53EB5E3B.20508@gmail.com> <20140813214054.GA7214@kroah.com> Message-ID: <53FB81C5.9010100@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On 08/13/2014 06:40 PM, Greg KH wrote: > 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 > It help-me alot Greg, thanks.. At last I know I'm doing in the right way :) Cheers,