Skip to content

Commit

Permalink
tty: Ldisc revamp
Browse files Browse the repository at this point in the history
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: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Alan Cox authored and torvalds committed Jul 21, 2008
1 parent e1e5770 commit a352def
Show file tree
Hide file tree
Showing 32 changed files with 286 additions and 246 deletions.
6 changes: 3 additions & 3 deletions drivers/bluetooth/hci_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
open path is before the ldisc is referencable */

if (tty->ldisc.flush_buffer)
tty->ldisc.flush_buffer(tty);
if (tty->ldisc.ops->flush_buffer)
tty->ldisc.ops->flush_buffer(tty);
tty_driver_flush_buffer(tty);

return 0;
Expand Down Expand Up @@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty,

static int __init hci_uart_init(void)
{
static struct tty_ldisc hci_uart_ldisc;
static struct tty_ldisc_ops hci_uart_ldisc;
int err;

BT_INFO("HCI UART driver ver %s", VERSION);
Expand Down
3 changes: 2 additions & 1 deletion drivers/char/cyclades.c
Original file line number Diff line number Diff line change
Expand Up @@ -5246,7 +5246,8 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
HZ, info->idle_stats.recv_bytes,
(cur_jifs - info->idle_stats.recv_idle)/
HZ, info->idle_stats.overruns,
(long)info->tty->ldisc.num);
/* FIXME: double check locking */
(long)info->tty->ldisc.ops->num);
else
size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
"%10lu %8lu %9lu %6ld\n",
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/epca.c
Original file line number Diff line number Diff line change
Expand Up @@ -2262,8 +2262,8 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file,
tty_wait_until_sent(tty, 0);
} else {
/* ldisc lock already held in ioctl */
if (tty->ldisc.flush_buffer)
tty->ldisc.flush_buffer(tty);
if (tty->ldisc.ops->flush_buffer)
tty->ldisc.ops->flush_buffer(tty);
}
unlock_kernel();
/* Fall Thru */
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/ip2/i2lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,11 @@ i2Input(i2ChanStrPtr pCh)
amountToMove = count;
}
// Move the first block
pCh->pTTY->ldisc.receive_buf( pCh->pTTY,
pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY,
&(pCh->Ibuf[stripIndex]), NULL, amountToMove );
// If we needed to wrap, do the second data move
if (count > amountToMove) {
pCh->pTTY->ldisc.receive_buf( pCh->pTTY,
pCh->pTTY->ldisc.ops->receive_buf( pCh->pTTY,
pCh->Ibuf, NULL, count - amountToMove );
}
// Bump and wrap the stripIndex all at once by the amount of data read. This
Expand Down
7 changes: 4 additions & 3 deletions drivers/char/ip2/ip2main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,11 +1289,12 @@ static void do_input(struct work_struct *work)
// code duplicated from n_tty (ldisc)
static inline void isig(int sig, struct tty_struct *tty, int flush)
{
/* FIXME: This is completely bogus */
if (tty->pgrp)
kill_pgrp(tty->pgrp, sig, 1);
if (flush || !L_NOFLSH(tty)) {
if ( tty->ldisc.flush_buffer )
tty->ldisc.flush_buffer(tty);
if ( tty->ldisc.ops->flush_buffer )
tty->ldisc.ops->flush_buffer(tty);
i2InputFlush( tty->driver_data );
}
}
Expand Down Expand Up @@ -1342,7 +1343,7 @@ static void do_status(struct work_struct *work)
}
tmp = pCh->pTTY->real_raw;
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;
}
#endif /* NEVER_HAPPENS_AS_SETUP_XXX */
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/n_hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 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,
.magic = TTY_LDISC_MAGIC,
.name = "hdlc",
Expand Down Expand Up @@ -342,8 +342,8 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
#endif

/* Flush any pending characters in the driver and discipline. */
if (tty->ldisc.flush_buffer)
tty->ldisc.flush_buffer(tty);
if (tty->ldisc.ops->flush_buffer)
tty->ldisc.ops->flush_buffer(tty);

tty_driver_flush_buffer(tty);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/n_r3964.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
char *fp, int count);

static struct tty_ldisc tty_ldisc_N_R3964 = {
static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
.owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC,
.name = "R3964",
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file,
return mask;
}

struct tty_ldisc tty_ldisc_N_TTY = {
struct tty_ldisc_ops tty_ldisc_N_TTY = {
.magic = TTY_LDISC_MAGIC,
.name = "n_tty",
.open = n_tty_open,
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return;
ld = tty_ldisc_ref(tty);
if (ld) {
if (ld->receive_buf)
ld->receive_buf(tty, data, flags, count);
if (ld->ops->receive_buf)
ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld);
}
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/char/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun
c = to->receive_room;
if (c > count)
c = count;
to->ldisc.receive_buf(to, buf, NULL, c);
to->ldisc.ops->receive_buf(to, buf, NULL, c);

return c;
}
Expand Down Expand Up @@ -149,11 +149,11 @@ static int pty_chars_in_buffer(struct tty_struct *tty)
int count;

/* 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;

/* 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;

Expand Down Expand Up @@ -186,8 +186,8 @@ static void pty_flush_buffer(struct tty_struct *tty)
if (!to)
return;

if (to->ldisc.flush_buffer)
to->ldisc.flush_buffer(to);
if (to->ldisc.ops->flush_buffer)
to->ldisc.ops->flush_buffer(to);

if (to->packet) {
spin_lock_irqsave(&tty->ctrl_lock, flags);
Expand Down
3 changes: 2 additions & 1 deletion drivers/char/selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ int paste_selection(struct tty_struct *tty)
}
count = sel_buffer_lth - pasted;
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;
}
remove_wait_queue(&vc->paste_wait, &wait);
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/synclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return;
ld = tty_ldisc_ref(tty);
if (ld) {
if (ld->receive_buf)
ld->receive_buf(tty, data, flags, count);
if (ld->ops->receive_buf)
ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld);
}
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/synclink_gt.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return;
ld = tty_ldisc_ref(tty);
if (ld) {
if (ld->receive_buf)
ld->receive_buf(tty, data, flags, count);
if (ld->ops->receive_buf)
ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld);
}
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/synclinkmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,
return;
ld = tty_ldisc_ref(tty);
if (ld) {
if (ld->receive_buf)
ld->receive_buf(tty, data, flags, count);
if (ld->ops->receive_buf)
ld->ops->receive_buf(tty, data, flags, count);
tty_ldisc_deref(ld);
}
}
Expand Down
Loading

0 comments on commit a352def

Please sign in to comment.