* Query regarding alloc_chrdev_region() @ 2007-03-29 17:20 Rajat Jain 2007-03-30 2:10 ` Greg KH 0 siblings, 1 reply; 6+ messages in thread From: Rajat Jain @ 2007-03-29 17:20 UTC (permalink / raw) To: kernelnewbies, newbie Hi, I was wondering that while using dynamic device numner allocation, can we ever have a scenario like following (using alloc_chrdev_region): 1) Char Driver A is hooked on Major num X, minor numbers 0-10 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 If yes, how will the userland get to know about the dynamically allocated range (needed to create device nodes), since /proc/devices only shows major numbers? Thanks, Rajat - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Query regarding alloc_chrdev_region() 2007-03-29 17:20 Query regarding alloc_chrdev_region() Rajat Jain @ 2007-03-30 2:10 ` Greg KH 2007-03-30 2:36 ` Rajat Jain 0 siblings, 1 reply; 6+ messages in thread From: Greg KH @ 2007-03-30 2:10 UTC (permalink / raw) To: Rajat Jain; +Cc: kernelnewbies, newbie On Thu, Mar 29, 2007 at 10:50:34PM +0530, Rajat Jain wrote: > Hi, > > I was wondering that while using dynamic device numner allocation, can > we ever have a scenario like following (using alloc_chrdev_region): > > 1) Char Driver A is hooked on Major num X, minor numbers 0-10 > 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 > > If yes, how will the userland get to know about the dynamically > allocated range (needed to create device nodes), since /proc/devices > only shows major numbers? Through the exporting of this information in sysfs by using the device_create() call that you are required to do in order to have your device show up properly there :) thanks, greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Query regarding alloc_chrdev_region() 2007-03-30 2:10 ` Greg KH @ 2007-03-30 2:36 ` Rajat Jain 2007-03-30 5:19 ` Greg KH 0 siblings, 1 reply; 6+ messages in thread From: Rajat Jain @ 2007-03-30 2:36 UTC (permalink / raw) To: kernelnewbies; +Cc: newbie Hi, > > I was wondering that while using dynamic device numner allocation, can > > we ever have a scenario like following (using alloc_chrdev_region): > > > > 1) Char Driver A is hooked on Major num X, minor numbers 0-10 > > 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 So the above is actually possible? > > > > If yes, how will the userland get to know about the dynamically > > allocated range (needed to create device nodes), since /proc/devices > > only shows major numbers? > > Through the exporting of this information in sysfs by using the > device_create() call that you are required to do in order to have your > device show up properly there :) Is that taken care by cdev_add() itself? Thanks, Rajat - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Query regarding alloc_chrdev_region() 2007-03-30 2:36 ` Rajat Jain @ 2007-03-30 5:19 ` Greg KH 2007-03-30 6:26 ` Rajat Jain 0 siblings, 1 reply; 6+ messages in thread From: Greg KH @ 2007-03-30 5:19 UTC (permalink / raw) To: Rajat Jain; +Cc: kernelnewbies, newbie On Fri, Mar 30, 2007 at 08:06:23AM +0530, Rajat Jain wrote: > Hi, > > >> I was wondering that while using dynamic device numner allocation, can > >> we ever have a scenario like following (using alloc_chrdev_region): > >> > >> 1) Char Driver A is hooked on Major num X, minor numbers 0-10 > >> 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 > > So the above is actually possible? Yes, once you have a major number, you can separate out the minor numbers how ever you wish to. > >> If yes, how will the userland get to know about the dynamically > >> allocated range (needed to create device nodes), since /proc/devices > >> only shows major numbers? > > > >Through the exporting of this information in sysfs by using the > >device_create() call that you are required to do in order to have your > >device show up properly there :) > > Is that taken care by cdev_add() itself? Nope, not at all. thanks, greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Query regarding alloc_chrdev_region() 2007-03-30 5:19 ` Greg KH @ 2007-03-30 6:26 ` Rajat Jain 2007-03-30 6:34 ` Greg KH 0 siblings, 1 reply; 6+ messages in thread From: Rajat Jain @ 2007-03-30 6:26 UTC (permalink / raw) To: Greg KH; +Cc: kernelnewbies, newbie > > >> I was wondering that while using dynamic device numner allocation, can > > >> we ever have a scenario like following (using alloc_chrdev_region): > > >> > > >> 1) Char Driver A is hooked on Major num X, minor numbers 0-10 > > >> 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 > > > > So the above is actually possible? > > Yes, once you have a major number, you can separate out the minor > numbers how ever you wish to. Hi Greg, Ok, I understand that we can get a major number from the kernel and split it into a range of minor numbers. But does alloc_chrdev_region() reuse the major numbers in such a way? In other words, is the following scenario possible: Driver 1 ====== alloc_chrdev_region(10 minor nos required) -> receives major 150 (minor 0-9) Driver 2 ====== alloc_chrdev_region(20 minor nos required) -> receives major 150 (minor 10-29) Thanks, Rajat - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Query regarding alloc_chrdev_region() 2007-03-30 6:26 ` Rajat Jain @ 2007-03-30 6:34 ` Greg KH 0 siblings, 0 replies; 6+ messages in thread From: Greg KH @ 2007-03-30 6:34 UTC (permalink / raw) To: Rajat Jain; +Cc: kernelnewbies, newbie On Fri, Mar 30, 2007 at 11:56:28AM +0530, Rajat Jain wrote: > >> >> I was wondering that while using dynamic device numner allocation, can > >> >> we ever have a scenario like following (using alloc_chrdev_region): > >> >> > >> >> 1) Char Driver A is hooked on Major num X, minor numbers 0-10 > >> >> 2) Char Driver B is hooked on (same) Major num X, minor numbers 11-20 > >> > >> So the above is actually possible? > > > >Yes, once you have a major number, you can separate out the minor > >numbers how ever you wish to. > > Hi Greg, > > Ok, I understand that we can get a major number from the kernel and > split it into a range of minor numbers. > > But does alloc_chrdev_region() reuse the major numbers in such a way? > > In other words, is the following scenario possible: > > Driver 1 > ====== > alloc_chrdev_region(10 minor nos required) > -> receives major 150 (minor 0-9) > > Driver 2 > ====== > alloc_chrdev_region(20 minor nos required) > -> receives major 150 (minor 10-29) If you look at the code in fs/char_dev.c, this can not happen right now, however, that could change in the future if we start to see a lot of different drivers all want dynamic numbers. In short, don't count on the fact that you will always get a different major number, it is not guaranteed, and in fact, your driver should never care about such a thing. And also userspace doesn't care either, udev handles all of that logic for you automatically. Hope this helps, greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-30 6:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-03-29 17:20 Query regarding alloc_chrdev_region() Rajat Jain 2007-03-30 2:10 ` Greg KH 2007-03-30 2:36 ` Rajat Jain 2007-03-30 5:19 ` Greg KH 2007-03-30 6:26 ` Rajat Jain 2007-03-30 6:34 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox