Skip to contentSkip to conversation

use .devfs_name in struct miscdevice

PATCH In review Christoph Hellwig 2 participants 2 messages Apr 30, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use .devfs_name in struct miscdevice

There's three drivers in the tree that workaround the suboptimal devfs name choice of the misc device layer (/dev/misc/<foo>) using
devfs_mk_symlink. Switch them to set miscdev.devfs_name instead
to get the right name from the very beginning.

arch/i386/kernel/microcode.c +5 -14
@@ -65,7 +65,6 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/miscdevice.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 
@@ -116,9 +115,10 @@
 };
 
 static struct miscdevice microcode_dev = {
-	.minor = MICROCODE_MINOR,
-	.name	= "microcode",
-	.fops	= &microcode_fops,
+	.minor		= MICROCODE_MINOR,
+	.name		= "microcode",
+	.devfs_name	= "cpu/microcode",
+	.fops		= &microcode_fops,
 };
 
 static int __init microcode_init(void)
@@ -127,26 +127,17 @@
 
 	error = misc_register(&microcode_dev);
 	if (error)
-		goto fail;
-	error = devfs_mk_symlink("cpu/microcode", "../misc/microcode");
-	if (error)
-		goto fail_deregister;
+		return error;
 
 	printk(KERN_INFO 
 		"IA-32 Microcode Update Driver: v%s <[email protected]>\n", 
 		MICROCODE_VERSION);
 	return 0;
-
-fail_deregister:
-	misc_deregister(&microcode_dev);
-fail:
-	return error;
 }
 
 static void __exit microcode_exit(void)
 {
 	misc_deregister(&microcode_dev);
-	devfs_remove("cpu/microcode");
 	kfree(mc_applied);
 	printk(KERN_INFO "IA-32 Microcode Update Driver v%s unregistered\n", 
 			MICROCODE_VERSION);
drivers/md/dm-ioctl.c +4 -10
@@ -1084,9 +1084,10 @@
 };
 
 static struct miscdevice _dm_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name  = DM_NAME,
-	.fops  = &_ctl_fops
+	.minor		= MISC_DYNAMIC_MINOR,
+	.name		= DM_NAME,
+	.devfs_name	= "mapper/control",
+	.fops		= &_ctl_fops
 };
 
 /*
@@ -1107,18 +1108,12 @@
 		return r;
 	}
 
-	r = devfs_mk_symlink(DM_DIR "/control", "../misc/" DM_NAME);
-	if (r) {
-		DMERR("devfs_mk_symlink failed for control device");
-		goto failed;
-	}
 	DMINFO("%d.%d.%d%s initialised: %s", DM_VERSION_MAJOR,
 	       DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL, DM_VERSION_EXTRA,
 	       DM_DRIVER_EMAIL);
 	return 0;
 
       failed:
-	devfs_remove(DM_DIR "/control");
 	if (misc_deregister(&_dm_misc) < 0)
 		DMERR("misc_deregister failed for control device");
 	dm_hash_exit();
@@ -1127,7 +1122,6 @@
 
 void dm_interface_exit(void)
 {
-	devfs_remove(DM_DIR "/control");
 	if (misc_deregister(&_dm_misc) < 0)
 		DMERR("misc_deregister failed for control device");
 	dm_hash_exit();
drivers/media/radio/miropcm20-rds.c +2 -14
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/miscdevice.h>
-#include <linux/devfs_fs_kernel.h>
 #include <asm/uaccess.h>
 #include "miropcm20-rds-core.h"
 
@@ -114,28 +113,17 @@
 static struct miscdevice rds_miscdev = {
 	.minor		= MISC_DYNAMIC_MINOR,
 	.name		= "radiotext",
+	.devfs_name	= "v4l/rds/radiotext",
 	.fops		= &rds_fops,
 };
 
 static int __init miropcm20_rds_init(void)
 {
-	int error;
-
-	error = misc_register(&rds_miscdev);
-	if (error)
-		return error;
-
-	error = devfs_mk_symlink("v4l/rds/radiotext",
-				 "../misc/radiotext");
-	if (error)
-		misc_deregister(&rds_miscdev);
-
-	return error;
+	return misc_register(&rds_miscdev);
 }
 
 static void __exit miropcm20_rds_cleanup(void)
 {
-	devfs_remove("v4l/rds/radiotext");
 	misc_deregister(&rds_miscdev);
 }
 
#1 lore raw
Followup to:  <[email protected]>
By author:    Christoph Hellwig <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 6 lines

There's three drivers in the tree that workaround the suboptimal devfs name choice of the misc device layer (/dev/misc/<foo>) using
devfs_mk_symlink. Switch them to set miscdev.devfs_name instead
to get the right name from the very beginning.

Understatement of the week :)

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64