Dynamic allocation of char majors in the new world order

From: Jonathan Corbet
Date: Tue Sep 16 2003 - 14:28:50 EST


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@xxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/