/* Locking: takes tty_ldisc_lock to guard against ldisc races  */
int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
/* Locking: takes tty_ldisc_lock to guard against ldisc races  */
int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
{
	unsigned long flags;
	int ret = 0;
	if (disc < N_TTY || disc >= NR_LDISCS)
		return -EINVAL;
	spin_lock_irqsave(&tty_ldisc_lock, flags);
	tty_ldiscs[disc] = new_ldisc;
	new_ldisc->num = disc;
	new_ldisc->refcount = 0;
	spin_unlock_irqrestore(&tty_ldisc_lock, flags);
	return ret;
}