]> git.hungrycats.org Git - linux/commitdiff
[PATCH] console cleanup (2/2)
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Thu, 24 Apr 2003 15:38:39 +0000 (08:38 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 24 Apr 2003 15:38:39 +0000 (08:38 -0700)
Console drivers cleanup.  In current tree interaction between
console and tty layer sits in the ->device() method of struct console.
It takes a pointer to console and returns device number of its tty
device.  open(2) on /dev/console goes through the list of registered
consoles, picks the first one that has ->device() and remaps the device
number to console->device(console).  Then it proceeds with normal
opening of tty.  This is the only caller of ->device().

Cleanup: let ->device() return a pair (pointer to tty_driver, index
of tty in question) instead of device number.  Note that
a) the first thing tty_open() does with remapped device number is
conversion to such pair.
b) console driver _knows_ which tty_driver we want - one that
implements tty interface to the same physical device (i.e. the part of
the same driver).
c) current code expects the result of ->device() to be a device
number of tty device - anything else is immediate -ENODEV from tty_open();
might as well have NULL ->device in that driver.

Console drivers converted, (the only) caller updated.

36 files changed:
arch/alpha/kernel/srmcons.c
arch/ia64/hp/sim/hpsim_console.c
arch/ia64/hp/sim/simserial.c
arch/m68k/sun3x/prom.c
arch/mips/au1000/common/serial.c
arch/mips/baget/vacserial.c
arch/mips/kernel/gdb-stub.c
arch/ppc/4xx_io/serial_sicc.c
arch/ppc/8260_io/uart.c
arch/ppc/8xx_io/uart.c
arch/sh/kernel/setup.c
arch/um/drivers/stdio_console.c
arch/v850/kernel/memcons.c
arch/v850/kernel/simcons.c
drivers/char/amiserial.c
drivers/char/dz.c
drivers/char/hvc_console.c
drivers/char/lp.c
drivers/char/lp_old98.c
drivers/char/serial167.c
drivers/char/serial_tx3912.c
drivers/char/sh-sci.c
drivers/char/tty_io.c
drivers/char/vme_scc.c
drivers/char/vt.c
drivers/macintosh/macserial.c
drivers/s390/char/con3215.c
drivers/s390/char/tuball.c
drivers/serial/68328serial.c
drivers/serial/68360serial.c
drivers/serial/core.c
drivers/serial/mcfserial.c
drivers/sgi/char/sgiserial.c
drivers/tc/zs.c
include/linux/console.h
include/linux/serial_core.h

index 29c5a04414b74928f55376264368739a23605cca..97d6def393b76cff79576429fb11eaea050ce44e 100644 (file)
@@ -318,11 +318,11 @@ srm_console_write(struct console *co, const char *s, unsigned count)
        spin_unlock_irqrestore(&srmcons_callback_lock, flags);
 }
 
-static kdev_t
-srm_console_device(struct console *co)
+static struct tty_driver *
+srm_console_device(struct console *co, int *index)
 {
-       return mk_kdev(srmcons_driver.major,
-                      srmcons_driver.minor_start + co->index);
+       *index = co->index;
+       return &srmcons_driver;
 }
 
 static int __init
index ad54d7e39934effd0a1dcb13292876024318e1c9..540f1d882a00ded63fb7e5844b321e362f33b3de 100644 (file)
@@ -27,7 +27,7 @@
 
 static int simcons_init (struct console *, char *);
 static void simcons_write (struct console *, const char *, unsigned);
-static kdev_t simcons_console_device (struct console *);
+static struct tty_driver *simcons_console_device (struct console *, int *);
 
 struct console hpsim_cons = {
        .name =         "simcons",
@@ -57,8 +57,9 @@ simcons_write (struct console *cons, const char *buf, unsigned count)
        }
 }
 
-static kdev_t
-simcons_console_device (struct console *c)
+static struct tty_driver *simcons_console_device (struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       extern struct tty_driver hp_serial_driver;
+       *index = c->index;
+       return &hp_serial_driver;
 }
index 6e671cacd825825ece4cbf2e8b467a3ab6ae3082..121fb7c223d7667ee96e2797d499aed6fb4ad51b 100644 (file)
@@ -103,7 +103,7 @@ static struct serial_uart_config uart_config[] = {
        { 0, 0}
 };
 
-static struct tty_driver serial_driver, callout_driver;
+static struct tty_driver hp_serial_driver, callout_driver;
 static int serial_refcount;
 
 static struct async_struct *IRQ_ports[NR_IRQS];
@@ -1028,43 +1028,43 @@ simrs_init (void)
 
        /* Initialize the tty_driver structure */
 
-       memset(&serial_driver, 0, sizeof(struct tty_driver));
-       serial_driver.magic = TTY_DRIVER_MAGIC;
-       serial_driver.driver_name = "simserial";
-       serial_driver.name = "ttyS";
-       serial_driver.major = TTY_MAJOR;
-       serial_driver.minor_start = 64;
-       serial_driver.num = 1;
-       serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
-       serial_driver.subtype = SERIAL_TYPE_NORMAL;
-       serial_driver.init_termios = tty_std_termios;
-       serial_driver.init_termios.c_cflag =
+       memset(&hp_serial_driver, 0, sizeof(struct tty_driver));
+       hp_serial_driver.magic = TTY_DRIVER_MAGIC;
+       hp_serial_driver.driver_name = "simserial";
+       hp_serial_driver.name = "ttyS";
+       hp_serial_driver.major = TTY_MAJOR;
+       hp_serial_driver.minor_start = 64;
+       hp_serial_driver.num = 1;
+       hp_serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
+       hp_serial_driver.subtype = SERIAL_TYPE_NORMAL;
+       hp_serial_driver.init_termios = tty_std_termios;
+       hp_serial_driver.init_termios.c_cflag =
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-       serial_driver.flags = TTY_DRIVER_REAL_RAW;
-       serial_driver.refcount = &serial_refcount;
-       serial_driver.table = serial_table;
-       serial_driver.termios = serial_termios;
-       serial_driver.termios_locked = serial_termios_locked;
-
-       serial_driver.open = rs_open;
-       serial_driver.close = rs_close;
-       serial_driver.write = rs_write;
-       serial_driver.put_char = rs_put_char;
-       serial_driver.flush_chars = rs_flush_chars;
-       serial_driver.write_room = rs_write_room;
-       serial_driver.chars_in_buffer = rs_chars_in_buffer;
-       serial_driver.flush_buffer = rs_flush_buffer;
-       serial_driver.ioctl = rs_ioctl;
-       serial_driver.throttle = rs_throttle;
-       serial_driver.unthrottle = rs_unthrottle;
-       serial_driver.send_xchar = rs_send_xchar;
-       serial_driver.set_termios = rs_set_termios;
-       serial_driver.stop = rs_stop;
-       serial_driver.start = rs_start;
-       serial_driver.hangup = rs_hangup;
-       serial_driver.break_ctl = rs_break;
-       serial_driver.wait_until_sent = rs_wait_until_sent;
-       serial_driver.read_proc = rs_read_proc;
+       hp_serial_driver.flags = TTY_DRIVER_REAL_RAW;
+       hp_serial_driver.refcount = &serial_refcount;
+       hp_serial_driver.table = serial_table;
+       hp_serial_driver.termios = serial_termios;
+       hp_serial_driver.termios_locked = serial_termios_locked;
+
+       hp_serial_driver.open = rs_open;
+       hp_serial_driver.close = rs_close;
+       hp_serial_driver.write = rs_write;
+       hp_serial_driver.put_char = rs_put_char;
+       hp_serial_driver.flush_chars = rs_flush_chars;
+       hp_serial_driver.write_room = rs_write_room;
+       hp_serial_driver.chars_in_buffer = rs_chars_in_buffer;
+       hp_serial_driver.flush_buffer = rs_flush_buffer;
+       hp_serial_driver.ioctl = rs_ioctl;
+       hp_serial_driver.throttle = rs_throttle;
+       hp_serial_driver.unthrottle = rs_unthrottle;
+       hp_serial_driver.send_xchar = rs_send_xchar;
+       hp_serial_driver.set_termios = rs_set_termios;
+       hp_serial_driver.stop = rs_stop;
+       hp_serial_driver.start = rs_start;
+       hp_serial_driver.hangup = rs_hangup;
+       hp_serial_driver.break_ctl = rs_break;
+       hp_serial_driver.wait_until_sent = rs_wait_until_sent;
+       hp_serial_driver.read_proc = rs_read_proc;
 
        /*
         * Let's have a little bit of fun !
@@ -1087,14 +1087,14 @@ simrs_init (void)
         * The callout device is just like normal device except for
         * major number and the subtype code.
         */
-       callout_driver = serial_driver;
+       callout_driver = hp_serial_driver;
        callout_driver.name = "cua";
        callout_driver.major = TTYAUX_MAJOR;
        callout_driver.subtype = SERIAL_TYPE_CALLOUT;
        callout_driver.read_proc = 0;
        callout_driver.proc_entry = 0;
 
-       if (tty_register_driver(&serial_driver))
+       if (tty_register_driver(&hp_serial_driver))
                panic("Couldn't register simserial driver\n");
 
        if (tty_register_driver(&callout_driver))
index 93dd64576e1aea6c1856a1edc4ba1f38a1c7089e..490f24dc3d017ba9fe688e87227726f321261844 100644 (file)
@@ -90,16 +90,10 @@ static void sun3x_prom_write(struct console *co, const char *s,
 /* debug console - write-only */
 
 static struct console sun3x_debug = {
-       "debug",
-       sun3x_prom_write,       /* write */
-       NULL,                   /* read */
-       NULL,                   /* device */
-       NULL,                   /* unblank */
-       NULL,                   /* setup */
-       CON_PRINTBUFFER,
-       -1,
-       0,
-       NULL
+       .name  =        "debug",
+       .write =        sun3x_prom_write,
+       .flags =        CON_PRINTBUFFER,
+       .index =        -1,
 };
 
 void sun3x_prom_init(void)
index 18c4a99f6dcc81ad2bc1c54d3c426166ec86625c..6a8ecd768632d2e506a31613bc2bc5f67f586ec0 100644 (file)
@@ -2915,9 +2915,10 @@ static void serial_console_write(struct console *co, const char *s,
        serial_out(info, UART_IER, ier);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + c->index);
+       *index = c->index - SERIAL_DEV_OFFSET;
+       return &serial_driver;
 }
 
 /*
index c949785bd6f364955e68b7f74a71b7cc1046a2db..aadfa933a23f17808323247c69b04d6510914b96 100644 (file)
@@ -2621,9 +2621,10 @@ static void serial_console_write(struct console *co, const char *s,
        serial_outp(&scr_info, VAC_UART_INT_MASK, ier);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 /*
index 0e37d0e3163f9a9508bb5d9b35d18482f3f3b366..e279dc48ca8a7d7055f78a550ae4c81468cdaa26 100644 (file)
@@ -942,11 +942,6 @@ void gdb_puts(const char *str)
        }
 }
 
-static kdev_t gdb_console_dev(struct console *con)
-{
-       return MKDEV(1, 3); /* /dev/null */
-}
-
 static void gdb_console_write(struct console *con, const char *s, unsigned n)
 {
        gdb_puts(s);
@@ -955,7 +950,6 @@ static void gdb_console_write(struct console *con, const char *s, unsigned n)
 static struct console gdb_console = {
        .name   = "gdb",
        .write  = gdb_console_write,
-       .device = gdb_console_dev,
        .flags  = CON_PRINTBUFFER,
        .index  = -1
 };
index 60acc7caa07d59c7a07db4d15c22f94f7a89fc32..f7b7044ecfe1c69f173897dc749e642c30c7c774 100644 (file)
@@ -1990,12 +1990,12 @@ static int siccuart_console_wait_key(struct console *co)
     return c;
 }
 
-static kdev_t siccuart_console_device(struct console *c)
+static struct tty_driver *siccuart_console_device(struct console *c, int *index)
 {
-    return MKDEV(SERIAL_SICC_MAJOR, SERIAL_SICC_MINOR + c->index);
+       *index = c->index;
+       return &siccnormal_driver;
 }
 
-
 static int __init siccuart_console_setup(struct console *co, char *options)
 {
     struct SICC_port *port;
index f4bdeb11dca024696a8d3d540a3ff5283760b14b..3393e85b05e9abb2f6a29ab941ff29f9844aa86e 100644 (file)
@@ -2449,7 +2449,8 @@ void kgdb_map_scc(void)
 
 static kdev_t serial_console_device(struct console *c)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 
index 5111ff2ae61703ebb72d8527802f27aaca987c9d..0465100f43e524fc0bf47ecfa984c685aa2fd35b 100644 (file)
@@ -91,7 +91,7 @@ static int serial_console_setup(struct console *co, char *options);
 
 static void serial_console_write(struct console *c, const char *s,
                                unsigned count);
-static kdev_t serial_console_device(struct console *c);
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 
 #if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 static unsigned long break_pressed; /* break, really ... */
@@ -2513,9 +2513,10 @@ void kgdb_map_scc(void)
 }
 #endif
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 /*
index 2b33c990517bce709717e33a2899f01e6e6a274f..10f02273b1dac4aa99cc81ec1e52623148c8984b 100644 (file)
@@ -139,12 +139,6 @@ static void sh_console_write(struct console *co, const char *s,
        sh_bios_console_write(s, count);
 }
 
-static kdev_t sh_console_device(struct console *c)
-{
-       /* /dev/null */
-       return mk_kdev(MEM_MAJOR, 3);
-}
-
 /*
  *     Setup initial baud/bits/parity. We do two things here:
  *     - construct a cflag setting for the first rs_open()
@@ -171,7 +165,6 @@ static int __init sh_console_setup(struct console *co, char *options)
 static struct console sh_console = {
        .name           = "bios",
        .write          = sh_console_write,
-       .device         = sh_console_device,
        .setup          = sh_console_setup,
        .flags          = CON_PRINTBUFFER,
        .index          = -1,
index 4aaec540e50525e638fd6623e66c78d1e8efcad7..f21c52fbbfd4d624858dfeeb32dee51b153f852a 100644 (file)
@@ -199,9 +199,10 @@ static struct tty_driver console_driver = {
        .set_termios            = set_termios
 };
 
-static kdev_t console_device(struct console *c)
+static struct tty_driver *console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, c->index);
+       *index = c->index;
+       return &console_driver;
 }
 
 static int console_setup(struct console *co, char *options)
index bd6c2fb1f09bee7551e4de684eb824aa05a21531..51e3b5b31d1683acf0f294fa3a3c5bcf3dad3e6b 100644 (file)
@@ -58,9 +58,11 @@ static void memcons_write (struct console *co, const char *buf, unsigned len)
                len -= write (buf, len);
 }
 
-static kdev_t memcons_device (struct console *co)
+extern struct tty_driver tty_driver;
+static struct tty_driver *memcons_device (struct console *co, int *index)
 {
-        return MKDEV (TTY_MAJOR, 64 + co->index);
+       *index = co->index;
+       return &tty_driver;
 }
 
 static struct console memcons =
index 35d8c7ef91d12ce80548c90ee47f8a78cbbb72ee..f4dbd755f17a4c2ea23c15bbaf74ee87e933ed75 100644 (file)
@@ -35,9 +35,11 @@ static int simcons_read (struct console *co, const char *buf, unsigned len)
        return V850_SIM_SYSCALL (read, 0, buf, len);
 }
 
-static kdev_t simcons_device (struct console *c)
+extern struct tty_driver tty_driver;
+static struct tty_driver *simcons_device (struct console *c, int *index)
 {
-        return mk_kdev (TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &tty_driver;
 }
 
 static struct console simcons =
index ca32674f45e7c5bd906d67fcfd181d79bbc834b4..810ba628f0752127753bd16ac99af62339dd8bb4 100644 (file)
@@ -2288,9 +2288,10 @@ static void serial_console_write(struct console *co, const char *s,
        custom.intena = IF_SETCLR | (intena & IF_TBE);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64);
+       *index = 0;
+       return &serial_driver;
 }
 
 static struct console sercons = {
index f29fb59793e530fd357ca226af91ee15968b496e..12a14689253fa93b9ae8c720a97d3c591bbed1a5 100644 (file)
@@ -1502,9 +1502,10 @@ static void dz_console_print (struct console *cons,
        }
 }
 
-static kdev_t dz_console_device(struct console *c)
+static struct tty_driver *dz_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 static int __init dz_console_setup(struct console *co, char *options)
index ed754f3df45fce124a8e87f75deca6ec44d0d8d8..2322dc4b89c29d5fb8cb2014573e198c47976b37 100644 (file)
@@ -324,9 +324,10 @@ void hvc_console_print(struct console *co, const char *b, unsigned count)
        }
 }
 
-static kdev_t hvc_console_device(struct console *c)
+static struct tty_driver *hvc_console_device(struct console *c, int *index)
 {
-       return mk_kdev(HVC_MAJOR, HVC_MINOR + c->index);
+       *index = c->index;
+       return &hvc_driver;
 }
 
 static int __init hvc_console_setup(struct console *co, char *options)
index f25ef37fd8c5bf131bb6b123678de0fd687fd94d..95dc6955cb945fb690bd952d8d9199d3b7962971 100644 (file)
@@ -733,15 +733,9 @@ static void lp_console_write (struct console *co, const char *s,
        parport_release (dev);
 }
 
-static kdev_t lp_console_device (struct console *c)
-{
-       return mk_kdev(LP_MAJOR, CONSOLE_LP);
-}
-
 static struct console lpcons = {
        .name           = "lp",
        .write          = lp_console_write,
-       .device         = lp_console_device,
        .flags          = CON_PRINTBUFFER,
 };
 
index 9bbdc2e4b8dec062954f012170e09b5cfd04df3e..fe5d3de82e0a2341874b980d3bcae2b786b91170 100644 (file)
@@ -441,15 +441,9 @@ static void lp_old98_console_write(struct console *console,
        }
 }
 
-static kdev_t lp_old98_console_device(struct console *console)
-{
-       return mk_kdev(LP_MAJOR, 0);
-}
-
 static struct console lp_old98_console = {
        .name   = "lp_old98",
        .write  = lp_old98_console_write,
-       .device = lp_old98_console_device,
        .flags  = CON_PRINTBUFFER,
        .index  = -1,
 };
index 929113786f728b4e12e6ca7a6f444bcf84398c38..61aa91704ae030449187926e26c35caf748d8443 100644 (file)
@@ -2814,9 +2814,10 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
        local_irq_restore(flags);
 }
 
-static kdev_t serial167_console_device(struct console *c)
+static struct tty_driver *serial167_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &cy_serial_driver;
 }
 
 
index 56d5da7b1ff5ecc87fb15112c318a53d658d2394..fa7ef4e2cd4c42744c90c8cd50c37cd84c1db1af 100644 (file)
@@ -1004,9 +1004,10 @@ static void serial_console_write(struct console *co, const char *s,
        }
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &rs_driver;
 }
 
 static __init int serial_console_setup(struct console *co, char *options)
index 10914fd23943ee71f4571a1eb2a41ea586e8a380..df14c284900d2c181a15aab8d79cc4a31cfbe4ad 100644 (file)
@@ -1179,9 +1179,10 @@ static void serial_console_write(struct console *co, const char *s,
        put_string(sercons_port, s, count);
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return mk_kdev(SCI_MAJOR, SCI_MINOR_START + c->index);
+       *index = c->index;
+       return &sci_driver;
 }
 
 /*
index 357c331adc8d61477092f002e6e3ed23838e1d5a..e6e5d8de0d7642f6a522ce3095b08a253eca0010 100644 (file)
@@ -1315,26 +1315,36 @@ retry_open:
        if (IS_TTY_DEV(device)) {
                if (!current->tty)
                        return -ENXIO;
-               device = to_kdev_t(current->tty->device);
+               driver = current->tty->driver;
+               index = current->tty->index;
                filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
                /* noctty = 1; */
+               goto got_driver;
        }
 #ifdef CONFIG_VT
        if (IS_CONSOLE_DEV(device)) {
                extern int fg_console;
-               device = mk_kdev(TTY_MAJOR, fg_console + 1);
+               extern struct tty_driver console_driver;
+               driver = &console_driver;
+               index = fg_console;
                noctty = 1;
+               goto got_driver;
        }
 #endif
        if (IS_SYSCONS_DEV(device)) {
                struct console *c = console_drivers;
-               while(c && !c->device)
-                       c = c->next;
-               if (!c)
-                        return -ENODEV;
-                device = c->device(c);
-               filp->f_flags |= O_NONBLOCK; /* Don't let /dev/console block */
-               noctty = 1;
+               for (c = console_drivers; c; c = c->next) {
+                       if (!c->device)
+                               continue;
+                       driver = c->device(c, &index);
+                       if (!driver)
+                               continue;
+                       /* Don't let /dev/console block */
+                       filp->f_flags |= O_NONBLOCK;
+                       noctty = 1;
+                       goto got_driver;
+               }
+               return -ENODEV;
        }
 
        if (IS_PTMX_DEV(device)) {
@@ -1357,7 +1367,7 @@ retry_open:
                driver = get_tty_driver(kdev_t_to_nr(device), &index);
                if (!driver)
                        return -ENODEV;
-
+got_driver:
                retval = init_dev(driver, index, &tty);
                if (retval)
                        return retval;
index 4b5e55709fa969f4af6368aad0e5ea14065439e4..93e654dc2f49df3a2f77b1e177a9a84ae3b341ef 100644 (file)
@@ -1069,9 +1069,10 @@ static void scc_console_write (struct console *co, const char *str, unsigned cou
        local_irq_restore(flags);
 }
 
-static kdev_t scc_console_device(struct console *c)
+static struct tty_driver *scc_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, SCC_MINOR_BASE + c->index);
+       *index = c->index;
+       return &scc_driver;
 }
 
 
index a5e75c3d65e495f5a7c3e3209b28b9213492d98f..8001d2e3d8c05c4dfe40d647f7dc624fc8d08e51 100644 (file)
@@ -2180,9 +2180,12 @@ quit:
        clear_bit(0, &printing);
 }
 
-static kdev_t vt_console_device(struct console *c)
+struct tty_driver console_driver;
+
+static struct tty_driver *vt_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, c->index ? c->index : fg_console + 1);
+       *index = c->index ? c->index-1 : fg_console;
+       return &console_driver;
 }
 
 struct console vt_console_driver = {
@@ -2455,7 +2458,6 @@ static void vc_init(unsigned int currcons, unsigned int rows, unsigned int cols,
  * the appropriate escape-sequence.
  */
 
-struct tty_driver console_driver;
 static int console_refcount;
 
 static int __init con_init(void)
index 18037963b7e377ca2f25ba2ae01b9522005b7415..dc0f2485d5c73aa60f01bb72fe5e1fcc61325eda 100644 (file)
@@ -2835,9 +2835,11 @@ static void serial_console_write(struct console *co, const char *s,
        /* Don't disable the transmitter. */
 }
 
-static kdev_t serial_console_device(struct console *c)
+extern struct tty_driver serial_driver;
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 /*
index a719b1a11f53cdeb70d1ec1fe1fb2b700c07676b..0c4d434de5aa83ca6c9b39dfad9977b51df6ace0 100644 (file)
@@ -840,10 +840,10 @@ con3215_write(struct console *co, const char *str, unsigned int count)
        }
 }
 
-static kdev_t
-con3215_device(struct console *c)
+static struct tty_driver *con3215_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, c->index + 64 );
+       *index = c->index;
+       return &tty3215_driver;
 }
 
 /*
index b9ceb8c2b7d2f83ac78d9c68ba46a73106b57b81..638900dc13ab091bfc8d1f5d744258a374367bda 100644 (file)
@@ -82,7 +82,7 @@ int tub3270_init(void);
  * Can't have this driver a module & support console at the same time
  */
 #ifdef CONFIG_TN3270_CONSOLE
-static kdev_t tub3270_con_device(struct console *);
+static struct tty_driver *tub3270_con_device(struct console *, int *);
 static void tub3270_con_unblank(void);
 static void tub3270_con_write(struct console *, const char *,
        unsigned int);
@@ -144,10 +144,11 @@ console_initcall(tub3270_con_init);
 
 #endif
 
-static kdev_t
-tub3270_con_device(struct console *conp)
+static struct tty_driver *tub3270_con_device(struct console *conp, int *index)
 {
-       return tub_mkdev(IBM_TTY3270_MAJOR, conp->index + 1);
+       *index = conp->index + 1;
+       extern struct tty_driver tty3270_driver;
+       return &tty3270_driver;
 }
 
 static void
index ca48aacc6081304e42f80770e1f4e40ea1df15e0..99577bb73f850d9d904e7295388899e88c503265 100644 (file)
@@ -1662,9 +1662,10 @@ int m68328_console_setup(struct console *cp, char *arg)
 }
 
 
-static kdev_t m68328_console_device(struct console *c)
+static struct tty_driver *m68328_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 
index 892e0cdc4942b96bea04f4c48c2dc7a792518293..bb5cfd74db8bf79382f56a4ba559792944257593 100644 (file)
@@ -2521,9 +2521,10 @@ void kgdb_map_scc(void)
 }
 #endif
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_struct *serial_console_device(struct console *c, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 
index 7359f3f71b14ee85db69c1ea90683ab5de7b9f4b..0d8c7601af30356b02316a86a304d483690021d1 100644 (file)
@@ -2187,17 +2187,19 @@ int uart_register_driver(struct uart_driver *drv)
  */
 void uart_unregister_driver(struct uart_driver *drv)
 {
-       tty_unregister_driver(drv->tty_driver);
-
+       struct tty_driver *p = drv->tty_driver;
+       drv->tty_driver = NULL;
+       tty_unregister_driver(p);
        kfree(drv->state);
        kfree(drv->tty_driver->termios);
        kfree(drv->tty_driver);
 }
 
-kdev_t uart_console_device(struct console *co)
+struct tty_driver *uart_console_device(struct console *co, int *index)
 {
        struct uart_driver *p = co->data;
-       return mk_kdev(p->major, p->minor + co->index);
+       *index = co->index;
+       return p->tty_driver;
 }
 
 /**
index 120aec80864fa4190f987c1f11a367ab364752b1..088f71298eaee4c6c2b2e1280fdae1719b54f13d 100644 (file)
@@ -1785,9 +1785,10 @@ int mcfrs_console_setup(struct console *cp, char *arg)
 }
 
 
-static kdev_t mcfrs_console_device(struct console *c)
+static struct tty_driver *mcfrs_console_device(struct console *c, int *index)
 {
-       return mk_kdev(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &mcfrs_serial_driver;
 }
 
 
index dfbc68e7f93fbb087370d916a2de33f3345381b7..40501a59cfced5794332d02a0f4abb4099c062f7 100644 (file)
@@ -2109,9 +2109,10 @@ static void zs_console_write(struct console *co, const char *str,
        rs_fair_output();
 }
 
-static kdev_t zs_console_device(struct console *con)
+static struct tty_driver *zs_console_device(struct console *con, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + con->index);
+       *index = con->index;
+       return &serial_driver;
 }
 
 
index 7438b5b749da8628fe5c0afdb79cf34a682d240e..2f0dc74de41cbf33eaea601815f77a6e70bac617 100644 (file)
@@ -2121,9 +2121,10 @@ static void serial_console_write(struct console *co, const char *s,
        }
 }
 
-static kdev_t serial_console_device(struct console *c)
+static struct tty_driver *serial_console_device(struct console *c, int *index)
 {
-       return MKDEV(TTY_MAJOR, 64 + c->index);
+       *index = c->index;
+       return &serial_driver;
 }
 
 /*
index c681a9eec658ec47d19cfe3ef6353aff914348c8..0b599fef2b8941e07c713857f9756e39d213fc99 100644 (file)
@@ -97,7 +97,7 @@ struct console
        char    name[8];
        void    (*write)(struct console *, const char *, unsigned);
        int     (*read)(struct console *, const char *, unsigned);
-       kdev_t  (*device)(struct console *);
+       struct tty_driver *(*device)(struct console *, int *);
        void    (*unblank)(void);
        int     (*setup)(struct console *, char *);
        short   flags;
index d3963ee21876edf742fb4f562c9b9599a22fb72e..8ac09f62af56c55abcaaf0270652652da0670062 100644 (file)
@@ -300,7 +300,7 @@ void uart_parse_options(char *options, int *baud, int *parity, int *bits,
                        int *flow);
 int uart_set_options(struct uart_port *port, struct console *co, int baud,
                     int parity, int bits, int flow);
-kdev_t uart_console_device(struct console *co);
+struct tty_driver *uart_console_device(struct console *co, int *index);
 
 /*
  * Port/driver registration/removal