static struct tty_ldisc_ops spk_ttyio_ldisc_ops = {
        .owner          = THIS_MODULE,
+       .num            = N_SPEAKUP,
        .name           = "speakup_ldisc",
        .open           = spk_ttyio_ldisc_open,
        .close          = spk_ttyio_ldisc_close,
 
 void spk_ttyio_register_ldisc(void)
 {
-       if (tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops))
+       if (tty_register_ldisc(&spk_ttyio_ldisc_ops))
                pr_warn("speakup: Error registering line discipline. Most synths won't work.\n");
 }
 
 
 
 static struct tty_ldisc_ops hci_uart_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_HCI,
        .name           = "n_hci",
        .open           = hci_uart_tty_open,
        .close          = hci_uart_tty_close,
        BT_INFO("HCI UART driver ver %s", VERSION);
 
        /* Register the tty discipline */
-       err = tty_register_ldisc(N_HCI, &hci_uart_ldisc);
+       err = tty_register_ldisc(&hci_uart_ldisc);
        if (err) {
                BT_ERR("HCI line discipline registration failed. (%d)", err);
                return err;
 
 
 static struct tty_ldisc_ops serport_ldisc = {
        .owner =        THIS_MODULE,
+       .num =          N_MOUSE,
        .name =         "input",
        .open =         serport_ldisc_open,
        .close =        serport_ldisc_close,
 static int __init serport_init(void)
 {
        int retval;
-       retval = tty_register_ldisc(N_MOUSE, &serport_ldisc);
+       retval = tty_register_ldisc(&serport_ldisc);
        if (retval)
                printk(KERN_ERR "serport.c: Error registering line discipline.\n");
 
 
 }
 
 static struct tty_ldisc_ops st_ldisc_ops = {
+       .num = N_TI_WL,
        .name = "n_st",
        .open = st_tty_open,
        .close = st_tty_close,
        struct st_data_s *st_gdata;
        long err;
 
-       err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
+       err = tty_register_ldisc(&st_ldisc_ops);
        if (err) {
                pr_err("error registering %d line discipline %ld",
                           N_TI_WL, err);
 
 /* The line discipline structure. */
 static struct tty_ldisc_ops caif_ldisc = {
        .owner =        THIS_MODULE,
+       .num =          N_CAIF,
        .name =         "n_caif",
        .open =         ldisc_open,
        .close =        ldisc_close,
 {
        int ret;
 
-       ret = tty_register_ldisc(N_CAIF, &caif_ldisc);
+       ret = tty_register_ldisc(&caif_ldisc);
        if (ret < 0)
                pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF, ret);
 
 
 
 static struct tty_ldisc_ops slc_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_SLCAN,
        .name           = "slcan",
        .open           = slcan_open,
        .close          = slcan_close,
                return -ENOMEM;
 
        /* Fill in our line protocol discipline, and register it */
-       status = tty_register_ldisc(N_SLCAN, &slc_ldisc);
+       status = tty_register_ldisc(&slc_ldisc);
        if (status)  {
                printk(KERN_ERR "slcan: can't register line discipline\n");
                kfree(slcan_devs);
 
 
 static struct tty_ldisc_ops sp_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_6PACK,
        .name           = "6pack",
        .open           = sixpack_open,
        .close          = sixpack_close,
        printk(msg_banner);
 
        /* Register the provided line protocol discipline */
-       if ((status = tty_register_ldisc(N_6PACK, &sp_ldisc)) != 0)
+       status = tty_register_ldisc(&sp_ldisc);
+       if (status)
                printk(msg_regfail, status);
 
        return status;
 
 
 static struct tty_ldisc_ops ax_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_AX25,
        .name           = "mkiss",
        .open           = mkiss_open,
        .close          = mkiss_close,
 
        printk(banner);
 
-       status = tty_register_ldisc(N_AX25, &ax_ldisc);
+       status = tty_register_ldisc(&ax_ldisc);
        if (status != 0)
                printk(msg_regfail, status);
 
 
 
 static struct tty_ldisc_ops ppp_ldisc = {
        .owner  = THIS_MODULE,
+       .num    = N_PPP,
        .name   = "ppp",
        .open   = ppp_asynctty_open,
        .close  = ppp_asynctty_close,
 {
        int err;
 
-       err = tty_register_ldisc(N_PPP, &ppp_ldisc);
+       err = tty_register_ldisc(&ppp_ldisc);
        if (err != 0)
                printk(KERN_ERR "PPP_async: error %d registering line disc.\n",
                       err);
 
 
 static struct tty_ldisc_ops ppp_sync_ldisc = {
        .owner  = THIS_MODULE,
+       .num    = N_SYNC_PPP,
        .name   = "pppsync",
        .open   = ppp_sync_open,
        .close  = ppp_sync_close,
 {
        int err;
 
-       err = tty_register_ldisc(N_SYNC_PPP, &ppp_sync_ldisc);
+       err = tty_register_ldisc(&ppp_sync_ldisc);
        if (err != 0)
                printk(KERN_ERR "PPP_sync: error %d registering line disc.\n",
                       err);
 
 
 static struct tty_ldisc_ops sl_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_SLIP,
        .name           = "slip",
        .open           = slip_open,
        .close          = slip_close,
                return -ENOMEM;
 
        /* Fill in our line protocol discipline, and register it */
-       status = tty_register_ldisc(N_SLIP, &sl_ldisc);
+       status = tty_register_ldisc(&sl_ldisc);
        if (status != 0) {
                printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status);
                kfree(slip_devs);
 
 
        /* Init PPS_TTY data */
        pps_ldisc_ops.owner = THIS_MODULE;
+       pps_ldisc_ops.num = N_PPS;
        pps_ldisc_ops.name = "pps_tty";
        pps_ldisc_ops.dcd_change = pps_tty_dcd_change;
        pps_ldisc_ops.open = pps_tty_open;
        pps_ldisc_ops.close = pps_tty_close;
 
-       err = tty_register_ldisc(N_PPS, &pps_ldisc_ops);
+       err = tty_register_ldisc(&pps_ldisc_ops);
        if (err)
                pr_err("can't register PPS line discipline\n");
        else
 
 /* Line discipline for real tty */
 static struct tty_ldisc_ops tty_ldisc_packet = {
        .owner           = THIS_MODULE,
+       .num             = N_GSM0710,
        .name            = "n_gsm",
        .open            = gsmld_open,
        .close           = gsmld_close,
 static int __init gsm_init(void)
 {
        /* Fill in our line protocol discipline, and register it */
-       int status = tty_register_ldisc(N_GSM0710, &tty_ldisc_packet);
+       int status = tty_register_ldisc(&tty_ldisc_packet);
        if (status != 0) {
                pr_err("n_gsm: can't register line discipline (err = %d)\n",
                                                                status);
 
 
 static struct tty_ldisc_ops n_hdlc_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_HDLC,
        .name           = "hdlc",
        .open           = n_hdlc_tty_open,
        .close          = n_hdlc_tty_close,
        /* range check maxframe arg */
        maxframe = clamp(maxframe, 4096, MAX_HDLC_FRAME_SIZE);
 
-       status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
+       status = tty_register_ldisc(&n_hdlc_ldisc);
        if (!status)
                pr_info("N_HDLC line discipline registered with maxframe=%d\n",
                                maxframe);
 
 
 static struct tty_ldisc_ops null_ldisc = {
        .owner          =       THIS_MODULE,
+       .num            =       N_NULL,
        .name           =       "n_null",
        .open           =       n_null_open,
        .close          =       n_null_close,
 
 static int __init n_null_init(void)
 {
-       BUG_ON(tty_register_ldisc(N_NULL, &null_ldisc));
+       BUG_ON(tty_register_ldisc(&null_ldisc));
        return 0;
 }
 
 
 
 static struct tty_ldisc_ops n_tty_ops = {
        .owner           = THIS_MODULE,
+       .num             = N_TTY,
        .name            = "n_tty",
        .open            = n_tty_open,
        .close           = n_tty_close,
 
 void __init n_tty_init(void)
 {
-       tty_register_ldisc(N_TTY, &n_tty_ops);
+       tty_register_ldisc(&n_tty_ops);
 }
 
  *             takes tty_ldiscs_lock to guard against ldisc races
  */
 
-int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
+int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc)
 {
        unsigned long flags;
        int ret = 0;
 
-       if (disc < N_TTY || disc >= NR_LDISCS)
+       if (new_ldisc->num < N_TTY || new_ldisc->num >= NR_LDISCS)
                return -EINVAL;
 
        raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
-       tty_ldiscs[disc] = new_ldisc;
-       new_ldisc->num = disc;
+       tty_ldiscs[new_ldisc->num] = new_ldisc;
        new_ldisc->refcount = 0;
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
 
 
        return port->count + port->blocked_open;
 }
 
-extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
+extern int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc);
 extern int tty_unregister_ldisc(int disc);
 extern int tty_set_ldisc(struct tty_struct *tty, int disc);
 extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
 
 
 static struct tty_ldisc_ops nci_uart_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_NCI,
        .name           = "n_nci",
        .open           = nci_uart_tty_open,
        .close          = nci_uart_tty_close,
 
 static int __init nci_uart_init(void)
 {
-       return tty_register_ldisc(N_NCI, &nci_uart_ldisc);
+       return tty_register_ldisc(&nci_uart_ldisc);
 }
 
 static void __exit nci_uart_exit(void)
 
 
 static struct tty_ldisc_ops cx81801_ops = {
        .name = "cx81801",
+       .num = N_V253,
        .owner = THIS_MODULE,
        .open = cx81801_open,
        .close = cx81801_close,
        }
 
        /* Register optional line discipline for over the modem control */
-       ret = tty_register_ldisc(N_V253, &cx81801_ops);
+       ret = tty_register_ldisc(&cx81801_ops);
        if (ret) {
                dev_warn(card->dev,
                                "Failed to register line discipline, "