tty: The big operations rework
- Operations are now a shared const function block as with most other Linux objects - Introduce wrappers for some optional functions to get consistent behaviour - Wrap put_char which used to be patched by the tty layer - Document which functions are needed/optional - Make put_char report success/fail - Cache the driver->ops pointer in the tty as tty->ops - Remove various surplus lock calls we no longer need - Remove proc_write method as noted by Alexey Dobriyan - Introduce some missing sanity checks where certain driver/ldisc combinations would oops as they didn't check needed methods were present [akpm@linux-foundation.org: fix fs/compat_ioctl.c build] [akpm@linux-foundation.org: fix isicom] [akpm@linux-foundation.org: fix arch/ia64/hp/sim/simserial.c build] [akpm@linux-foundation.org: fix kgdb] Signed-off-by: Alan Cox <alan@redhat.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Cc: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -516,7 +516,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
|
||||
spin_unlock_bh(&ax->buflock);
|
||||
|
||||
set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
|
||||
actual = ax->tty->driver->write(ax->tty, ax->xbuff, count);
|
||||
actual = ax->tty->ops->write(ax->tty, ax->xbuff, count);
|
||||
ax->stats.tx_packets++;
|
||||
ax->stats.tx_bytes += actual;
|
||||
|
||||
@@ -546,7 +546,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
}
|
||||
|
||||
printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name,
|
||||
(ax->tty->driver->chars_in_buffer(ax->tty) || ax->xleft) ?
|
||||
(ax->tty->ops->chars_in_buffer(ax->tty) || ax->xleft) ?
|
||||
"bad line quality" : "driver error");
|
||||
|
||||
ax->xleft = 0;
|
||||
@@ -736,6 +736,8 @@ static int mkiss_open(struct tty_struct *tty)
|
||||
|
||||
if (!capable(CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
if (tty->ops->write == NULL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup);
|
||||
if (!dev) {
|
||||
@@ -754,8 +756,7 @@ static int mkiss_open(struct tty_struct *tty)
|
||||
tty->disc_data = ax;
|
||||
tty->receive_room = 65535;
|
||||
|
||||
if (tty->driver->flush_buffer)
|
||||
tty->driver->flush_buffer(tty);
|
||||
tty_driver_flush_buffer(tty);
|
||||
|
||||
/* Restore default settings */
|
||||
dev->type = ARPHRD_AX25;
|
||||
@@ -936,8 +937,8 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
|
||||
|
||||
mkiss_put(ax);
|
||||
if (test_and_clear_bit(TTY_THROTTLED, &tty->flags)
|
||||
&& tty->driver->unthrottle)
|
||||
tty->driver->unthrottle(tty);
|
||||
&& tty->ops->unthrottle)
|
||||
tty->ops->unthrottle(tty);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -962,7 +963,7 @@ static void mkiss_write_wakeup(struct tty_struct *tty)
|
||||
goto out;
|
||||
}
|
||||
|
||||
actual = tty->driver->write(tty, ax->xhead, ax->xleft);
|
||||
actual = tty->ops->write(tty, ax->xhead, ax->xleft);
|
||||
ax->xleft -= actual;
|
||||
ax->xhead += actual;
|
||||
|
||||
|
Reference in New Issue
Block a user