[PATCH] Char: tty_wakeup cleanup

tty_wakeup cleanup

- remove wake_up_interruptible(&tty->write_wait) surrounding
  tty_wakup(tty);
- substitute tty->ldisc.write_wakeup(tty) + wake_up() by tty_wakeup(tty);

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Acked-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index feb4ac8..39880eb 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -527,10 +527,8 @@
 	if (!tty)
 		return;
 
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 /*
@@ -968,7 +966,6 @@
 	local_irq_save(flags);
 	info->xmit.head = info->xmit.tail = 0;
 	local_irq_restore(flags);
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 3ffa080..363beb1 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4488,7 +4488,6 @@
 		CY_UNLOCK(info, flags);
 	}
 	tty_wakeup(tty);
-	wake_up_interruptible(&tty->write_wait);
 }				/* cy_flush_buffer */
 
 /*
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index a0f822c..88fc24f 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -844,7 +844,6 @@
 	fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
 	memoff(ch);
 	spin_unlock_irqrestore(&epca_lock, flags);
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 } /* End pc_flush_buffer */
 
@@ -1795,7 +1794,6 @@
 				{ /* Begin if LOWWAIT */
 					ch->statusflags &= ~LOWWAIT;
 					tty_wakeup(tty);
-					wake_up_interruptible(&tty->write_wait);
 				} /* End if LOWWAIT */
 			} else if (event & EMPTYTX_IND)  { /* Begin EMPTYTX_IND */
 				/* This event is generated by setup_empty_event */
@@ -1803,7 +1801,6 @@
 				if (ch->statusflags & EMPTYWAIT)  { /* Begin if EMPTYWAIT */
 					ch->statusflags &= ~EMPTYWAIT;
 					tty_wakeup(tty);
-					wake_up_interruptible(&tty->write_wait);
 				} /* End if EMPTYWAIT */
 			} /* End EMPTYTX_IND */
 		} /* End if valid tty */
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index e769811..337bbcd 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -382,7 +382,6 @@
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
 	spin_unlock_irqrestore (&port->driver_lock, flags);
 
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 	func_exit ();
 }
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 7804576..88b9d33 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -1373,15 +1373,7 @@
 	ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags,
 			(1 << TTY_DO_WRITE_WAKEUP) );
 
-	wake_up_interruptible ( &tp->write_wait );
-	if ( ( tp->flags & (1 << TTY_DO_WRITE_WAKEUP) ) 
-	  && tp->ldisc.write_wakeup )
-	{
-		(tp->ldisc.write_wakeup) ( tp );
-
-		ip2trace (CHANN, ITRC_SICMD, 11, 0 );
-
-	}
+	tty_wakeup(tp);
 }
 
 static inline void
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 9feb762..43ab9ed 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1487,7 +1487,6 @@
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 68645d3..7b279d1 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -2424,7 +2424,6 @@
 			if (tty != NULL) {
 				tty_wakeup(tty);
 				EBRDENABLE(brdp);
-				wake_up_interruptible(&tty->write_wait);
 			}
 		}
 
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 83f604b..df1e608 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -1254,9 +1254,7 @@
 	spin_unlock_irqrestore(&info->slock, flags);
 	/* above added by shinhay */
 
-	wake_up_interruptible(&tty->write_wait);
-	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
-		(tty->ldisc.write_wakeup) (tty);
+	tty_wakeup(tty);
 }
 
 static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index f108c13..4ab2c98 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -887,10 +887,8 @@
 	if (debug_level >= DEBUG_LEVEL_BH)
 		printk("bh_transmit() entry on %s\n", info->device_name);
 
-	if (tty) {
+	if (tty)
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 static void bh_status(MGSLPC_INFO *info)
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index eeda40c..ebc7634 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -162,13 +162,8 @@
 
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 
-	if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) {
-		rio_dprintk(RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....", (int) (PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)), PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
-		if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && PortP->gs.tty->ldisc.write_wakeup)
-			(PortP->gs.tty->ldisc.write_wakeup) (PortP->gs.tty);
-		rio_dprintk(RIO_DEBUG_INTR, "(%d/%d)\n", PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
-		wake_up_interruptible(&PortP->gs.tty->write_wait);
-	}
+	if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN))
+		tty_wakeup(PortP->gs.tty);
 
 }
 
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index e2a94bf..7014525 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1229,7 +1229,6 @@
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
 	restore_flags(flags);
 	
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
@@ -1570,10 +1569,8 @@
 	if(!(tty = port->tty)) 
 		return;
 
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 static const struct tty_operations riscom_ops = {
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index e94a62e..106f225 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -474,7 +474,6 @@
 
 	if (info->xmit_cnt < WAKEUP_CHARS) {
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
 		wake_up_interruptible(&tty->poll_wait);
 #endif
@@ -1772,7 +1771,6 @@
 end:
  	if (info->xmit_cnt < WAKEUP_CHARS) {
  		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
 		wake_up_interruptible(&tty->poll_wait);
 #endif
@@ -1841,7 +1839,6 @@
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 	spin_unlock_irqrestore(&info->slock, flags);
 
-	wake_up_interruptible(&tty->write_wait);
 #ifdef ROCKETPORT_HAVE_POLL_WAIT
 	wake_up_interruptible(&tty->poll_wait);
 #endif
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 20946f5..92043c8 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2350,10 +2350,8 @@
 		return;
 	}
 
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) {
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
  		tty_wakeup(tty);
-		//wake_up_interruptible(&tty->write_wait);
-	}
 
 	func_exit();
 }
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 3fa625d..bf76db1 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -1148,10 +1148,8 @@
 		printk( "%s(%d):mgsl_bh_transmit() entry on %s\n",
 			__FILE__,__LINE__,info->device_name);
 
-	if (tty) {
+	if (tty)
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 
 	/* if transmitter idle and loopmode_send_done_requested
 	 * then start echoing RxD to TxD
@@ -2340,7 +2338,6 @@
 	del_timer(&info->tx_timer);	
 	spin_unlock_irqrestore(&info->irq_spinlock,flags);
 	
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 792c79c..54af763 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1045,7 +1045,6 @@
 		info->tx_count = 0;
 	spin_unlock_irqrestore(&info->lock,flags);
 
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
@@ -1933,10 +1932,8 @@
 	struct tty_struct *tty = info->tty;
 
 	DBGBH(("%s bh_transmit\n", info->device_name));
-	if (tty) {
+	if (tty)
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 static void dsr_change(struct slgt_info *info)
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 8f4d67a..ebde4e5 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -1258,7 +1258,6 @@
 	del_timer(&info->tx_timer);
 	spin_unlock_irqrestore(&info->lock,flags);
 
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
@@ -2127,10 +2126,8 @@
 		printk( "%s(%d):%s bh_transmit() entry\n",
 			__FILE__,__LINE__,info->device_name);
 
-	if (tty) {
+	if (tty)
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 void bh_status(SLMP_INFO *info)
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 458b646..f13de20 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -599,19 +599,9 @@
 static void if_wake(unsigned long data)
 {
 	struct cardstate *cs = (struct cardstate *) data;
-	struct tty_struct *tty;
 
-	tty = cs->tty;
-	if (!tty)
-		return;
-
-	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-	    tty->ldisc.write_wakeup) {
-		gig_dbg(DEBUG_IF, "write wakeup call");
-		tty->ldisc.write_wakeup(tty);
-	}
-
-	wake_up_interruptible(&tty->write_wait);
+	if (cs->tty)
+		tty_wakeup(cs->tty);
 }
 
 /*** interface to common ***/
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index fc80afe..ea5f30d 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1261,7 +1261,6 @@
 	}
 	isdn_tty_cleanup_xmit(info);
 	info->xmit_count = 0;
-	wake_up_interruptible(&tty->write_wait);
 	tty_wakeup(tty);
 }
 
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 42b050c..312bef6 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -3173,12 +3173,8 @@
 	if (!tty)
 		return;
 
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
-		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-		    tty->ldisc.write_wakeup)
-			(tty->ldisc.write_wakeup)(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
+		tty_wakeup(tty);
 }
 
 static int
@@ -3798,11 +3794,7 @@
 	info->xmit.head = info->xmit.tail = 0;
 	restore_flags(flags);
 
-	wake_up_interruptible(&tty->write_wait);
-
-	if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-	    tty->ldisc.write_wakeup)
-		(tty->ldisc.write_wakeup)(tty);
+	tty_wakeup(tty);
 }
 
 /*
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index fc31972..3d72aa5 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -626,10 +626,8 @@
 	if (!tty)
 		return;
 
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
+	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
 		tty_wakeup(tty);
-		wake_up_interruptible(&tty->write_wait);
-	}
 }
 
 static int zs_startup(struct dec_serial * info)
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 0b0fb51..d78692c 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -616,15 +616,7 @@
 
 static void digi_wakeup_write( struct usb_serial_port *port )
 {
-
-	struct tty_struct *tty = port->tty;
-
-
-	/* wake up port processes */
-	wake_up_interruptible( &port->write_wait );
-
-	/* wake up line discipline */
-	tty_wakeup(tty);
+	tty_wakeup(port->tty);
 }
 
 
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index da514cb..dd0b66a 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -182,13 +182,8 @@
 	struct keyspan_pda_private *priv =
 		container_of(work, struct keyspan_pda_private, wakeup_work);
 	struct usb_serial_port *port = priv->port;
-	struct tty_struct *tty = port->tty;
 
-	/* wake up port processes */
-	wake_up_interruptible( &port->write_wait );
-
-	/* wake up line discipline */
-	tty_wakeup(tty);
+	tty_wakeup(port->tty);
 }
 
 static void keyspan_pda_request_unthrottle(struct work_struct *work)
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 6109c67..2d588fb 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -269,18 +269,8 @@
 
 	tty = mos7720_port->port->tty;
 
-	if (tty && mos7720_port->open) {
-		/* let the tty driver wakeup if it has a special *
-		 * write_wakeup function */
-		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-		     tty->ldisc.write_wakeup)
-			(tty->ldisc.write_wakeup)(tty);
-
-		/* tell the tty driver that something has changed */
-		wake_up_interruptible(&tty->write_wait);
-	}
-
-	/* schedule_work(&mos7720_port->port->work); */
+	if (tty && mos7720_port->open)
+		tty_wakeup(tty);
 }
 
 /*
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index b2264a8..c6cca85 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -755,18 +755,8 @@
 
 	tty = mos7840_port->port->tty;
 
-	if (tty && mos7840_port->open) {
-		/* let the tty driver wakeup if it has a special *
-		 * write_wakeup function                         */
-
-		if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
-		    && tty->ldisc.write_wakeup) {
-			(tty->ldisc.write_wakeup) (tty);
-		}
-
-		/* tell the tty driver that something has changed */
-		wake_up_interruptible(&tty->write_wait);
-	}
+	if (tty && mos7840_port->open)
+		tty_wakeup(tty);
 
 }