From: Christoph Hellwig <hch@lst.de>

Currently the tty code abuses tty_driver.name as the prefix for the devfs
names of the ttys.  This is a very bad idea because it means the tty name
changes depending on whether devfs is enabled or not, leading to different
names in /proc/tty/ depending on whether we have devfs or not (and not
whether it actually is mounted!) and a huge amount of ifdefs.

The patch below adds a .devfs_name member instead, similar to the block
device changes a few weeks ago.



 25-akpm/arch/mips/au1000/common/serial.c |    5 ---
 25-akpm/arch/ppc/8260_io/uart.c          |    5 ---
 25-akpm/arch/ppc/8xx_io/uart.c           |    5 ---
 25-akpm/drivers/char/dz.c                |    5 ---
 25-akpm/drivers/char/ip2main.c           |   21 ++--------------
 25-akpm/drivers/char/pty.c               |   10 +------
 25-akpm/drivers/char/rocket.c            |    5 ---
 25-akpm/drivers/char/serial167.c         |    5 ---
 25-akpm/drivers/char/sh-sci.c            |    5 ---
 25-akpm/drivers/char/stallion.c          |    8 +-----
 25-akpm/drivers/char/tty_io.c            |   40 +++++++------------------------
 25-akpm/drivers/char/vme_scc.c           |    5 ---
 25-akpm/drivers/char/vt.c                |    3 +-
 25-akpm/drivers/isdn/i4l/isdn_tty.c      |    9 +-----
 25-akpm/drivers/macintosh/macserial.c    |    5 ---
 25-akpm/drivers/s390/net/ctctty.c        |   13 ++--------
 25-akpm/drivers/serial/8250.c            |    5 ---
 25-akpm/drivers/serial/core.c            |    1 
 25-akpm/drivers/serial/nb85e_uart.c      |    5 ---
 25-akpm/drivers/serial/sunsab.c          |    5 ---
 25-akpm/drivers/serial/sunsu.c           |    5 ---
 25-akpm/drivers/serial/sunzilog.c        |    5 ---
 25-akpm/drivers/tc/zs.c                  |    5 ---
 25-akpm/drivers/usb/serial/usb-serial.c  |    5 ---
 25-akpm/include/linux/serial_core.h      |    1 
 25-akpm/include/linux/tty_driver.h       |    1 
 25-akpm/net/bluetooth/rfcomm/tty.c       |    5 ---
 27 files changed, 44 insertions(+), 148 deletions(-)

diff -puN arch/mips/au1000/common/serial.c~fix-tty-driver-mess arch/mips/au1000/common/serial.c
--- 25/arch/mips/au1000/common/serial.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/arch/mips/au1000/common/serial.c	Tue Jun  3 14:01:25 2003
@@ -2549,11 +2549,8 @@ static int __init rs_init(void)
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
-#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	serial_driver.name = "tts/";
-#else
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64 + SERIAL_DEV_OFFSET;
 	serial_driver.num = NR_PORTS;
diff -puN arch/ppc/8260_io/uart.c~fix-tty-driver-mess arch/ppc/8260_io/uart.c
--- 25/arch/ppc/8260_io/uart.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/arch/ppc/8260_io/uart.c	Tue Jun  3 14:01:25 2003
@@ -2467,11 +2467,8 @@ int __init rs_8xx_init(void)
 	__clear_user(&serial_driver,sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
-#ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/";
-#else
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
 	serial_driver.num = NR_PORTS;
diff -puN arch/ppc/8xx_io/uart.c~fix-tty-driver-mess arch/ppc/8xx_io/uart.c
--- 25/arch/ppc/8xx_io/uart.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/arch/ppc/8xx_io/uart.c	Tue Jun  3 14:01:25 2003
@@ -2520,11 +2520,8 @@ int __init rs_8xx_init(void)
 	__clear_user(&serial_driver,sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.driver_name = "serial";
-#ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/";
-#else
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
 	serial_driver.num = NR_PORTS;
diff -puN drivers/char/dz.c~fix-tty-driver-mess drivers/char/dz.c
--- 25/drivers/char/dz.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/dz.c	Tue Jun  3 14:01:25 2003
@@ -1295,11 +1295,8 @@ int __init dz_init(void)
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.owner = THIS_MODULE;
-#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#else
-	serial_driver.name = "tts/";
-#endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
 	serial_driver.num = DZ_NB_PORT;
diff -puN drivers/char/ip2main.c~fix-tty-driver-mess drivers/char/ip2main.c
--- 25/drivers/char/ip2main.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/ip2main.c	Tue Jun  3 14:01:25 2003
@@ -94,9 +94,7 @@
 #include <linux/module.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
-#ifdef	CONFIG_DEVFS_FS
 #include <linux/devfs_fs_kernel.h>
-#endif
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
@@ -229,11 +227,6 @@ static char *pcVersion = "1.2.14";
 
 /* String constants for port names */
 static char *pcDriver_name   = "ip2";
-#ifdef	CONFIG_DEVFS_FS
-static char *pcTty    		 = "tts/F%d";
-#else
-static char *pcTty    		 = "ttyF";
-#endif
 static char *pcIpl    		 = "ip2ipl";
 
 /* Serial subtype definitions */
@@ -564,10 +557,7 @@ cleanup_module(void)
 int
 ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) 
 {
-#ifdef	CONFIG_DEVFS_FS
-	int j, box;
-#endif
-	int i;
+	int i, j, box;
 	int err;
 	int status = 0;
 	static int loaded;
@@ -786,7 +776,8 @@ ip2_loadmain(int *iop, int *irqp, unsign
 	/* Initialise the relevant fields. */
 	ip2_tty_driver.magic                = TTY_DRIVER_MAGIC;
 	ip2_tty_driver.owner		    = THIS_MODULE;
-	ip2_tty_driver.name                 = pcTty;
+	ip2_tty_driver.name                 = "ttyF";
+	ip2_tty_driver.devfs_name	    = "tts/F";
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0)
 	ip2_tty_driver.driver_name          = pcDriver_name;
 	ip2_tty_driver.read_proc          	= ip2_read_proc;
@@ -798,11 +789,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 	ip2_tty_driver.subtype              = SERIAL_TYPE_NORMAL;
 	ip2_tty_driver.init_termios         = tty_std_termios;
 	ip2_tty_driver.init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
-#ifdef	CONFIG_DEVFS_FS
 	ip2_tty_driver.flags                = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
-#else
-	ip2_tty_driver.flags                = TTY_DRIVER_REAL_RAW;
-#endif
 	ip2_tty_driver.refcount             = &ref_count;
 	ip2_tty_driver.table                = TtyTable;
 	ip2_tty_driver.termios              = Termios;
@@ -851,7 +838,6 @@ ip2_loadmain(int *iop, int *irqp, unsign
 				continue;
 			}
 
-#ifdef	CONFIG_DEVFS_FS
 			if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
 				devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
 						S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
@@ -874,7 +860,6 @@ ip2_loadmain(int *iop, int *irqp, unsign
 			        }
 			    }
 			}
-#endif
 
 			if (poll_only) {
 //		Poll only forces driver to only use polling and
diff -puN drivers/char/pty.c~fix-tty-driver-mess drivers/char/pty.c
--- 25/drivers/char/pty.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/pty.c	Tue Jun  3 14:01:25 2003
@@ -347,11 +347,8 @@ int __init pty_init(void)
 	pty_driver.magic = TTY_DRIVER_MAGIC;
 	pty_driver.owner = THIS_MODULE;
 	pty_driver.driver_name = "pty_master";
-#ifdef CONFIG_DEVFS_FS
-	pty_driver.name = "pty/m";
-#else
 	pty_driver.name = "pty";
-#endif
+	pty_driver.devfs_name = "pty/m";
 	pty_driver.major = PTY_MASTER_MAJOR;
 	pty_driver.minor_start = 0;
 	pty_driver.num = NR_PTYS;
@@ -382,11 +379,8 @@ int __init pty_init(void)
 	pty_slave_driver = pty_driver;
 	pty_slave_driver.driver_name = "pty_slave";
 	pty_slave_driver.proc_entry = 0;
-#ifdef CONFIG_DEVFS_FS
-	pty_slave_driver.name = "pty/s";
-#else
 	pty_slave_driver.name = "ttyp";
-#endif
+	pty_slave_driver.devfs_name = "pty/s";
 	pty_slave_driver.subtype = PTY_TYPE_SLAVE;
 	pty_slave_driver.major = PTY_SLAVE_MAJOR;
 	pty_slave_driver.minor_start = 0;
diff -puN drivers/char/rocket.c~fix-tty-driver-mess drivers/char/rocket.c
--- 25/drivers/char/rocket.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/rocket.c	Tue Jun  3 14:01:25 2003
@@ -1964,11 +1964,8 @@ int __init rp_init(void)
 	memset(&rocket_driver, 0, sizeof(struct tty_driver));
 	rocket_driver.magic = TTY_DRIVER_MAGIC;
 	rocket_driver.owner = THIS_MODULE;
-#ifdef CONFIG_DEVFS_FS
-	rocket_driver.name = "tts/R";
-#else
+	rocket_driver.devfs_name = "tts/R";
 	rocket_driver.name = "ttyR";
-#endif
 	rocket_driver.major = TTY_ROCKET_MAJOR;
 	rocket_driver.minor_start = 0;
 	rocket_driver.num = MAX_RP_PORTS;
diff -puN drivers/char/serial167.c~fix-tty-driver-mess drivers/char/serial167.c
--- 25/drivers/char/serial167.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/serial167.c	Tue Jun  3 14:01:25 2003
@@ -2359,11 +2359,8 @@ scrn[1] = '\0';
     memset(&cy_serial_driver, 0, sizeof(struct tty_driver));
     cy_serial_driver.magic = TTY_DRIVER_MAGIC;
     cy_serial_driver.owner = THIS_MODULE;
-#ifdef CONFIG_DEVFS_FS
-    cy_serial_driver.name = "tts/";
-#else
+    cy_serial_driver.devfs_name = "tts/";
     cy_serial_driver.name = "ttyS";
-#endif
     cy_serial_driver.major = TTY_MAJOR;
     cy_serial_driver.minor_start = 64;
     cy_serial_driver.num = NR_PORTS;
diff -puN drivers/char/sh-sci.c~fix-tty-driver-mess drivers/char/sh-sci.c
--- 25/drivers/char/sh-sci.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/sh-sci.c	Tue Jun  3 14:01:25 2003
@@ -994,11 +994,8 @@ static int sci_init_drivers(void)
 	sci_driver.magic = TTY_DRIVER_MAGIC;
 	sci_driver.owner = THIS_MODULE;
 	sci_driver.driver_name = "sci";
-#ifdef CONFIG_DEVFS_FS
-	sci_driver.name = "ttsc/";
-#else
 	sci_driver.name = "ttySC";
-#endif
+	sci_driver.devfs_name = "ttsc/";
 	sci_driver.major = SCI_MAJOR;
 	sci_driver.minor_start = SCI_MINOR_START;
 	sci_driver.num = SCI_NPORTS;
diff -puN drivers/char/stallion.c~fix-tty-driver-mess drivers/char/stallion.c
--- 25/drivers/char/stallion.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/stallion.c	Tue Jun  3 14:01:25 2003
@@ -136,11 +136,6 @@ static int	stl_nrbrds = sizeof(stl_brdco
 static char	*stl_drvtitle = "Stallion Multiport Serial Driver";
 static char	*stl_drvname = "stallion";
 static char	*stl_drvversion = "5.6.0";
-#ifdef CONFIG_DEVFS_FS
-static char	*stl_serialname = "tts/E%d";
-#else
-static char	*stl_serialname = "ttyE";
-#endif
 
 static struct tty_driver	stl_serial;
 static struct tty_struct	*stl_ttys[STL_MAXDEVS];
@@ -3178,7 +3173,8 @@ int __init stl_init(void)
 	stl_serial.magic = TTY_DRIVER_MAGIC;
 	stl_serial.owner = THIS_MODULE;
 	stl_serial.driver_name = stl_drvname;
-	stl_serial.name = stl_serialname;
+	stl_serial.name = "ttyE";
+	stl_serial.devfs_name = "tts/E";
 	stl_serial.major = STL_SERIALMAJOR;
 	stl_serial.minor_start = 0;
 	stl_serial.num = STL_MAXBRDS * STL_MAXPORTS;
diff -puN drivers/char/tty_io.c~fix-tty-driver-mess drivers/char/tty_io.c
--- 25/drivers/char/tty_io.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/tty_io.c	Tue Jun  3 14:01:25 2003
@@ -2082,17 +2082,6 @@ static void tty_default_put_char(struct 
 	tty->driver->write(tty, 0, &ch, 1);
 }
 
-#ifdef CONFIG_DEVFS_FS
-static void tty_unregister_devfs(struct tty_driver *driver, int index)
-{
-	char path[64];
-	tty_line_name(driver, index, path);
-	devfs_remove(path);
-}
-#else
-# define tty_unregister_devfs(driver, index)	do { } while (0)
-#endif /* CONFIG_DEVFS_FS */
-
 static struct class tty_class = {
 	.name	= "tty",
 };
@@ -2117,7 +2106,6 @@ static CLASS_DEVICE_ATTR(dev, S_IRUGO, s
 static void tty_add_class_device(char *name, dev_t dev, struct device *device)
 {
 	struct tty_dev *tty_dev = NULL;
-	char *temp;
 	int retval;
 
 	tty_dev = kmalloc(sizeof(*tty_dev), GFP_KERNEL);
@@ -2125,16 +2113,9 @@ static void tty_add_class_device(char *n
 		return;
 	memset(tty_dev, 0x00, sizeof(*tty_dev));
 
-	/* stupid '/' in tty name strings... */
-	temp = strrchr(name, '/');
-	if (temp && (temp[1] != 0x00))
-		++temp;
-	else
-		temp = name;
-
 	tty_dev->class_dev.dev = device;
 	tty_dev->class_dev.class = &tty_class;
-	snprintf(tty_dev->class_dev.class_id, BUS_ID_SIZE, "%s", temp);
+	snprintf(tty_dev->class_dev.class_id, BUS_ID_SIZE, "%s", name);
 	retval = class_device_register(&tty_dev->class_dev);
 	if (retval)
 		goto error;
@@ -2189,7 +2170,6 @@ void tty_register_device(struct tty_driv
 			 struct device *device)
 {
 	dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
-	char name[64];
 
 	if (index >= driver->num) {
 		printk(KERN_ERR "Attempt to register invalid tty line number "
@@ -2197,16 +2177,16 @@ void tty_register_device(struct tty_driv
 		return;
 	}
 
-	tty_line_name(driver, index, name);
-	devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, name);
-
-	/* stupid console driver devfs names... change vc/X into ttyX */
-	if (driver->type == TTY_DRIVER_TYPE_CONSOLE)
-		sprintf(name, "tty%d", MINOR(dev));
+	devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
+			"%s%d", driver->devfs_name, index + driver->name_base);
 
 	/* we don't care about the ptys */
-	if (driver->type != TTY_DRIVER_TYPE_PTY)
-		tty_add_class_device (name, dev, device);
+	/* how nice to hide this behind some crappy interface.. */
+	if (driver->type != TTY_DRIVER_TYPE_PTY) {
+		char name[64];
+		tty_line_name(driver, index, name);
+		tty_add_class_device(name, dev, device);
+	}
 }
 
 /**
@@ -2219,7 +2199,7 @@ void tty_register_device(struct tty_driv
  */
 void tty_unregister_device(struct tty_driver *driver, unsigned index)
 {
-	tty_unregister_devfs(driver, index);
+	devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
 	tty_remove_class_device(MKDEV(driver->major, driver->minor_start) + index);
 }
 
diff -puN drivers/char/vme_scc.c~fix-tty-driver-mess drivers/char/vme_scc.c
--- 25/drivers/char/vme_scc.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/vme_scc.c	Tue Jun  3 14:01:25 2003
@@ -131,11 +131,8 @@ static int scc_init_drivers(void)
 	scc_driver.magic = TTY_DRIVER_MAGIC;
 	scc_driver.owner = THIS_MODULE;
 	scc_driver.driver_name = "scc";
-#ifdef CONFIG_DEVFS_FS
-	scc_driver.name = "tts/";
-#else
 	scc_driver.name = "ttyS";
-#endif
+	scc_driver.devfs_name = "tts/";
 	scc_driver.major = TTY_MAJOR;
 	scc_driver.minor_start = SCC_MINOR_BASE;
 	scc_driver.num = 2;
diff -puN drivers/char/vt.c~fix-tty-driver-mess drivers/char/vt.c
--- 25/drivers/char/vt.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/char/vt.c	Tue Jun  3 14:01:25 2003
@@ -2531,7 +2531,8 @@ int __init vty_init(void)
 	memset(&console_driver, 0, sizeof(struct tty_driver));
 	console_driver.magic = TTY_DRIVER_MAGIC;
 	console_driver.owner = THIS_MODULE;
-	console_driver.name = "vc/";
+	console_driver.devfs_name = "vc/";
+	console_driver.name = "tty";
 	console_driver.name_base = 1;
 	console_driver.major = TTY_MAJOR;
 	console_driver.minor_start = 1;
diff -puN drivers/isdn/i4l/isdn_tty.c~fix-tty-driver-mess drivers/isdn/i4l/isdn_tty.c
--- 25/drivers/isdn/i4l/isdn_tty.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/isdn/i4l/isdn_tty.c	Tue Jun  3 14:01:25 2003
@@ -62,12 +62,6 @@ isdn_tty_event_callback(struct isdn_slot
 #define MODEM_PARANOIA_CHECK
 #define MODEM_DO_RESTART
 
-#ifdef CONFIG_DEVFS_FS
-static char *isdn_ttyname_ttyI = "isdn/ttyI%d";
-#else
-static char *isdn_ttyname_ttyI = "ttyI";
-#endif
-
 struct isdn_modem isdn_mdm;
 
 static int bit2si[8] =
@@ -2013,7 +2007,8 @@ isdn_tty_init(void)
 	m = &isdn_mdm;
 	memset(&m->tty_modem, 0, sizeof(struct tty_driver));
 	m->tty_modem.magic = TTY_DRIVER_MAGIC;
-	m->tty_modem.name = isdn_ttyname_ttyI;
+	m->tty_modem.name = "ttyI";
+	m->tty_modem.devfs_name = "isdn/ttyI";
 	m->tty_modem.major = ISDN_TTY_MAJOR;
 	m->tty_modem.minor_start = 0;
 	m->tty_modem.num = ISDN_MAX_CHANNELS;
diff -puN drivers/macintosh/macserial.c~fix-tty-driver-mess drivers/macintosh/macserial.c
--- 25/drivers/macintosh/macserial.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/macintosh/macserial.c	Tue Jun  3 14:01:25 2003
@@ -2568,11 +2568,8 @@ no_dma:		
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.owner = THIS_MODULE;
 	serial_driver.driver_name = "macserial";
-#ifdef CONFIG_DEVFS_FS
-	serial_driver.name = "tts/";
-#else
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#endif /* CONFIG_DEVFS_FS */
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
 	serial_driver.num = zs_channels_found;
diff -puN drivers/s390/net/ctctty.c~fix-tty-driver-mess drivers/s390/net/ctctty.c
--- 25/drivers/s390/net/ctctty.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/s390/net/ctctty.c	Tue Jun  3 14:01:25 2003
@@ -28,9 +28,7 @@
 #include <linux/serial_reg.h>
 #include <linux/interrupt.h>
 #include <asm/uaccess.h>
-#ifdef CONFIG_DEVFS_FS
-#  include <linux/devfs_fs_kernel.h>
-#endif
+#include <linux/devfs_fs_kernel.h>
 #include "ctctty.h"
 
 #define CTC_TTY_MAJOR       43
@@ -89,12 +87,6 @@ static ctc_tty_driver *driver;
 
 #define CTC_TTY_NAME "ctctty"
 
-#ifdef CONFIG_DEVFS_FS
-static char *ctc_ttyname = "ctc/" CTC_TTY_NAME "%d";
-#else
-static char *ctc_ttyname = CTC_TTY_NAME;
-#endif
-
 static __u32 ctc_tty_magic = CTC_ASYNC_MAGIC;
 static int ctc_tty_shuttingdown = 0;
 
@@ -1170,7 +1162,8 @@ ctc_tty_init(void)
 	device = &driver->ctc_tty_device;
 
 	device->magic = TTY_DRIVER_MAGIC;
-	device->name = ctc_ttyname;
+	device->devfs_name = "ctc/" CTC_TTY_NAME;
+	device->name = CTC_TTY_NAME;
 	device->major = CTC_TTY_MAJOR;
 	device->minor_start = 0;
 	device->num = CTC_TTY_MAX_DEVICES;
diff -puN drivers/serial/8250.c~fix-tty-driver-mess drivers/serial/8250.c
--- 25/drivers/serial/8250.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/8250.c	Tue Jun  3 14:01:25 2003
@@ -2011,11 +2011,8 @@ console_initcall(serial8250_console_init
 static struct uart_driver serial8250_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
-#ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/",
-#else
+	.devfs_name		= "tts/",
 	.dev_name		= "ttyS",
-#endif
 	.major			= TTY_MAJOR,
 	.minor			= 64,
 	.nr			= UART_NR,
diff -puN drivers/serial/core.c~fix-tty-driver-mess drivers/serial/core.c
--- 25/drivers/serial/core.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/core.c	Tue Jun  3 14:01:25 2003
@@ -2115,6 +2115,7 @@ int uart_register_driver(struct uart_dri
 	normal->magic		= TTY_DRIVER_MAGIC;
 	normal->owner		= drv->owner;
 	normal->driver_name	= drv->driver_name;
+	normal->devfs_name	= drv->devfs_name;
 	normal->name		= drv->dev_name;
 	normal->major		= drv->major;
 	normal->minor_start	= drv->minor;
diff -puN drivers/serial/nb85e_uart.c~fix-tty-driver-mess drivers/serial/nb85e_uart.c
--- 25/drivers/serial/nb85e_uart.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/nb85e_uart.c	Tue Jun  3 14:01:25 2003
@@ -524,11 +524,8 @@ static struct uart_ops nb85e_uart_ops = 
 static struct uart_driver nb85e_uart_driver = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "nb85e_uart",
-#ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/",
-#else
+	.devfs_name		= "tts/",
 	.dev_name		= "ttyS",
-#endif
 	.major			= TTY_MAJOR,
 	.minor			= NB85E_UART_MINOR_BASE,
 	.nr			= NB85E_UART_NUM_CHANNELS,
diff -puN drivers/serial/sunsab.c~fix-tty-driver-mess drivers/serial/sunsab.c
--- 25/drivers/serial/sunsab.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/sunsab.c	Tue Jun  3 14:01:25 2003
@@ -827,11 +827,8 @@ static struct uart_ops sunsab_pops = {
 static struct uart_driver sunsab_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
-#ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/",
-#else
+	.devfs_name		= "tts/",
 	.dev_name		= "ttyS",
-#endif
 	.major			= TTY_MAJOR,
 };
 
diff -puN drivers/serial/sunsu.c~fix-tty-driver-mess drivers/serial/sunsu.c
--- 25/drivers/serial/sunsu.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/sunsu.c	Tue Jun  3 14:01:25 2003
@@ -1285,11 +1285,8 @@ out:
 static struct uart_driver sunsu_reg = {
 	.owner			= THIS_MODULE,
 	.driver_name		= "serial",
-#ifdef CONFIG_DEVFS_FS
-	.dev_name		= "tts/",
-#else
+	.devfs_name		= "tts/",
 	.dev_name		= "ttyS",
-#endif
 	.major			= TTY_MAJOR,
 };
 
diff -puN drivers/serial/sunzilog.c~fix-tty-driver-mess drivers/serial/sunzilog.c
--- 25/drivers/serial/sunzilog.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/serial/sunzilog.c	Tue Jun  3 14:01:25 2003
@@ -1030,11 +1030,8 @@ static int zilog_irq = -1;
 static struct uart_driver sunzilog_reg = {
 	.owner		=	THIS_MODULE,
 	.driver_name	=	"ttyS",
-#ifdef CONFIG_DEVFS_FS
-	.dev_name	=	"tts/",
-#else
+	.devfs_name	=	"tts/",
 	.dev_name	=	"ttyS",
-#endif
 	.major		=	TTY_MAJOR,
 };
 
diff -puN drivers/tc/zs.c~fix-tty-driver-mess drivers/tc/zs.c
--- 25/drivers/tc/zs.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/tc/zs.c	Tue Jun  3 14:01:25 2003
@@ -1840,11 +1840,8 @@ int __init zs_init(void)
 	memset(&serial_driver, 0, sizeof(struct tty_driver));
 	serial_driver.magic = TTY_DRIVER_MAGIC;
 	serial_driver.owner = THIS_MODULE;
-#if (LINUX_VERSION_CODE > 0x2032D && defined(CONFIG_DEVFS_FS))
-	serial_driver.name = "tts/";
-#else
+	serial_driver.devfs_name = "tts/";
 	serial_driver.name = "ttyS";
-#endif
 	serial_driver.major = TTY_MAJOR;
 	serial_driver.minor_start = 64;
 	serial_driver.num = zs_channels_found;
diff -puN drivers/usb/serial/usb-serial.c~fix-tty-driver-mess drivers/usb/serial/usb-serial.c
--- 25/drivers/usb/serial/usb-serial.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/drivers/usb/serial/usb-serial.c	Tue Jun  3 14:01:25 2003
@@ -1304,11 +1304,8 @@ struct tty_driver usb_serial_tty_driver 
 	.magic =		TTY_DRIVER_MAGIC,
 	.owner =		THIS_MODULE,
 	.driver_name =		"usbserial",
-#ifndef CONFIG_DEVFS_FS
+	.devfs_name =		"usb/tts/",
 	.name =			"ttyUSB",
-#else
-	.name =			"usb/tts/",
-#endif
 	.major =		SERIAL_TTY_MAJOR,
 	.minor_start =		0,
 	.num =			SERIAL_TTY_MINORS,
diff -puN include/linux/serial_core.h~fix-tty-driver-mess include/linux/serial_core.h
--- 25/include/linux/serial_core.h~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/include/linux/serial_core.h	Tue Jun  3 14:01:25 2003
@@ -266,6 +266,7 @@ struct uart_driver {
 	struct module		*owner;
 	const char		*driver_name;
 	const char		*dev_name;
+	const char		*devfs_name;
 	int			 major;
 	int			 minor;
 	int			 nr;
diff -puN include/linux/tty_driver.h~fix-tty-driver-mess include/linux/tty_driver.h
--- 25/include/linux/tty_driver.h~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/include/linux/tty_driver.h	Tue Jun  3 14:01:25 2003
@@ -124,6 +124,7 @@ struct tty_driver {
 	struct cdev cdev;
 	struct module	*owner;
 	const char	*driver_name;
+	const char	*devfs_name;
 	const char	*name;
 	int	name_base;	/* offset of printed name */
 	short	major;		/* major device number */
diff -puN net/bluetooth/rfcomm/tty.c~fix-tty-driver-mess net/bluetooth/rfcomm/tty.c
--- 25/net/bluetooth/rfcomm/tty.c~fix-tty-driver-mess	Tue Jun  3 14:01:25 2003
+++ 25-akpm/net/bluetooth/rfcomm/tty.c	Tue Jun  3 14:01:25 2003
@@ -863,11 +863,8 @@ static struct tty_driver rfcomm_tty_driv
 
 	.magic			= TTY_DRIVER_MAGIC,
 	.driver_name		= "rfcomm",
-#ifdef CONFIG_DEVFS_FS
-	.name			= "bluetooth/rfcomm/",
-#else
+	.devfs_name		= "bluetooth/rfcomm/",
 	.name			= "rfcomm",
-#endif
 	.major			= RFCOMM_TTY_MAJOR,
 	.minor_start		= RFCOMM_TTY_MINOR,
 	.num			= RFCOMM_TTY_PORTS,

_