Commit 7bfcc033 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] make config_max_raw_devices work

From: "Kenneth Chen" <kenneth.w.chen@intel.com>

Even though there is a CONFIG_MAX_RAW_DEVS option, it doesn't actually
increase the number of raw devices beyond 256 because during the char
registration, it uses the standard register_chrdev() interface which has
hard coded 256 minor in it.  Here is a patch that fix this problem by using
register_chrdev_region() and cdev_(init/add/del) functions.
parent a50d447d
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/raw.h> #include <linux/raw.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/cdev.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -260,11 +261,26 @@ static struct file_operations raw_ctl_fops = { ...@@ -260,11 +261,26 @@ static struct file_operations raw_ctl_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static struct cdev raw_cdev = {
.kobj = {.name = "raw", },
.owner = THIS_MODULE,
};
static int __init raw_init(void) static int __init raw_init(void)
{ {
int i; int i;
dev_t dev = MKDEV(RAW_MAJOR, 0);
if (register_chrdev_region(dev, MAX_RAW_MINORS, "raw"))
goto error;
cdev_init(&raw_cdev, &raw_fops);
if (cdev_add(&raw_cdev, dev, MAX_RAW_MINORS)) {
kobject_put(&raw_cdev.kobj);
unregister_chrdev_region(dev, MAX_RAW_MINORS);
goto error;
}
register_chrdev(RAW_MAJOR, "raw", &raw_fops);
devfs_mk_cdev(MKDEV(RAW_MAJOR, 0), devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
"raw/rawctl"); "raw/rawctl");
...@@ -273,6 +289,10 @@ static int __init raw_init(void) ...@@ -273,6 +289,10 @@ static int __init raw_init(void)
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
"raw/raw%d", i); "raw/raw%d", i);
return 0; return 0;
error:
printk(KERN_ERR "error register raw device\n");
return 1;
} }
static void __exit raw_exit(void) static void __exit raw_exit(void)
...@@ -283,7 +303,8 @@ static void __exit raw_exit(void) ...@@ -283,7 +303,8 @@ static void __exit raw_exit(void)
devfs_remove("raw/raw%d", i); devfs_remove("raw/raw%d", i);
devfs_remove("raw/rawctl"); devfs_remove("raw/rawctl");
devfs_remove("raw"); devfs_remove("raw");
unregister_chrdev(RAW_MAJOR, "raw"); cdev_del(&raw_cdev);
unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
} }
module_init(raw_init); module_init(raw_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment