kdev_t.h old major/minor numbers

From: Corey Richardson
Date: Wed Aug 10 2011 - 04:21:52 EST

While reading through some of the kernel stuff I noticed that the macros
at the end of include/linux/kdev_t.h were out-of-sync with the macros at
the top. I'm not certain when/if they would ever be defined and not the
other ones (I'm very new to the kernel), but I would assume that they
shouldn't be using the old 255-number system.

Was this just an oversight or is there something else going on?


--- linux/include/linux/kdev_t.h 2011-05-19 00:06:34.000000000 -0400
+++ git/include/linux/kdev_t.h. 2011-08-10 03:19:10.228987057 -0400
@@ -93,8 +93,11 @@
Some programs want their definitions of MAJOR and MINOR and MKDEV
from the kernel sources. These must be the externally visible ones.
-#define MAJOR(dev) ((dev)>>8)
-#define MINOR(dev) ((dev) & 0xff)
-#define MKDEV(ma,mi) ((ma)<<8 | (mi))
+#define MINORBITS 20
+#define MINORMASK ((1U << MINORBITS) - 1)
+#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
+#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
+#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
#endif /* __KERNEL__ */
Corey Richardson
"Those who deny freedom to others, deserve it not for themselves"
-- Abraham Lincoln
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/