list_for_each_entry(filp, &tty->tty_files, f_list) { 
list_for_each_entry(filp, &tty->tty_files, f_u.fu_list) { 
static void do_tty_hangup(void *data){	struct tty_struct *tty = (struct tty_struct *) data;	struct file * cons_filp = NULL;	struct file *filp, *f = NULL;	struct task_struct *p;	struct tty_ldisc *ld;	int    closecount = 0, n;	if (!tty)		return;	/* inuse_filps is protected by the single kernel lock */	lock_kernel();	spin_lock(&redirect_lock);	if (redirect && redirect->private_data == tty) {		f = redirect;		redirect = NULL;	}	spin_unlock(&redirect_lock);		check_tty_count(tty, "do_tty_hangup");	file_list_lock();	/* This breaks for file handles being sent over AF_UNIX sockets ? */	list_for_each_entry(filp, &tty->tty_files, f_list) {		if (filp->f_op->write == redirected_tty_write)			cons_filp = filp;		if (filp->f_op->write != tty_write)			continue;		closecount++;		tty_fasync(-1, filp, 0);	/* can't block */		filp->f_op = &hung_up_tty_fops;	}	file_list_unlock();		/* FIXME! What are the locking issues here? This may me overdoing things..	 * this question is especially important now that we've removed the irqlock. */	ld = tty_ldisc_ref(tty);	if(ld != NULL)	/* We may have no line discipline at this point */	{		if (ld->flush_buffer)			ld->flush_buffer(tty);		if (tty->driver->flush_buffer)			tty->driver->flush_buffer(tty);		if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) &&		    ld->write_wakeup)			ld->write_wakeup(tty);		if (ld->hangup)			ld->hangup(tty);	}	/* FIXME: Once we trust the LDISC code better we can wait here for	   ldisc completion and fix the driver call race */	   	wake_up_interruptible(&tty->write_wait);	wake_up_interruptible(&tty->read_wait);	/*	 * Shutdown the current line discipline, and reset it to	 * N_TTY.	 */	if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)	{		down(&tty->termios_sem);		*tty->termios = tty->driver->init_termios;		up(&tty->termios_sem);	}		/* Defer ldisc switch */	/* tty_deferred_ldisc_switch(N_TTY);		  This should get done automatically when the port closes and	  tty_release is called */		read_lock(&tasklist_lock);	if (tty->session > 0) {		do_each_task_pid(tty->session, PIDTYPE_SID, p) {			if (p->signal->tty == tty)				p->signal->tty = NULL;			if (!p->signal->leader)				continue;			send_group_sig_info(SIGHUP, SEND_SIG_PRIV, p);			send_group_sig_info(SIGCONT, SEND_SIG_PRIV, p);			if (tty->pgrp > 0)				p->signal->tty_old_pgrp = tty->pgrp;		} while_each_task_pid(tty->session, PIDTYPE_SID, p);	}	read_unlock(&tasklist_lock);	tty->flags = 0;	tty->session = 0;	tty->pgrp = -1;	tty->ctrl_status = 0;	/*	 *	If one of the devices matches a console pointer, we	 *	cannot just call hangup() because that will cause	 *	tty->count and state->count to go out of sync.	 *	So we just call close() the right number of times.	 */	if (cons_filp) {		if (tty->driver->close)			for (n = 0; n < closecount; n++)				tty->driver->close(tty, cons_filp);	} else if (tty->driver->hangup)		(tty->driver->hangup)(tty);			/* We don't want to have driver/ldisc interactions beyond	   the ones we did here. The driver layer expects no	   calls after ->hangup() from the ldisc side. However we	   can't yet guarantee all that */	set_bit(TTY_HUPPED, &tty->flags);	if (ld) {		tty_ldisc_enable(tty);		tty_ldisc_deref(ld);	}	unlock_kernel();	if (f)		fput(f);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2f51201662b28dbf8c15fb7eb972bc51c6cc3fa5/tty_io.c/buggy/drivers/char/tty_io.c