[-mm PATCH 18/32] drivers/char: fix-up schedule_timeout() usage

Nishanth Aravamudan <[email protected]>
Newsgroups gmane.linux.tape
Message-ID <[email protected]>
Description: Use schedule_timeout_interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.

Signed-off-by: Nishanth Aravamudan <[email protected]>

---

 drivers/char/ftape/lowlevel/fdc-io.c |    6 ++----
 drivers/char/hw_random.c             |    5 +----
 drivers/char/ip2/i2lib.c             |    6 ++----
 drivers/char/ipmi/ipmi_si_intf.c     |   18 ++++++------------
 drivers/char/ipmi/ipmi_watchdog.c    |    6 ++----
 drivers/char/mxser.c                 |   12 ++++--------
 6 files changed, 17 insertions(+), 36 deletions(-)

diff -urpN 2.6.13-rc5-mm1/drivers/char/ftape/lowlevel/fdc-io.c 2.6.13-rc5-mm1-dev/drivers/char/ftape/lowlevel/fdc-io.c
--- 2.6.13-rc5-mm1/drivers/char/ftape/lowlevel/fdc-io.c	2005-08-07 09:57:24.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/ftape/lowlevel/fdc-io.c	2005-08-08 14:21:35.000000000 -0700
@@ -387,10 +387,8 @@ int fdc_interrupt_wait(unsigned int time
 
 	set_current_state(TASK_INTERRUPTIBLE);
 	add_wait_queue(&ftape_wait_intr, &wait);
-	while (!ft_interrupt_seen && timeout) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		timeout = schedule_timeout(timeout);
-        }
+	while (!ft_interrupt_seen && timeout)
+		timeout = schedule_timeout_interruptible(timeout);
 
 	spin_lock_irq(&current->sighand->siglock);
 	current->blocked = old_sigmask;
diff -urpN 2.6.13-rc5-mm1/drivers/char/hw_random.c 2.6.13-rc5-mm1-dev/drivers/char/hw_random.c
--- 2.6.13-rc5-mm1/drivers/char/hw_random.c	2005-08-07 09:57:50.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/hw_random.c	2005-08-08 14:21:45.000000000 -0700
@@ -513,10 +513,7 @@ static ssize_t rng_dev_read (struct file
 			return ret ? : -EAGAIN;
 
 		if(need_resched())
-		{
-			current->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(1);
-		}
+			schedule_timeout_interruptible(1);
 		else
 			udelay(200);	/* FIXME: We could poll for 250uS ?? */
 
diff -urpN 2.6.13-rc5-mm1/drivers/char/ip2/i2lib.c 2.6.13-rc5-mm1-dev/drivers/char/ip2/i2lib.c
--- 2.6.13-rc5-mm1/drivers/char/ip2/i2lib.c	2005-08-07 10:05:20.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/ip2/i2lib.c	2005-08-08 14:22:27.000000000 -0700
@@ -655,8 +655,7 @@ i2QueueCommands(int type, i2ChanStrPtr p
 			timeout--;   // So negative values == forever
 		
 		if (!in_interrupt()) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(1);	// short nap 
+			schedule_timeout_interruptible(1);	// short nap 
 		} else {
 			// we cannot sched/sleep in interrrupt silly
 			return 0;   
@@ -1132,8 +1131,7 @@ i2Output(i2ChanStrPtr pCh, const char *p
 
 					ip2trace (CHANN, ITRC_OUTPUT, 61, 0 );
 
-					set_current_state(TASK_INTERRUPTIBLE);
-					schedule_timeout(2);
+					schedule_timeout_interruptible(2);
 					if (signal_pending(current)) {
 						break;
 					}
diff -urpN 2.6.13-rc5-mm1/drivers/char/ipmi/ipmi_si_intf.c 2.6.13-rc5-mm1-dev/drivers/char/ipmi/ipmi_si_intf.c
--- 2.6.13-rc5-mm1/drivers/char/ipmi/ipmi_si_intf.c	2005-08-07 10:05:20.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/ipmi/ipmi_si_intf.c	2005-08-08 14:23:13.000000000 -0700
@@ -1988,8 +1988,7 @@ static int try_get_dev_id(struct smi_inf
 	for (;;)
 	{
 		if (smi_result == SI_SM_CALL_WITH_DELAY) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 			smi_result = smi_info->handlers->event(
 				smi_info->si_sm, 100);
 		}
@@ -2327,10 +2326,8 @@ static int init_one_smi(int intf_num, st
 
 	/* Wait for the timer to stop.  This avoids problems with race
 	   conditions removing the timer here. */
-	while (!new_smi->timer_stopped) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while (!new_smi->timer_stopped)
+		schedule_timeout_uninterruptible(1);
 
  out_err:
 	if (new_smi->intf)
@@ -2450,17 +2447,14 @@ static void __exit cleanup_one_si(struct
 
 	/* Wait for the timer to stop.  This avoids problems with race
 	   conditions removing the timer here. */
-	while (!to_clean->timer_stopped) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while (!to_clean->timer_stopped)
+		schedule_timeout_uninterruptible(1);
 
 	/* Interrupts and timeouts are stopped, now make sure the
 	   interface is in a clean state. */
 	while ((to_clean->curr_msg) || (to_clean->si_state != SI_NORMAL)) {
 		poll(to_clean);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	rv = ipmi_unregister_smi(to_clean->intf);
diff -urpN 2.6.13-rc5-mm1/drivers/char/ipmi/ipmi_watchdog.c 2.6.13-rc5-mm1-dev/drivers/char/ipmi/ipmi_watchdog.c
--- 2.6.13-rc5-mm1/drivers/char/ipmi/ipmi_watchdog.c	2005-08-07 10:05:20.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/ipmi/ipmi_watchdog.c	2005-08-08 14:23:24.000000000 -0700
@@ -1038,10 +1038,8 @@ static __exit void ipmi_unregister_watch
 	/* Wait to make sure the message makes it out.  The lower layer has
 	   pointers to our buffers, we want to make sure they are done before
 	   we release our memory. */
-	while (atomic_read(&set_timeout_tofree)) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+	while (atomic_read(&set_timeout_tofree))
+		schedule_timeout_uninterruptible(1);
 
 	/* Disconnect from IPMI. */
 	rv = ipmi_destroy_user(watchdog_user);
diff -urpN 2.6.13-rc5-mm1/drivers/char/mxser.c 2.6.13-rc5-mm1-dev/drivers/char/mxser.c
--- 2.6.13-rc5-mm1/drivers/char/mxser.c	2005-08-07 09:57:25.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/drivers/char/mxser.c	2005-08-08 14:33:43.000000000 -0700
@@ -1059,8 +1059,7 @@ static void mxser_close(struct tty_struc
 		 */
 		timeout = jiffies + HZ;
 		while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(5);
+			schedule_timeout_interruptible(5);
 			if (time_after(jiffies, timeout))
 				break;
 		}
@@ -1081,10 +1080,8 @@ static void mxser_close(struct tty_struc
 	info->event = 0;
 	info->tty = NULL;
 	if (info->blocked_open) {
-		if (info->close_delay) {
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(info->close_delay);
-		}
+		if (info->close_delay)
+			schedule_timeout_interruptible(info->close_delay);
 		wake_up_interruptible(&info->open_wait);
 	}
 
@@ -1802,8 +1799,7 @@ static void mxser_wait_until_sent(struct
 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
 		printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(char_time);
+		schedule_timeout_interruptible(char_time);
 		if (signal_pending(current))
 			break;
 		if (timeout && time_after(jiffies, orig_jiffies + timeout))
-
To unsubscribe from this list: send the line "unsubscribe linux-tape" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.