Exemplo n.º 1
0
static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
{
    int i = *(loff_t *)v;
    struct tty_ldisc_ops *ldops;

    ldops = get_ldops(i);
    if (IS_ERR(ldops))
        return 0;
    seq_printf(m, "%-10s %2d\n", ldops->name ? ldops->name : "???", i);
    put_ldops(ldops);
    return 0;
}
Exemplo n.º 2
0
/**
 *	tty_ldisc_get	-	Take a reference of a line discipine
 *	@tty: the tty in move
 *	@disc: disc number
 *
 *	Takes a reference of a line discipline op, deals with refcount.
 *	Returns %NULL if line discipline op is not available. Return the
 *	pointer to the tty_ldisc if succeed, and increases the refcount
 *	of the line discipline op.
 */
static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
{
	struct tty_ldisc *ld;
	struct tty_ldisc_ops *ldops;

	if (disc < N_TTY || disc >= NR_LDISCS)
		return ERR_PTR(-EINVAL);

	ldops = get_ldops(disc);
	if (IS_ERR(ldops))
		return ERR_CAST(ldops);

	ld = kmalloc(sizeof(struct tty_ldisc), 1);
	if (!ld) {
		put_ldops(ldops);
		return ERR_PTR(-ENOMEM);
	}

	ld->ops = ldops;
	ld->tty = tty;

	return ld;
}