public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* kdev_t.h old major/minor numbers
@ 2011-08-10  8:21 Corey Richardson
  2011-08-10 15:19 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Corey Richardson @ 2011-08-10  8:21 UTC (permalink / raw)
  To: linux-kernel


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?

Patch:

--- 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__ */
 #endif
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
     -- Abraham Lincoln

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

* Re: kdev_t.h old major/minor numbers
  2011-08-10  8:21 kdev_t.h old major/minor numbers Corey Richardson
@ 2011-08-10 15:19 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2011-08-10 15:19 UTC (permalink / raw)
  To: Corey Richardson; +Cc: linux-kernel

On Wed, Aug 10, 2011 at 04:21:15AM -0400, Corey Richardson wrote:
> 
> 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?

No, it is done this way on purpose, please read the comment right before
the code you just changed.

greg k-h

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

end of thread, other threads:[~2011-08-10 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-10  8:21 kdev_t.h old major/minor numbers Corey Richardson
2011-08-10 15:19 ` Greg KH

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