char_dev: order /proc/devices by major number
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 15 Jun 2017 20:05:21 +0000 (14:05 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jul 2017 13:28:50 +0000 (15:28 +0200)
commit8a932f73e5b4227bf787474b44dc70b6961d6246
treed4aee1018a99bca853584061cb4cc71afecd7266
parenta5d31a3f81c6fb13b381951bf6163444c0257e8b
char_dev: order /proc/devices by major number

Presently, the order of the char devices listed in /proc/devices is not
entirely sequential. If a char device has a major number greater than
CHRDEV_MAJOR_HASH_SIZE (255), it will be ordered as if its major were
module 255. For example, 511 appears after 1.

This patch cleans that up and prints each major number in the correct
order, regardless of where they are stored in the hash table.

In order to do this, we introduce CHRDEV_MAJOR_MAX as an artificial
limit (chosen to be 511). It will then print all devices in major
order number from 0 to the maximum.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/char_dev.c
fs/proc/devices.c
include/linux/fs.h