Skip to contentSkip to conversation

devfs (2/7) - minor miscdev changes

PATCH In review Christoph Hellwig 2 participants 3 messages Apr 18, 2003 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devfs (2/7) - minor miscdev changes

Make sure the first argument to devfs_register is zero.

drivers/char/misc.c +11 -9
diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
@@ -166,8 +166,8 @@
  
 int misc_register(struct miscdevice * misc)
 {
-	static devfs_handle_t devfs_handle, dir;
 	struct miscdevice *c;
+	char buf[256];
 	
 	if (misc->next || misc->prev)
 		return -EBUSY;
@@ -195,14 +195,16 @@
 	}
 	if (misc->minor < DYNAMIC_MINORS)
 		misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
-	if (!devfs_handle)
-		devfs_handle = devfs_mk_dir("misc");
-	dir = strchr (misc->name, '/') ? NULL : devfs_handle;
-	misc->devfs_handle =
-		devfs_register (dir, misc->name, DEVFS_FL_NONE,
-				MISC_MAJOR, misc->minor,
-				S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
-				misc->fops, NULL);
+
+
+	/* yuck, yet another stupid special-casing.  We should rather
+	   add ->devfs_name to avoid this mess. */
+	snprintf(buf, sizeof(buf), strchr(misc->name, '/') ?
+			"%s" : "misc/%s", misc->name);
+	misc->devfs_handle = devfs_register(NULL, buf, 0,
+			MISC_MAJOR, misc->minor,
+			S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
+			misc->fops, NULL);
 
 	/*
 	 * Add it to the front, so that later devices can "override"
#1 lore raw

int misc_register(struct miscdevice * misc)
{
- static devfs_handle_t devfs_handle, dir;
struct miscdevice *c;
+ char buf[256];

Wouldn't it be better not to have a 256-byte buffer on the stack?

- Roland

#2 lore raw

drivers/char/misc.c

Quoted 7 lines · Roland Dreier

int misc_register(struct miscdevice * misc)
{

drivers/char/misc.c +1 -1
-	static devfs_handle_t devfs_handle, dir;
 	struct miscdevice *c;
+	char buf[256];
 
    Wouldn't it be better not to have a 256-byte buffer on the stack?

You're probably right. But 64 bytes should be enough anyway - that's what devfs uses everywhere else.