Commit a352def2 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

tty: Ldisc revamp

Move the line disciplines towards a conventional ->ops arrangement.  For
the moment the actual 'tty_ldisc' struct in the tty is kept as part of
the tty struct but this can then be changed if it turns out that when it
all settles down we want to refcount ldiscs separately to the tty.

Pull the ldisc code out of /proc and put it with our ldisc code.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e1e5770b
...@@ -282,8 +282,8 @@ static int hci_uart_tty_open(struct tty_struct *tty) ...@@ -282,8 +282,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
/* FIXME: why is this needed. Note don't use ldisc_ref here as the /* FIXME: why is this needed. Note don't use ldisc_ref here as the
open path is before the ldisc is referencable */ open path is before the ldisc is referencable */
if (tty->ldisc.flush_buffer) if (tty->ldisc.ops->flush_buffer)
tty->ldisc.flush_buffer(tty); tty->ldisc.ops->flush_buffer(tty);
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
return 0; return 0;
...@@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty, ...@@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty,
static int __init hci_uart_init(void) static int __init hci_uart_init(void)
{ {
static struct tty_ldisc hci_uart_ldisc; static struct tty_ldisc_ops hci_uart_ldisc;
int err; int err;
BT_INFO("HCI UART driver ver %s", VERSION); BT_INFO("HCI UART driver ver %s", VERSION);
......
...@@ -5246,7 +5246,8 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, ...@@ -5246,7 +5246,8 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
HZ, info->idle_stats.recv_bytes, HZ, info->idle_stats.recv_bytes,
(cur_jifs - info->idle_stats.recv_idle)/ (cur_jifs - info->idle_stats.recv_idle)/
HZ, info->idle_stats.overruns, HZ, info->idle_stats.overruns,
(long)info->tty->ldisc.num); /* FIXME: double check locking */
(long)info->tty->ldisc.ops->num);
else else
size = sprintf(buf + len, "%3d %8lu %10lu %8lu " size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
"%10lu %8lu %9lu %6ld\n", "%10lu %8lu %9lu %6ld\n",
......
...@@ -2262,8 +2262,8 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file, ...@@ -2262,8 +2262,8 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file,
tty_wait_until_sent(tty, 0); tty_wait_until_sent(tty, 0);
} else { } else {
/* ldisc lock already held in ioctl */ /* ldisc lock already held in ioctl */
if (tty->ldisc.flush_buffer) if (tty->ldisc.ops->flush_buffer)
tty->ldisc.flush_buffer(tty); tty->ldisc.ops->flush_buffer(tty);
} }
unlock_kernel(); unlock_kernel();
/* Fall Thru */ /* Fall Thru */
......
...@@ -868,11 +868,11 @@ i2Input(i2ChanStrPtr pCh) ...@@ -868,11 +868,11 @@ i2Input(i2ChanStrPtr pCh)
amountToMove = count; amountToMove = count;
} }
// Move the first block // Move the first block
pCh->pTTY->ldisc.receive_buf( pCh->pTTY, pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY,
&(pCh->Ibuf[stripIndex]), NULL, amountToMove ); &(pCh->Ibuf[stripIndex]), NULL, amountToMove );
// If we needed to wrap, do the second data move // If we needed to wrap, do the second data move
if (count > amountToMove) { if (count > amountToMove) {
pCh->pTTY->ldisc.receive_buf( pCh->pTTY, pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY,
pCh->Ibuf, NULL, count - amountToMove ); pCh->Ibuf, NULL, count - amountToMove );
} }
// Bump and wrap the stripIndex all at once by the amount of data read. This // Bump and wrap the stripIndex all at once by the amount of data read. This
......
...@@ -1289,11 +1289,12 @@ static void do_input(struct work_struct *work) ...@@ -1289,11 +1289,12 @@ static void do_input(struct work_struct *work)
// code duplicated from n_tty (ldisc) // code duplicated from n_tty (ldisc)
static inline void isig(int sig, struct tty_struct *tty, int flush) static inline void isig(int sig, struct tty_struct *tty, int flush)
{ {
/* FIXME: This is completely bogus */
if (tty->pgrp) if (tty->pgrp)
kill_pgrp(tty->pgrp, sig, 1); kill_pgrp(tty->pgrp, sig, 1);
if (flush || !L_NOFLSH(tty)) { if (flush || !L_NOFLSH(tty)) {
if ( tty->ldisc.flush_buffer ) if ( tty->ldisc.ops->flush_buffer )
tty->ldisc.flush_buffer(tty); tty->ldisc.ops->flush_buffer(tty);
i2InputFlush( tty->driver_data ); i2InputFlush( tty->driver_data );
} }
} }
...@@ -1342,7 +1343,7 @@ static void do_status(struct work_struct *work) ...@@ -1342,7 +1343,7 @@ static void do_status(struct work_struct *work)
} }
tmp = pCh->pTTY->real_raw; tmp = pCh->pTTY->real_raw;
pCh->pTTY->real_raw = 0; pCh->pTTY->real_raw = 0;
pCh->pTTY->ldisc.receive_buf( pCh->pTTY, &brkc, &brkf, 1 ); pCh->pTTY->ldisc->ops.receive_buf( pCh->pTTY, &brkc, &brkf, 1 );
pCh->pTTY->real_raw = tmp; pCh->pTTY->real_raw = tmp;
} }
#endif /* NEVER_HAPPENS_AS_SETUP_XXX */ #endif /* NEVER_HAPPENS_AS_SETUP_XXX */
......
...@@ -199,7 +199,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty); ...@@ -199,7 +199,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty);
#define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data)) #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
#define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty)
static struct tty_ldisc n_hdlc_ldisc = { static struct tty_ldisc_ops n_hdlc_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "hdlc", .name = "hdlc",
...@@ -342,8 +342,8 @@ static int n_hdlc_tty_open (struct tty_struct *tty) ...@@ -342,8 +342,8 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
#endif #endif
/* Flush any pending characters in the driver and discipline. */ /* Flush any pending characters in the driver and discipline. */
if (tty->ldisc.flush_buffer) if (tty->ldisc.ops->flush_buffer)
tty->ldisc.flush_buffer(tty); tty->ldisc.ops->flush_buffer(tty);
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
......
...@@ -143,7 +143,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, ...@@ -143,7 +143,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count); char *fp, int count);
static struct tty_ldisc tty_ldisc_N_R3964 = { static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "R3964", .name = "R3964",
......
...@@ -1573,7 +1573,7 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file, ...@@ -1573,7 +1573,7 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file,
return mask; return mask;
} }
struct tty_ldisc tty_ldisc_N_TTY = { struct tty_ldisc_ops tty_ldisc_N_TTY = {
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "n_tty", .name = "n_tty",
.open = n_tty_open, .open = n_tty_open,
......
...@@ -514,8 +514,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, ...@@ -514,8 +514,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return; return;
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld) { if (ld) {
if (ld->receive_buf) if (ld->ops->receive_buf)
ld->receive_buf(tty, data, flags, count); ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
} }
......
...@@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun ...@@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun
c = to->receive_room; c = to->receive_room;
if (c > count) if (c > count)
c = count; c = count;
to->ldisc.receive_buf(to, buf, NULL, c); to->ldisc.ops->receive_buf(to, buf, NULL, c);
return c; return c;
} }
...@@ -149,11 +149,11 @@ static int pty_chars_in_buffer(struct tty_struct *tty) ...@@ -149,11 +149,11 @@ static int pty_chars_in_buffer(struct tty_struct *tty)
int count; int count;
/* We should get the line discipline lock for "tty->link" */ /* We should get the line discipline lock for "tty->link" */
if (!to || !to->ldisc.chars_in_buffer) if (!to || !to->ldisc.ops->chars_in_buffer)
return 0; return 0;
/* The ldisc must report 0 if no characters available to be read */ /* The ldisc must report 0 if no characters available to be read */
count = to->ldisc.chars_in_buffer(to); count = to->ldisc.ops->chars_in_buffer(to);
if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; if (tty->driver->subtype == PTY_TYPE_SLAVE) return count;
...@@ -186,8 +186,8 @@ static void pty_flush_buffer(struct tty_struct *tty) ...@@ -186,8 +186,8 @@ static void pty_flush_buffer(struct tty_struct *tty)
if (!to) if (!to)
return; return;
if (to->ldisc.flush_buffer) if (to->ldisc.ops->flush_buffer)
to->ldisc.flush_buffer(to); to->ldisc.ops->flush_buffer(to);
if (to->packet) { if (to->packet) {
spin_lock_irqsave(&tty->ctrl_lock, flags); spin_lock_irqsave(&tty->ctrl_lock, flags);
......
...@@ -327,7 +327,8 @@ int paste_selection(struct tty_struct *tty) ...@@ -327,7 +327,8 @@ int paste_selection(struct tty_struct *tty)
} }
count = sel_buffer_lth - pasted; count = sel_buffer_lth - pasted;
count = min(count, tty->receive_room); count = min(count, tty->receive_room);
tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count); tty->ldisc.ops->receive_buf(tty, sel_buffer + pasted,
NULL, count);
pasted += count; pasted += count;
} }
remove_wait_queue(&vc->paste_wait, &wait); remove_wait_queue(&vc->paste_wait, &wait);
......
...@@ -975,8 +975,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, ...@@ -975,8 +975,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return; return;
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld) { if (ld) {
if (ld->receive_buf) if (ld->ops->receive_buf)
ld->receive_buf(tty, data, flags, count); ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
} }
......
...@@ -641,8 +641,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, ...@@ -641,8 +641,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return; return;
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld) { if (ld) {
if (ld->receive_buf) if (ld->ops->receive_buf)
ld->receive_buf(tty, data, flags, count); ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
} }
......
...@@ -712,8 +712,8 @@ static void ldisc_receive_buf(struct tty_struct *tty, ...@@ -712,8 +712,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return; return;
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld) { if (ld) {
if (ld->receive_buf) if (ld->ops->receive_buf)
ld->receive_buf(tty, data, flags, count); ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
} }
......
This diff is collapsed.
...@@ -491,8 +491,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) ...@@ -491,8 +491,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld != NULL) { if (ld != NULL) {
if (ld->set_termios) if (ld->ops->set_termios)
(ld->set_termios)(tty, &old_termios); (ld->ops->set_termios)(tty, &old_termios);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
mutex_unlock(&tty->termios_mutex); mutex_unlock(&tty->termios_mutex);
...@@ -552,8 +552,8 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt) ...@@ -552,8 +552,8 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
if (ld != NULL) { if (ld != NULL) {
if ((opt & TERMIOS_FLUSH) && ld->flush_buffer) if ((opt & TERMIOS_FLUSH) && ld->ops->flush_buffer)
ld->flush_buffer(tty); ld->ops->flush_buffer(tty);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
...@@ -959,12 +959,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) ...@@ -959,12 +959,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
ld = tty_ldisc_ref(tty); ld = tty_ldisc_ref(tty);
switch (arg) { switch (arg) {
case TCIFLUSH: case TCIFLUSH:
if (ld && ld->flush_buffer) if (ld && ld->ops->flush_buffer)
ld->flush_buffer(tty); ld->ops->flush_buffer(tty);
break; break;
case TCIOFLUSH: case TCIOFLUSH:
if (ld && ld->flush_buffer) if (ld && ld->ops->flush_buffer)
ld->flush_buffer(tty); ld->ops->flush_buffer(tty);
/* fall through */ /* fall through */
case TCOFLUSH: case TCOFLUSH:
tty_driver_flush_buffer(tty); tty_driver_flush_buffer(tty);
......
...@@ -216,7 +216,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty) ...@@ -216,7 +216,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty)
* The line discipline structure. * The line discipline structure.
*/ */
static struct tty_ldisc serport_ldisc = { static struct tty_ldisc_ops serport_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "input", .name = "input",
.open = serport_ldisc_open, .open = serport_ldisc_open,
......
...@@ -466,7 +466,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ...@@ -466,7 +466,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
ld = tty_ldisc_ref(mp->tty); ld = tty_ldisc_ref(mp->tty);
if (ld == NULL) if (ld == NULL)
return -1; return -1;
if (ld->receive_buf == NULL) { if (ld->ops->receive_buf == NULL) {
#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS)
printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n"); printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n");
#endif #endif
...@@ -501,7 +501,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ...@@ -501,7 +501,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n", printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n",
datahandle, skb->len); datahandle, skb->len);
#endif #endif
ld->receive_buf(mp->tty, skb->data, NULL, skb->len); ld->ops->receive_buf(mp->tty, skb->data, NULL, skb->len);
kfree_skb(skb); kfree_skb(skb);
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
return 0; return 0;
......
...@@ -766,7 +766,7 @@ gigaset_tty_wakeup(struct tty_struct *tty) ...@@ -766,7 +766,7 @@ gigaset_tty_wakeup(struct tty_struct *tty)
cs_put(cs); cs_put(cs);
} }
static struct tty_ldisc gigaset_ldisc = { static struct tty_ldisc_ops gigaset_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "ser_gigaset", .name = "ser_gigaset",
......
...@@ -783,7 +783,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file, ...@@ -783,7 +783,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
return err; return err;
} }
static struct tty_ldisc sp_ldisc = { static struct tty_ldisc_ops sp_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "6pack", .name = "6pack",
......
...@@ -969,7 +969,7 @@ out: ...@@ -969,7 +969,7 @@ out:
mkiss_put(ax); mkiss_put(ax);
} }
static struct tty_ldisc ax_ldisc = { static struct tty_ldisc_ops ax_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "mkiss", .name = "mkiss",
......
...@@ -533,7 +533,7 @@ static void irtty_close(struct tty_struct *tty) ...@@ -533,7 +533,7 @@ static void irtty_close(struct tty_struct *tty)
/* ------------------------------------------------------- */ /* ------------------------------------------------------- */
static struct tty_ldisc irda_ldisc = { static struct tty_ldisc_ops irda_ldisc = {
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "irda", .name = "irda",
.flags = 0, .flags = 0,
......
...@@ -378,7 +378,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty) ...@@ -378,7 +378,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
} }
static struct tty_ldisc ppp_ldisc = { static struct tty_ldisc_ops ppp_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "ppp", .name = "ppp",
......
...@@ -418,7 +418,7 @@ ppp_sync_wakeup(struct tty_struct *tty) ...@@ -418,7 +418,7 @@ ppp_sync_wakeup(struct tty_struct *tty)
} }
static struct tty_ldisc ppp_sync_ldisc = { static struct tty_ldisc_ops ppp_sync_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "pppsync", .name = "pppsync",
......
...@@ -1301,7 +1301,7 @@ static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1301,7 +1301,7 @@ static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
#endif #endif
/* VSV changes end */ /* VSV changes end */
static struct tty_ldisc sl_ldisc = { static struct tty_ldisc_ops sl_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "slip", .name = "slip",
......
...@@ -688,9 +688,9 @@ static void cpc_tty_rx_work(struct work_struct *work) ...@@ -688,9 +688,9 @@ static void cpc_tty_rx_work(struct work_struct *work)
if (cpc_tty->tty) { if (cpc_tty->tty) {
ld = tty_ldisc_ref(cpc_tty->tty); ld = tty_ldisc_ref(cpc_tty->tty);
if (ld) { if (ld) {
if (ld->receive_buf) { if (ld->ops->receive_buf) {
CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); ld->ops->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
} }
tty_ldisc_deref(ld); tty_ldisc_deref(ld);
} }
......
...@@ -754,7 +754,7 @@ static void x25_asy_setup(struct net_device *dev) ...@@ -754,7 +754,7 @@ static void x25_asy_setup(struct net_device *dev)
dev->flags = IFF_NOARP; dev->flags = IFF_NOARP;
} }
static struct tty_ldisc x25_ldisc = { static struct tty_ldisc_ops x25_ldisc = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC, .magic = TTY_LDISC_MAGIC,
.name = "X.25", .name = "X.25",
......
...@@ -136,54 +136,6 @@ static const struct file_operations proc_tty_drivers_operations = { ...@@ -136,54 +136,6 @@ static const struct file_operations proc_tty_drivers_operations = {
.release = seq_release, .release = seq_release,
}; };
static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos)
{
return (*pos < NR_LDISCS) ? pos : NULL;
}
static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
(*pos)++;
return (*pos < NR_LDISCS) ? pos : NULL;
}
static void tty_ldiscs_seq_stop(struct seq_file *m, void *v)
{
}
static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
{
int i = *(loff_t *)v;
struct tty_ldisc *ld;
ld = tty_ldisc_get(i);
if (ld == NULL)
return 0;
seq_printf(m, "%-10s %2d\n", ld->name ? ld->name : "???", i);
tty_ldisc_put(i);
return 0;
}
static const struct seq_operations tty_ldiscs_seq_ops = {
.start = tty_ldiscs_seq_start,
.next = tty_ldiscs_seq_next,
.stop = tty_ldiscs_seq_stop,
.show = tty_ldiscs_seq_show,
};
static int proc_tty_ldiscs_open(struct inode *inode, struct file *file)
{
return seq_open(file, &tty_ldiscs_seq_ops);
}
static const struct file_operations tty_ldiscs_proc_fops = {
.owner = THIS_MODULE,
.open = proc_tty_ldiscs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
/* /*
* This function is called by tty_register_driver() to handle * This function is called by tty_register_driver() to handle
* registering the driver's /proc handler into /proc/tty/driver/<foo> * registering the driver's /proc handler into /proc/tty/driver/<foo>
......
...@@ -185,6 +185,7 @@ struct tty_struct { ...@@ -185,6 +185,7 @@ struct tty_struct {
struct tty_driver *driver; struct tty_driver *driver;
const struct tty_operations *ops; const struct tty_operations *ops;
int index; int index;
/* The ldisc objects are protected by tty_ldisc_lock at the moment */
struct tty_ldisc ldisc; struct tty_ldisc ldisc;
struct mutex termios_mutex; struct mutex termios_mutex;
spinlock_t ctrl_lock; spinlock_t ctrl_lock;
...@@ -289,7 +290,7 @@ extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); ...@@ -289,7 +290,7 @@ extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
extern int tty_check_change(struct tty_struct * tty); extern int tty_check_change(struct tty_struct * tty);
extern void stop_tty(struct tty_struct * tty); extern void stop_tty(struct tty_struct * tty);
extern void start_tty(struct tty_struct * tty); extern void start_tty(struct tty_struct * tty);
extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
extern int tty_unregister_ldisc(int disc); extern int tty_unregister_ldisc(int disc);
extern int tty_register_driver(struct tty_driver *driver); extern int tty_register_driver(struct tty_driver *driver);
extern int tty_unregister_driver(struct tty_driver *driver); extern int tty_unregister_driver(struct tty_driver *driver);
...@@ -330,9 +331,7 @@ extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); ...@@ -330,9 +331,7 @@ extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);
extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
extern void tty_ldisc_deref(struct tty_ldisc *); extern void tty_ldisc_deref(struct tty_ldisc *);
extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *);
extern const struct file_operations tty_ldiscs_proc_fops;
extern struct tty_ldisc *tty_ldisc_get(int);
extern void tty_ldisc_put(int);
extern void tty_wakeup(struct tty_struct *tty); extern void tty_wakeup(struct tty_struct *tty);
extern void tty_ldisc_flush(struct tty_struct *tty); extern void tty_ldisc_flush(struct tty_struct *tty);
...@@ -354,7 +353,7 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay); ...@@ -354,7 +353,7 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);
/* n_tty.c */ /* n_tty.c */
extern struct tty_ldisc tty_ldisc_N_TTY; extern struct tty_ldisc_ops tty_ldisc_N_TTY;
/* tty_audit.c */ /* tty_audit.c */
#ifdef CONFIG_AUDIT #ifdef CONFIG_AUDIT
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/wait.h> #include <linux/wait.h>
struct tty_ldisc { struct tty_ldisc_ops {
int magic; int magic;
char *name; char *name;
int num; int num;
...@@ -142,6 +142,11 @@ struct tty_ldisc { ...@@ -142,6 +142,11 @@ struct tty_ldisc {
int refcount; int refcount;
}; };
struct tty_ldisc {
struct tty_ldisc_ops *ops;
int refcount;
};
#define TTY_LDISC_MAGIC 0x5403 #define TTY_LDISC_MAGIC 0x5403
#define LDISC_FLAG_DEFINED 0x00000001 #define LDISC_FLAG_DEFINED 0x00000001
......
...@@ -617,14 +617,7 @@ static void rfcomm_tty_wakeup(unsigned long arg) ...@@ -617,14 +617,7 @@ static void rfcomm_tty_wakeup(unsigned long arg)
return; return;
BT_DBG("dev %p tty %p", dev, tty); BT_DBG("dev %p tty %p", dev, tty);
tty_wakeup(tty);
if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup)
(tty->ldisc.write_wakeup)(tty);
wake_up_interruptible(&tty->write_wait);
#ifdef SERIAL_HAVE_POLL_WAIT
wake_up_interruptible(&tty->poll_wait);
#endif
} }
static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
...@@ -1005,9 +998,7 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty) ...@@ -1005,9 +998,7 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty)
return; return;
skb_queue_purge(&dev->dlc->tx_queue); skb_queue_purge(&dev->dlc->tx_queue);
tty_wakeup(tty);
if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup)
tty->ldisc.write_wakeup(tty);
} }
static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch) static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch)
......