if (!retinfo)
                return -EFAULT;
        memset(&tmp, 0, sizeof(tmp));
-       lock_kernel();
+       tty_lock();
        tmp.type = state->type;
        tmp.line = state->line;
        tmp.port = state->port;
        tmp.close_delay = state->close_delay;
        tmp.closing_wait = state->closing_wait;
        tmp.custom_divisor = state->custom_divisor;
-       unlock_kernel();
+       tty_unlock();
        if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
                return -EFAULT;
        return 0;
        if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
                return -EFAULT;
 
-       lock_kernel();
+       tty_lock();
        state = info->state;
        old_state = *state;
   
        change_irq = new_serial.irq != state->irq;
        change_port = (new_serial.port != state->port);
        if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) {
-         unlock_kernel();
+         tty_unlock();
          return -EINVAL;
        }
   
        }
 
        if (new_serial.baud_base < 9600) {
-               unlock_kernel();
+               tty_unlock();
                return -EINVAL;
        }
 
                }
        } else
                retval = startup(info);
-       unlock_kernel();
+       tty_unlock();
        return retval;
 }
 
 
        orig_jiffies = jiffies;
 
-       lock_kernel();
+       tty_lock_nested(); /* tty_wait_until_sent is called from lots of places */
        /*
         * Set the check interval to be 1/5 of the estimated time to
         * send a single character, and make it at least 1.  The check
                        break;
        }
        __set_current_state(TASK_RUNNING);
-       unlock_kernel();
+       tty_unlock();
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
        printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
 #endif
 
 
 static int briq_panel_open(struct inode *ino, struct file *filep)
 {
-       lock_kernel();
+       tty_lock();
        /* enforce single access, vfd_is_open is protected by BKL */
        if (vfd_is_open) {
-               unlock_kernel();
+               tty_unlock();
                return -EBUSY;
        }
        vfd_is_open = 1;
 
-       unlock_kernel();
+       tty_unlock();
        return 0;
 }
 
 
                return -EFAULT;
        }
 
-       lock_kernel();
+       tty_lock();
 
        for (;;) {
                if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
-                       unlock_kernel();
+                       tty_unlock();
                        return -EIO;
                }
 
                n_hdlc = tty2n_hdlc (tty);
                if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
                         tty != n_hdlc->tty) {
-                       unlock_kernel();
+                       tty_unlock();
                        return 0;
                }
 
                        
                /* no data */
                if (file->f_flags & O_NONBLOCK) {
-                       unlock_kernel();
+                       tty_unlock();
                        return -EAGAIN;
                }
                        
                interruptible_sleep_on (&tty->read_wait);
                if (signal_pending(current)) {
-                       unlock_kernel();
+                       tty_unlock();
                        return -EINTR;
                }
        }
                kfree(rbuf);
        else    
                n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
-       unlock_kernel();
+       tty_unlock();
        return ret;
        
 }      /* end of n_hdlc_tty_read() */
                count = maxframe;
        }
        
-       lock_kernel();
+       tty_lock();
 
        add_wait_queue(&tty->write_wait, &wait);
        set_current_state(TASK_INTERRUPTIBLE);
                n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
                n_hdlc_send_frames(n_hdlc,tty);
        }
-       unlock_kernel();
+       tty_unlock();
        return error;
        
 }      /* end of n_hdlc_tty_write() */
 
 
        TRACE_L("read()");
 
-       lock_kernel();
+       tty_lock();
 
        pClient = findClient(pInfo, task_pid(current));
        if (pClient) {
        }
        ret = -EPERM;
 unlock:
-       unlock_kernel();
+       tty_unlock();
        return ret;
 }
 
        pHeader->locks = 0;
        pHeader->owner = NULL;
 
-       lock_kernel();
+       tty_lock();
 
        pClient = findClient(pInfo, task_pid(current));
        if (pClient) {
        add_tx_queue(pInfo, pHeader);
        trigger_transmit(pInfo);
 
-       unlock_kernel();
+       tty_unlock();
 
        return 0;
 }
 
 {
        int ret;
 
-       lock_kernel();
+       tty_lock();
        ret = __ptmx_open(inode, filp);
-       unlock_kernel();
+       tty_unlock();
        return ret;
 }
 
 
        struct  tty_ldisc *ld;
        DECLARE_WAITQUEUE(wait, current);
 
-       lock_kernel();
+       tty_lock_nested(); /* always called with BTM from vt_ioctl */
 
        acquire_console_sem();
        poke_blanked_console();
        __set_current_state(TASK_RUNNING);
 
        tty_ldisc_deref(ld);
-       unlock_kernel();
+       tty_unlock();
        return 0;
 }
 
        printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg);       /* */
 #endif
 
-       lock_kernel();
+       tty_lock();
 
        switch (cmd) {
        case CYGETMON:
        default:
                ret_val = -ENOIOCTLCMD;
        }
-       unlock_kernel();
+       tty_unlock();
 
 #ifdef SERIAL_DEBUG_OTHER
        printk("cy_ioctl done\n");
 
        if (!capable(CAP_SYS_RAWIO))
                return -EPERM;
 
-       lock_kernel();
+       tty_lock();
 
        sx_dprintk(SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg);
 
                break;
        }
 out:
-       unlock_kernel();
+       tty_unlock();
        func_exit();
        return rc;
 }
        int rv;
 
        func_enter();
-       lock_kernel();
+       tty_lock();
 
        if (flag)
                rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK);
        if (rv != 1)
                printk(KERN_ERR "sx: couldn't send break (%x).\n",
                        read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat)));
-       unlock_kernel();
+       tty_unlock();
        func_exit();
        return 0;
 }
        /* func_enter2(); */
 
        rc = 0;
-       lock_kernel();
+       tty_lock();
        switch (cmd) {
        case TIOCGSERIAL:
                rc = gs_getserial(&port->gs, argp);
                rc = -ENOIOCTLCMD;
                break;
        }
-       unlock_kernel();
+       tty_unlock();
 
        /* func_exit(); */
        return rc;
 
 #else
 #define tty_compat_ioctl NULL
 #endif
+static int __tty_fasync(int fd, struct file *filp, int on);
 static int tty_fasync(int fd, struct file *filp, int on);
 static void release_tty(struct tty_struct *tty, int idx);
 static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
  *     remains intact.
  *
  *     Locking:
- *             BKL
+ *             BTM
  *               redirect lock for undoing redirection
  *               file list lock for manipulating list of ttys
  *               tty_ldisc_lock from called functions
        }
        spin_unlock(&redirect_lock);
 
-       /* inuse_filps is protected by the single kernel lock */
-       lock_kernel();
+       /* inuse_filps is protected by the single tty lock,
+          this really needs to change if we want to flush the
+          workqueue with the lock held */
+       tty_lock_nested(); /* called with BTM held from pty_close and
+                               others */
        check_tty_count(tty, "do_tty_hangup");
 
        file_list_lock();
                if (filp->f_op->write != tty_write)
                        continue;
                closecount++;
-               tty_fasync(-1, filp, 0);        /* can't block */
+               __tty_fasync(-1, filp, 0);      /* can't block */
                filp->f_op = &hung_up_tty_fops;
        }
        file_list_unlock();
         */
        set_bit(TTY_HUPPED, &tty->flags);
        tty_ldisc_enable(tty);
-       unlock_kernel();
+       tty_unlock();
        if (f)
                fput(f);
 }
  *     exiting; it is 0 if called by the ioctl TIOCNOTTY.
  *
  *     Locking:
- *             BKL is taken for hysterical raisins
+ *             BTM is taken for hysterical raisins, and held when
+ *               called from no_tty().
  *               tty_mutex is taken to protect tty
  *               ->siglock is taken to protect ->signal/->sighand
  *               tasklist_lock is taken to walk process list for sessions
        tty = get_current_tty();
        if (tty) {
                tty_pgrp = get_pid(tty->pgrp);
-               lock_kernel();
+               tty_lock_nested(); /* see above */
                if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
                        tty_vhangup(tty);
-               unlock_kernel();
+               tty_unlock();
                tty_kref_put(tty);
        } else if (on_exit) {
                struct pid *old_pgrp;
 void no_tty(void)
 {
        struct task_struct *tsk = current;
-       lock_kernel();
+       tty_lock();
        disassociate_ctty(0);
-       unlock_kernel();
+       tty_unlock();
        proc_clear_tty(tsk);
 }
 
  * We don't put it into the syslog queue right now maybe in the future if
  * really needed.
  *
- * We must still hold the BKL and test the CLOSING flag for the moment.
+ * We must still hold the BTM and test the CLOSING flag for the moment.
  */
 
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
        if (tty) {
                mutex_lock(&tty->atomic_write_lock);
-               lock_kernel();
+               tty_lock();
                if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
-                       unlock_kernel();
+                       tty_unlock();
                        tty->ops->write(tty, msg, strlen(msg));
                } else
-                       unlock_kernel();
+                       tty_unlock();
                tty_write_unlock(tty);
        }
        return;
        int ret;
 
        if (driver->ops->install) {
-               lock_kernel();
+               tty_lock_nested(); /* already called with BTM held */
                ret = driver->ops->install(driver, tty);
-               unlock_kernel();
+               tty_unlock();
                return ret;
        }
 
        if (tty_init_termios(tty) == 0) {
-               lock_kernel();
+               tty_lock_nested();
                tty_driver_kref_get(driver);
                tty->count++;
                driver->ttys[idx] = tty;
-               unlock_kernel();
+               tty_unlock();
                return 0;
        }
        return -ENOMEM;
        struct tty_struct *tty;
        int retval;
 
-       lock_kernel();
+       tty_lock_nested(); /* always called with tty lock held already */
+
        /* Check if pty master is being opened multiple times */
        if (driver->subtype == PTY_TYPE_MASTER &&
                (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) {
-               unlock_kernel();
+               tty_unlock();
                return ERR_PTR(-EIO);
        }
-       unlock_kernel();
+       tty_unlock();
 
        /*
         * First time open is complex, especially for PTY devices.
        if (printk_ratelimit())
                printk(KERN_INFO "tty_init_dev: ldisc open failed, "
                                 "clearing slot %d\n", idx);
-       lock_kernel();
+       tty_lock_nested();
        release_tty(tty, idx);
-       unlock_kernel();
+       tty_unlock();
        return ERR_PTR(retval);
 }
 
        if (tty_paranoia_check(tty, inode, "tty_release_dev"))
                return 0;
 
-       lock_kernel();
+       tty_lock();
        check_tty_count(tty, "tty_release_dev");
 
-       tty_fasync(-1, filp, 0);
+       __tty_fasync(-1, filp, 0);
 
        idx = tty->index;
        pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
        if (idx < 0 || idx >= tty->driver->num) {
                printk(KERN_DEBUG "tty_release_dev: bad idx when trying to "
                                  "free (%s)\n", tty->name);
-               unlock_kernel();
+               tty_unlock();
                return 0;
        }
        if (!devpts) {
                if (tty != tty->driver->ttys[idx]) {
-                       unlock_kernel();
+                       tty_unlock();
                        printk(KERN_DEBUG "tty_release_dev: driver.table[%d] not tty "
                               "for (%s)\n", idx, tty->name);
                        return 0;
                }
                if (tty->termios != tty->driver->termios[idx]) {
-                       unlock_kernel();
+                       tty_unlock();
                        printk(KERN_DEBUG "tty_release_dev: driver.termios[%d] not termios "
                               "for (%s)\n",
                               idx, tty->name);
        if (tty->driver->other &&
             !(tty->driver->flags & TTY_DRIVER_DEVPTS_MEM)) {
                if (o_tty != tty->driver->other->ttys[idx]) {
-                       unlock_kernel();
+                       tty_unlock();
                        printk(KERN_DEBUG "tty_release_dev: other->table[%d] "
                                          "not o_tty for (%s)\n",
                               idx, tty->name);
                        return 0 ;
                }
                if (o_tty->termios != tty->driver->other->termios[idx]) {
-                       unlock_kernel();
+                       tty_unlock();
                        printk(KERN_DEBUG "tty_release_dev: other->termios[%d] "
                                          "not o_termios for (%s)\n",
                               idx, tty->name);
                        return 0;
                }
                if (o_tty->link != tty) {
-                       unlock_kernel();
+                       tty_unlock();
                        printk(KERN_DEBUG "tty_release_dev: bad pty pointers\n");
                        return 0;
                }
        if (tty->ops->close)
                tty->ops->close(tty, filp);
 
-       unlock_kernel();
+       tty_unlock();
        /*
         * Sanity check: if tty->count is going to zero, there shouldn't be
         * any waiters on tty->read_wait or tty->write_wait.  We test the
                   opens on /dev/tty */
 
                mutex_lock(&tty_mutex);
-               lock_kernel();
+               tty_lock();
                tty_closing = tty->count <= 1;
                o_tty_closing = o_tty &&
                        (o_tty->count <= (pty_master ? 1 : 0));
 
                printk(KERN_WARNING "tty_release_dev: %s: read/write wait queue "
                                    "active!\n", tty_name(tty, buf));
-               unlock_kernel();
+               tty_unlock();
                mutex_unlock(&tty_mutex);
                schedule();
        }
 
        /* check whether both sides are closing ... */
        if (!tty_closing || (o_tty && !o_tty_closing)) {
-               unlock_kernel();
+               tty_unlock();
                return 0;
        }
 
        /* Make this pty number available for reallocation */
        if (devpts)
                devpts_kill_index(inode, idx);
-       unlock_kernel();
+       tty_unlock();
        return 0;
 }
 
        retval = 0;
 
        mutex_lock(&tty_mutex);
-       lock_kernel();
+       tty_lock();
 
        if (device == MKDEV(TTYAUX_MAJOR, 0)) {
                tty = get_current_tty();
                if (!tty) {
-                       unlock_kernel();
+                       tty_unlock();
                        mutex_unlock(&tty_mutex);
                        return -ENXIO;
                }
                                goto got_driver;
                        }
                }
-               unlock_kernel();
+               tty_unlock();
                mutex_unlock(&tty_mutex);
                return -ENODEV;
        }
 
        driver = get_tty_driver(device, &index);
        if (!driver) {
-               unlock_kernel();
+               tty_unlock();
                mutex_unlock(&tty_mutex);
                return -ENODEV;
        }
                tty = tty_driver_lookup_tty(driver, inode, index);
 
                if (IS_ERR(tty)) {
-                       unlock_kernel();
+                       tty_unlock();
                        mutex_unlock(&tty_mutex);
                        return PTR_ERR(tty);
                }
        mutex_unlock(&tty_mutex);
        tty_driver_kref_put(driver);
        if (IS_ERR(tty)) {
-               unlock_kernel();
+               tty_unlock();
                return PTR_ERR(tty);
        }
 
 #endif
                tty_release(inode, filp);
                if (retval != -ERESTARTSYS) {
-                       unlock_kernel();
+                       tty_unlock();
                        return retval;
                }
                if (signal_pending(current)) {
-                       unlock_kernel();
+                       tty_unlock();
                        return retval;
                }
                schedule();
                 */
                if (filp->f_op == &hung_up_tty_fops)
                        filp->f_op = &tty_fops;
-               unlock_kernel();
+               tty_unlock();
                goto retry_open;
        }
-       unlock_kernel();
+       tty_unlock();
 
 
        mutex_lock(&tty_mutex);
-       lock_kernel();
+       tty_lock();
        spin_lock_irq(¤t->sighand->siglock);
        if (!noctty &&
            current->signal->leader &&
            tty->session == NULL)
                __proc_set_tty(current, tty);
        spin_unlock_irq(¤t->sighand->siglock);
-       unlock_kernel();
+       tty_unlock();
        mutex_unlock(&tty_mutex);
        return 0;
 }
        return ret;
 }
 
-static int tty_fasync(int fd, struct file *filp, int on)
+static int __tty_fasync(int fd, struct file *filp, int on)
 {
        struct tty_struct *tty;
        unsigned long flags;
        int retval = 0;
 
-       lock_kernel();
        tty = (struct tty_struct *)filp->private_data;
        if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync"))
                goto out;
        }
        retval = 0;
 out:
-       unlock_kernel();
+       return retval;
+}
+
+static int tty_fasync(int fd, struct file *filp, int on)
+{
+       int retval;
+       tty_lock();
+       retval = __tty_fasync(fd, filp, on);
+       tty_unlock();
        return retval;
 }
 
 
  *
  *     A helper opening method. Also a convenient debugging and check
  *     point.
+ *
+ *     Locking: always called with BTM already held.
  */
 
 static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld)
        WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, &tty->flags));
        if (ld->ops->open) {
                int ret;
-                /* BKL here locks verus a hangup event */
-               lock_kernel();
+                /* BTM here locks versus a hangup event */
+               tty_lock_nested(); /* always held here already */
                ret = ld->ops->open(tty);
-               unlock_kernel();
+               tty_unlock();
                return ret;
        }
        return 0;
        if (IS_ERR(new_ldisc))
                return PTR_ERR(new_ldisc);
 
-       lock_kernel();
+       tty_lock();
        /*
         *      We need to look at the tty locking here for pty/tty pairs
         *      when both sides try to change in parallel.
         */
 
        if (tty->ldisc->ops->num == ldisc) {
-               unlock_kernel();
+               tty_unlock();
                tty_ldisc_put(new_ldisc);
                return 0;
        }
 
-       unlock_kernel();
+       tty_unlock();
        /*
         *      Problem: What do we do if this blocks ?
         *      We could deadlock here
                mutex_lock(&tty->ldisc_mutex);
        }
 
-       lock_kernel();
+       tty_lock();
 
        set_bit(TTY_LDISC_CHANGING, &tty->flags);
 
 
        o_ldisc = tty->ldisc;
 
-       unlock_kernel();
+       tty_unlock();
        /*
         *      Make sure we don't change while someone holds a
         *      reference to the line discipline. The TTY_LDISC bit
        flush_scheduled_work();
 
        mutex_lock(&tty->ldisc_mutex);
-       lock_kernel();
+       tty_lock();
        if (test_bit(TTY_HUPPED, &tty->flags)) {
                /* We were raced by the hangup method. It will have stomped
                   the ldisc data and closed the ldisc down */
                clear_bit(TTY_LDISC_CHANGING, &tty->flags);
                mutex_unlock(&tty->ldisc_mutex);
                tty_ldisc_put(new_ldisc);
-               unlock_kernel();
+               tty_unlock();
                return -EIO;
        }
 
        if (o_work)
                schedule_delayed_work(&o_tty->buf.work, 1);
        mutex_unlock(&tty->ldisc_mutex);
-       unlock_kernel();
+       tty_unlock();
        return retval;
 }
 
 
        unsigned int currcons = iminor(inode) & 127;
        int ret = 0;
        
-       lock_kernel();
+       tty_lock();
        if(currcons && !vc_cons_allocated(currcons-1))
                ret = -ENXIO;
-       unlock_kernel();
+       tty_unlock();
        return ret;
 }
 
 
 
        console = vc->vc_num;
 
-       lock_kernel();
+       tty_lock();
 
        if (!vc_cons_allocated(console)) {      /* impossible? */
                ret = -ENOIOCTLCMD;
                ret = -ENOIOCTLCMD;
        }
 out:
-       unlock_kernel();
+       tty_unlock();
        return ret;
 eperm:
        ret = -EPERM;
 
        console = vc->vc_num;
 
-       lock_kernel();
+       tty_lock();
 
        if (!vc_cons_allocated(console)) {      /* impossible? */
                ret = -ENOIOCTLCMD;
                goto fallback;
        }
 out:
-       unlock_kernel();
+       tty_unlock();
        return ret;
 
 fallback:
-       unlock_kernel();
+       tty_unlock();
        return vt_ioctl(tty, file, cmd, arg);
 }
 
 
        printk("jiff=%lu...", jiffies);
 #endif
 
-       lock_kernel();
+       tty_lock_nested(); /* always held already since we come from ->close */
        /* We go through the loop at least once because we can't tell
         * exactly when the last character exits the shifter.  There can
         * be at least two characters waiting to be sent after the buffers
                        bdp--;
        } while (bdp->status & BD_SC_READY);
        current->state = TASK_RUNNING;
-       unlock_kernel();
+       tty_unlock();
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
        printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
 #endif
 
         * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
         * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
         */
-       lock_kernel();
+       tty_lock_nested(); /* locked already when coming from close */
        orig_jiffies = jiffies;
        while (info->xmit.head != info->xmit.tail || /* More in send queue */
               (*info->ostatusadr & 0x007f) ||  /* more in FIFO */
                        curr_time_usec - info->last_tx_active_usec;
        }
        set_current_state(TASK_RUNNING);
-       unlock_kernel();
+       tty_unlock();
 }
 
 /*
 
        struct uart_port *uport;
        unsigned long flags;
 
-       BUG_ON(!kernel_locked());
+       BUG_ON(!tty_locked());
 
        if (!state)
                return;
        if (port->type == PORT_UNKNOWN || port->fifosize == 0)
                return;
 
-       lock_kernel();
+       tty_lock_nested(); /* already locked when coming from close */
 
        /*
         * Set the check interval to be 1/5 of the estimated time to
                        break;
        }
        set_current_state(TASK_RUNNING); /* might not be needed */
-       unlock_kernel();
+       tty_unlock();
 }
 
 /*
        struct tty_port *port = &state->port;
        unsigned long flags;
 
-       BUG_ON(!kernel_locked());
+       BUG_ON(!tty_locked());
        pr_debug("uart_hangup(%d)\n", state->uart_port->line);
 
        mutex_lock(&port->mutex);
        struct tty_port *port;
        int retval, line = tty->index;
 
-       BUG_ON(!kernel_locked());
+       BUG_ON(!tty_locked());
        pr_debug("uart_open(%d) called\n", line);
 
        /*
 
                charmap += 4 * cmapsz;
 #endif
 
-       unlock_kernel();
+       tty_unlock();
        spin_lock_irq(&vga_lock);
        /* First, the Sequencer */
        vga_wseq(state->vgabase, VGA_SEQ_RESET, 0x1);
                vga_wattr(state->vgabase, VGA_AR_ENABLE_DISPLAY, 0);    
        }
        spin_unlock_irq(&vga_lock);
-       lock_kernel();
+       tty_lock();
        return 0;
 }
 
 
 #include <linux/tty_driver.h>
 #include <linux/tty_ldisc.h>
 #include <linux/mutex.h>
+#include <linux/smp_lock.h>
 
 #include <asm/system.h>
 
 extern long vt_compat_ioctl(struct tty_struct *tty, struct file * file,
                     unsigned int cmd, unsigned long arg);
 
+/* functions for preparation of BKL removal */
+
+/*
+ * tty_lock_nested get the tty_lock while potentially holding it
+ *
+ * The Big TTY Mutex is a recursive lock, meaning you can take it
+ * from a thread that is already holding it.
+ * This is bad for a number of reasons, so tty_lock_nested should
+ * really be used as rarely as possible. If a code location can
+ * be shown to never get called with this held already, it should
+ * use tty_lock() instead.
+ */
+static inline void __lockfunc tty_lock_nested(void) __acquires(kernel_lock)
+{
+       lock_kernel();
+}
+static inline void tty_lock(void) __acquires(kernel_lock)
+{
+#ifdef CONFIG_LOCK_KERNEL
+       /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
+       WARN_ON(kernel_locked());
+#endif
+       lock_kernel();
+}
+static inline void tty_unlock(void) __releases(kernel_lock)
+{
+       unlock_kernel();
+}
+#define tty_locked()           (kernel_locked())
+
 #endif /* __KERNEL__ */
 #endif