public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/char/misc.c: deprecated call register_chrdev, and 256 minor limit eliminated
@ 2007-09-06  9:38 Renzo Davoli
  2007-09-06 10:04 ` Renzo Davoli
  0 siblings, 1 reply; 2+ messages in thread
From: Renzo Davoli @ 2007-09-06  9:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mathiasen, Torben

[-- Attachment #1: Type: text/plain, Size: 912 bytes --]

Dear Kernel Developers,

I have seen that drivers/char/misc.c already used the deprecated 
register_chrdev call and this limited the number of minors to 256.

I recetly asked for a misc minor number attribution for View-OS/kmview
and Torben Mathiasen told me about this issue.

I propose this patch that eliminate both problems. With this patch 
misc allocates the entire major 10 and avoids the deprecated call.

These are just my 2 (euro) cents, I hope it can be useful.

	renzo
-- 
============================================================================
Renzo Davoli				| Dept. of Computer Science
(NIC rd235, HAM IZ4DJE)                 | University of Bologna	
Tel. +39 051 2094501			| Mura Anteo Zamboni, 7
Fax. +39 051 2094510			| I-40127 Bologna  ITALY
Key fingerprint = A019 17E2 5562 06F6 77BB  2E93 1A01 F646 30EA B487
============================================================================

[-- Attachment #2: drivers_char_misc.patch --]
[-- Type: text/plain, Size: 1318 bytes --]

--- drivers/char/misc.orig.c	2007-08-05 16:56:59.000000000 +0200
+++ drivers/char/misc.c	2007-09-06 11:07:51.000000000 +0200
@@ -56,6 +56,8 @@
 static LIST_HEAD(misc_list);
 static DEFINE_MUTEX(misc_mtx);
 
+static struct cdev misc_cdev;
+
 /*
  * Assigned numbers, used for dynamic minors
  */
@@ -273,6 +275,31 @@
 EXPORT_SYMBOL(misc_register);
 EXPORT_SYMBOL(misc_deregister);
 
+static int misc_register_chrdev(void)
+{
+	dev_t from=MKDEV(MISC_MAJOR,0);
+	int rv;
+	int err = -ENOMEM;
+	char *s;
+
+	if ((rv=register_chrdev_region(from,MINORMASK,"misc")) != 0)
+		return rv;
+
+	cdev_init(&misc_cdev, &misc_fops);
+	misc_cdev.owner=misc_fops.owner;
+	kobject_set_name(&misc_cdev.kobj, "%s", "misc");
+	for (s = strchr(kobject_name(&misc_cdev.kobj),'/'); s; s = strchr(s, '/'))
+		    *s = '!';
+	err = cdev_add(&misc_cdev, from, MINORMASK);
+	if (err)
+		goto out;
+	return 0;
+out:
+	kobject_put(&misc_cdev.kobj);
+	unregister_chrdev_region(from,MINORMASK);
+  return err;
+}
+
 static int __init misc_init(void)
 {
 #ifdef CONFIG_PROC_FS
@@ -286,7 +313,7 @@
 	if (IS_ERR(misc_class))
 		return PTR_ERR(misc_class);
 
-	if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
+	if (misc_register_chrdev()) {
 		printk("unable to get major %d for misc devices\n",
 		       MISC_MAJOR);
 		class_destroy(misc_class);

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

* Re: [PATCH] drivers/char/misc.c: deprecated call register_chrdev, and 256 minor limit eliminated
  2007-09-06  9:38 [PATCH] drivers/char/misc.c: deprecated call register_chrdev, and 256 minor limit eliminated Renzo Davoli
@ 2007-09-06 10:04 ` Renzo Davoli
  0 siblings, 0 replies; 2+ messages in thread
From: Renzo Davoli @ 2007-09-06 10:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mathiasen, Torben

On Thu, Sep 06, 2007 at 11:38:44AM +0200, Renzo Davoli wrote:
Dear Kernel Developers,

I have seen that drivers/char/misc.c already used the deprecated 
register_chrdev call and this limited the number of minors to 256.

I recetly asked for a misc minor number attribution for View-OS/kmview
and Torben Mathiasen told me about this issue.

I propose this patch that eliminate both problems. With this patch 
misc allocates the entire major 10 and avoids the deprecated call.

These are just my 2 (euro) cents, I hope it can be useful.

	renzo

Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>

-- 
============================================================================
Renzo Davoli				| Dept. of Computer Science
(NIC rd235, HAM IZ4DJE)                 | University of Bologna	
Tel. +39 051 2094501			| Mura Anteo Zamboni, 7
Fax. +39 051 2094510			| I-40127 Bologna  ITALY
Key fingerprint = A019 17E2 5562 06F6 77BB  2E93 1A01 F646 30EA B487
============================================================================

--- drivers/char/misc.orig.c	2007-08-05 16:56:59.000000000 +0200
+++ drivers/char/misc.c	2007-09-06 11:07:51.000000000 +0200
@@ -56,6 +56,8 @@
 static LIST_HEAD(misc_list);
 static DEFINE_MUTEX(misc_mtx);
 
+static struct cdev misc_cdev;
+
 /*
  * Assigned numbers, used for dynamic minors
  */
@@ -273,6 +275,31 @@
 EXPORT_SYMBOL(misc_register);
 EXPORT_SYMBOL(misc_deregister);
 
+static int misc_register_chrdev(void)
+{
+	dev_t from=MKDEV(MISC_MAJOR,0);
+	int rv;
+	int err = -ENOMEM;
+	char *s;
+
+	if ((rv=register_chrdev_region(from,MINORMASK,"misc")) != 0)
+		return rv;
+
+	cdev_init(&misc_cdev, &misc_fops);
+	misc_cdev.owner=misc_fops.owner;
+	kobject_set_name(&misc_cdev.kobj, "%s", "misc");
+	for (s = strchr(kobject_name(&misc_cdev.kobj),'/'); s; s = strchr(s, '/'))
+		    *s = '!';
+	err = cdev_add(&misc_cdev, from, MINORMASK);
+	if (err)
+		goto out;
+	return 0;
+out:
+	kobject_put(&misc_cdev.kobj);
+	unregister_chrdev_region(from,MINORMASK);
+  return err;
+}
+
 static int __init misc_init(void)
 {
 #ifdef CONFIG_PROC_FS
@@ -286,7 +313,7 @@
 	if (IS_ERR(misc_class))
 		return PTR_ERR(misc_class);
 
-	if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
+	if (misc_register_chrdev()) {
 		printk("unable to get major %d for misc devices\n",
 		       MISC_MAJOR);
 		class_destroy(misc_class);


-- 
============================================================================
Renzo Davoli				| Dept. of Computer Science
(NIC rd235, HAM IZ4DJE)                 | University of Bologna	
Tel. +39 051 2094501			| Mura Anteo Zamboni, 7
Fax. +39 051 2094510			| I-40127 Bologna  ITALY
Key fingerprint = A019 17E2 5562 06F6 77BB  2E93 1A01 F646 30EA B487
============================================================================

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

end of thread, other threads:[~2007-09-06 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-06  9:38 [PATCH] drivers/char/misc.c: deprecated call register_chrdev, and 256 minor limit eliminated Renzo Davoli
2007-09-06 10:04 ` Renzo Davoli

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