patch-2.1.37 linux/drivers/char/tty_io.c

Next file: linux/drivers/char/vga.c
Previous file: linux/drivers/char/tpqic02.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.36/linux/drivers/char/tty_io.c linux/drivers/char/tty_io.c
@@ -166,14 +166,11 @@
 {
 #ifdef CHECK_TTY_COUNT
 	struct file *f;
-	int i, count = 0;
+	int count = 0;
 	
-	for (f = first_file, i=0; i<nr_files; i++, f = f->f_next) {
-		if (!f->f_count)
-			continue;
-		if (f->private_data == tty) {
+	for(f = inuse_filps; f; f = f->f_next) {
+		if(f->private_data == tty)
 			count++;
-		}
 	}
 	if (tty->driver.type == TTY_DRIVER_TYPE_PTY &&
 	    tty->driver.subtype == PTY_TYPE_SLAVE &&
@@ -363,16 +360,14 @@
 
 void do_tty_hangup(struct tty_struct * tty, struct file_operations *fops)
 {
-	int i;
+
 	struct file * filp;
 	struct task_struct *p;
 
 	if (!tty)
 		return;
 	check_tty_count(tty, "do_tty_hangup");
-	for (filp = first_file, i=0; i<nr_files; i++, filp = filp->f_next) {
-		if (!filp->f_count)
-			continue;
+	for (filp = inuse_filps; filp; filp = filp->f_next) {
 		if (filp->private_data != tty)
 			continue;
 		if (!filp->f_inode)
@@ -405,13 +400,14 @@
 		tty->ldisc = ldiscs[N_TTY];
 		tty->termios->c_line = N_TTY;
 		if (tty->ldisc.open) {
-			i = (tty->ldisc.open)(tty);
+			int i = (tty->ldisc.open)(tty);
 			if (i < 0)
 				printk("do_tty_hangup: N_TTY open: error %d\n",
 				       -i);
 		}
 	}
 	
+	read_lock(&tasklist_lock);
  	for_each_task(p) {
 		if ((tty->session > 0) && (p->session == tty->session) &&
 		    p->leader) {
@@ -423,6 +419,8 @@
 		if (p->tty == tty)
 			p->tty = NULL;
 	}
+	read_unlock(&tasklist_lock);
+
 	tty->flags = 0;
 	tty->session = 0;
 	tty->pgrp = -1;
@@ -494,9 +492,11 @@
 	tty->session = 0;
 	tty->pgrp = -1;
 
+	read_lock(&tasklist_lock);
 	for_each_task(p)
 	  	if (p->session == current->session)
 			p->tty = NULL;
+	read_unlock(&tasklist_lock);
 }
 
 void wait_for_keypress(void)
@@ -1338,9 +1338,11 @@
 			 */
 			struct task_struct *p;
 
+			read_lock(&tasklist_lock);
 			for_each_task(p)
 				if (p->tty == tty)
 					p->tty = NULL;
+			read_unlock(&tasklist_lock);
 		} else
 			return -EPERM;
 	}
@@ -1760,6 +1762,9 @@
 #endif
 #ifdef CONFIG_DIGI
 	pcxe_init();
+#endif
+#ifdef CONFIG_DIGIEPCA
+	pc_init();
 #endif
 #ifdef CONFIG_RISCOM8
 	riscom8_init();

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov