The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Dynamic allocation of char majors in the new world order
@ 2003-09-16 19:24 Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2003-09-16 19:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: viro

Once again, I'm trying to figure out how char drivers are really going to
work once the dust has settled around the dev_t changes.  The new
register_chrdev_region() and cdev_* functions are reasonably easy to get a
grasp of, for the most part.  But I'm curious about one thing: what do you
do if you want to use the new functions with dynamic major number
allocation? 

Passing zero for the major number into register_chrdev_region() does almost
what one would want - it allocates a number for the caller.  The one thing
it does *not* do, however, is communicate that number back to the caller in
any way.  If you want to know what number you got, you have to call
__register_chrdev_region(), but that's static and uses a private structure
type - clearly not meant to be used that way.

Now, it wouldn't be that hard to hack register_chrdev_region() to save out
the actual major number and return it to the caller.  But I get the sense
that things ultimately are not meant to work that way.  I'm not a
particularly sensitive guy, but even I can notice little things like
comments reading "/* temporary */".  So...is there some grand design out
there on how dynamic majors are really supposed to work in 2.6?  Is it
rational to be trying to write something about char device registration at
this point?

Thanks,

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net


^ permalink raw reply	[flat|nested] 2+ messages in thread
* Re: Dynamic allocation of char majors in the new world order
@ 2003-09-17 19:52 Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2003-09-17 19:52 UTC (permalink / raw)
  To: linux-kernel

Yesterday I done wrote:

> The new register_chrdev_region() and cdev_* functions are reasonably easy
> to get a grasp of, for the most part.  But I'm curious about one thing:
> what do you do if you want to use the new functions with dynamic major
> number allocation?

Well, I'm a little slow, but it is possible for things to seep into my
brain eventually.  Further review of the source makes it clear that the
dynamic allocation case is what alloc_chrdev_region() is for.  

Look for a new article in the driver porting series shortly...

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-17 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-16 19:24 Dynamic allocation of char majors in the new world order Jonathan Corbet
  -- strict thread matches above, loose matches on Subject: below --
2003-09-17 19:52 Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox