Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
tty_ldisc.c File Reference
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kmod.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/file.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/wait.h>
#include <linux/bitops.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <linux/ratelimit.h>

Go to the source code of this file.

Functions

int tty_register_ldisc (int disc, struct tty_ldisc_ops *new_ldisc)
 
 EXPORT_SYMBOL (tty_register_ldisc)
 
int tty_unregister_ldisc (int disc)
 
 EXPORT_SYMBOL (tty_unregister_ldisc)
 
struct tty_ldisctty_ldisc_ref_wait (struct tty_struct *tty)
 
 EXPORT_SYMBOL_GPL (tty_ldisc_ref_wait)
 
struct tty_ldisctty_ldisc_ref (struct tty_struct *tty)
 
 EXPORT_SYMBOL_GPL (tty_ldisc_ref)
 
void tty_ldisc_deref (struct tty_ldisc *ld)
 
 EXPORT_SYMBOL_GPL (tty_ldisc_deref)
 
void tty_ldisc_enable (struct tty_struct *tty)
 
void tty_ldisc_flush (struct tty_struct *tty)
 
 EXPORT_SYMBOL_GPL (tty_ldisc_flush)
 
int tty_set_ldisc (struct tty_struct *tty, int ldisc)
 
void tty_ldisc_hangup (struct tty_struct *tty)
 
int tty_ldisc_setup (struct tty_struct *tty, struct tty_struct *o_tty)
 
void tty_ldisc_release (struct tty_struct *tty, struct tty_struct *o_tty)
 
void tty_ldisc_init (struct tty_struct *tty)
 
void tty_ldisc_deinit (struct tty_struct *tty)
 
void tty_ldisc_begin (void)
 

Variables

struct file_operations tty_ldiscs_proc_fops
 

Function Documentation

EXPORT_SYMBOL ( tty_register_ldisc  )
EXPORT_SYMBOL ( tty_unregister_ldisc  )
EXPORT_SYMBOL_GPL ( tty_ldisc_ref_wait  )
EXPORT_SYMBOL_GPL ( tty_ldisc_ref  )
EXPORT_SYMBOL_GPL ( tty_ldisc_deref  )
EXPORT_SYMBOL_GPL ( tty_ldisc_flush  )
void tty_ldisc_begin ( void  )

Definition at line 980 of file tty_ldisc.c.

void tty_ldisc_deinit ( struct tty_struct tty)

tty_ldisc_init - ldisc cleanup for new tty : tty that was allocated recently

The tty structure must not becompletely set up (tty_ldisc_setup) when this call is made.

Definition at line 974 of file tty_ldisc.c.

void tty_ldisc_deref ( struct tty_ldisc ld)

tty_ldisc_deref - free a tty ldisc reference : reference to free up

Undoes the effect of tty_ldisc_ref or tty_ldisc_ref_wait. May be called in IRQ context.

Locking: takes tty_ldisc_lock

Definition at line 351 of file tty_ldisc.c.

void tty_ldisc_enable ( struct tty_struct tty)

tty_ldisc_enable - allow ldisc use : terminal to activate ldisc on

Set the TTY_LDISC flag when the line discipline can be called again. Do necessary wakeups for existing sleepers. Clear the LDISC changing flag to indicate any ldisc change is now over.

Note: nobody should set the TTY_LDISC bit except via this function. Clearing directly is allowed.

Definition at line 374 of file tty_ldisc.c.

void tty_ldisc_flush ( struct tty_struct tty)

tty_ldisc_flush - flush line discipline queue : tty

Flush the line discipline queue (if any) for this tty. If there is no line discipline active this is a no-op.

Definition at line 389 of file tty_ldisc.c.

void tty_ldisc_hangup ( struct tty_struct tty)

tty_ldisc_hangup - hangup ldisc reset : tty being hung up

Some tty devices reset their termios when they receive a hangup event. In that situation we must also switch back to N_TTY properly before we reset the termios data.

Locking: We can take the ldisc mutex as the rest of the code is careful to allow for this.

In the pty pair case this occurs in the close() path of the tty itself so we must be careful about locking rules.

Definition at line 775 of file tty_ldisc.c.

void tty_ldisc_init ( struct tty_struct tty)

tty_ldisc_init - ldisc setup for new tty : tty being allocated

Set up the line discipline objects for a newly allocated tty. Note that the tty structure is not completely set up when this call is made.

Definition at line 959 of file tty_ldisc.c.

struct tty_ldisc* tty_ldisc_ref ( struct tty_struct tty)
read

tty_ldisc_ref - get the tty ldisc : tty device

Dereference the line discipline for the terminal and take a reference to it. If the line discipline is in flux then return NULL. Can be called from IRQ and timer functions.

Locking: called functions take tty_ldisc_lock

Definition at line 335 of file tty_ldisc.c.

struct tty_ldisc* tty_ldisc_ref_wait ( struct tty_struct tty)
read

tty_ldisc_ref_wait - wait for the tty ldisc : tty device

Dereference the line discipline for the terminal and take a reference to it. If the line discipline is in flux then wait patiently until it changes.

Note: Must not be called from an IRQ/timer context. The caller must also be careful not to hold other locks that will deadlock against a discipline change, such as an existing ldisc reference (which we check for)

Locking: call functions take tty_ldisc_lock

Definition at line 314 of file tty_ldisc.c.

void tty_ldisc_release ( struct tty_struct tty,
struct tty_struct o_tty 
)

tty_ldisc_release - release line discipline : tty being shut down : pair tty for pty/tty pairs

Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened.

Definition at line 924 of file tty_ldisc.c.

int tty_ldisc_setup ( struct tty_struct tty,
struct tty_struct o_tty 
)

tty_ldisc_setup - open line discipline : tty being shut down : pair tty for pty/tty pairs

Called during the initial open of a tty/pty pair in order to set up the line disciplines and bind them to the tty. This has no locking issues as the device isn't yet active.

Definition at line 877 of file tty_ldisc.c.

int tty_register_ldisc ( int  disc,
struct tty_ldisc_ops new_ldisc 
)

tty_register_ldisc - install a line discipline : ldisc number : pointer to the ldisc object

Installs a new line discipline into the kernel. The discipline is set up as unreferenced and then made available to the kernel from this point onwards.

Locking: takes tty_ldisc_lock to guard against ldisc races

Definition at line 83 of file tty_ldisc.c.

int tty_set_ldisc ( struct tty_struct tty,
int  ldisc 
)

tty_set_ldisc - set line discipline : the terminal to set : the line discipline

Set the discipline of a tty line. Must be called from a process context. The ldisc change logic has to protect itself against any overlapping ldisc change (including on the other end of pty pairs), the close of one side of a tty/pty pair, and eventually hangup.

Locking: takes tty_ldisc_lock, termios_mutex

Definition at line 560 of file tty_ldisc.c.

int tty_unregister_ldisc ( int  disc)

tty_unregister_ldisc - unload a line discipline : ldisc number : pointer to the ldisc object

Remove a line discipline from the kernel providing it is not currently in use.

Locking: takes tty_ldisc_lock to guard against ldisc races

Definition at line 113 of file tty_ldisc.c.

Variable Documentation

struct file_operations tty_ldiscs_proc_fops
Initial value:
= {
.owner = THIS_MODULE,
.open = proc_tty_ldiscs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
}

Definition at line 247 of file tty_ldisc.c.