mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
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: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
+2
-2
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
|
||||
@@ -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",
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+213
-123
File diff suppressed because it is too large
Load Diff
@@ -491,8 +491,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
|
||||
|
||||
ld = tty_ldisc_ref(tty);
|
||||
if (ld != NULL) {
|
||||
if (ld->set_termios)
|
||||
(ld->set_termios)(tty, &old_termios);
|
||||
if (ld->ops->set_termios)
|
||||
(ld->ops->set_termios)(tty, &old_termios);
|
||||
tty_ldisc_deref(ld);
|
||||
}
|
||||
mutex_unlock(&tty->termios_mutex);
|
||||
@@ -552,8 +552,8 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
|
||||
ld = tty_ldisc_ref(tty);
|
||||
|
||||
if (ld != NULL) {
|
||||
if ((opt & TERMIOS_FLUSH) && ld->flush_buffer)
|
||||
ld->flush_buffer(tty);
|
||||
if ((opt & TERMIOS_FLUSH) && ld->ops->flush_buffer)
|
||||
ld->ops->flush_buffer(tty);
|
||||
tty_ldisc_deref(ld);
|
||||
}
|
||||
|
||||
@@ -959,12 +959,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
|
||||
ld = tty_ldisc_ref(tty);
|
||||
switch (arg) {
|
||||
case TCIFLUSH:
|
||||
if (ld && ld->flush_buffer)
|
||||
ld->flush_buffer(tty);
|
||||
if (ld && ld->ops->flush_buffer)
|
||||
ld->ops->flush_buffer(tty);
|
||||
break;
|
||||
case TCIOFLUSH:
|
||||
if (ld && ld->flush_buffer)
|
||||
ld->flush_buffer(tty);
|
||||
if (ld && ld->ops->flush_buffer)
|
||||
ld->ops->flush_buffer(tty);
|
||||
/* fall through */
|
||||
case TCOFLUSH:
|
||||
tty_driver_flush_buffer(tty);
|
||||
|
||||
@@ -216,7 +216,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty)
|
||||
* The line discipline structure.
|
||||
*/
|
||||
|
||||
static struct tty_ldisc serport_ldisc = {
|
||||
static struct tty_ldisc_ops serport_ldisc = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "input",
|
||||
.open = serport_ldisc_open,
|
||||
|
||||
@@ -466,7 +466,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)
|
||||
ld = tty_ldisc_ref(mp->tty);
|
||||
if (ld == NULL)
|
||||
return -1;
|
||||
if (ld->receive_buf == NULL) {
|
||||
if (ld->ops->receive_buf == NULL) {
|
||||
#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS)
|
||||
printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n");
|
||||
#endif
|
||||
@@ -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",
|
||||
datahandle, skb->len);
|
||||
#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);
|
||||
tty_ldisc_deref(ld);
|
||||
return 0;
|
||||
|
||||
@@ -766,7 +766,7 @@ gigaset_tty_wakeup(struct tty_struct *tty)
|
||||
cs_put(cs);
|
||||
}
|
||||
|
||||
static struct tty_ldisc gigaset_ldisc = {
|
||||
static struct tty_ldisc_ops gigaset_ldisc = {
|
||||
.owner = THIS_MODULE,
|
||||
.magic = TTY_LDISC_MAGIC,
|
||||
.name = "ser_gigaset",
|
||||
|
||||
@@ -783,7 +783,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
|
||||
return err;
|
||||
}
|
||||
|
||||
static struct tty_ldisc sp_ldisc = {
|
||||
static struct tty_ldisc_ops sp_ldisc = {
|
||||
.owner = THIS_MODULE,
|
||||
.magic = TTY_LDISC_MAGIC,
|
||||
.name = "6pack",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user