From: Nishanth Aravamudan <[email-masked]>

Use schedule_timeout_uninterruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.

(akpm: this patch relies on other stuff in -mm, please don't apply)

Signed-off-by: Nishanth Aravamudan <[email-masked]>
Cc: James Bottomley <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 drivers/scsi/NCR5380.c        |    5 +----
 drivers/scsi/aacraid/rkt.c    |    6 ++----
 drivers/scsi/aacraid/rx.c     |    6 ++----
 drivers/scsi/aacraid/sa.c     |    6 ++----
 drivers/scsi/dpt_i2o.c        |   34 +++++++++++-----------------------
 drivers/scsi/lpfc/lpfc_scsi.c |   12 ++++--------
 drivers/scsi/osst.c           |    9 +++------
 drivers/scsi/qla2xxx/qla_os.c |   11 ++++-------
 8 files changed, 29 insertions(+), 60 deletions(-)

diff -puN drivers/scsi/aacraid/rkt.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/aacraid/rkt.c
--- 25/drivers/scsi/aacraid/rkt.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/aacraid/rkt.c	Wed Aug 17 17:01:09 2005
@@ -166,8 +166,7 @@ static int rkt_sync_cmd(struct aac_dev *
 		/*
 		 *	Yield the processor in case we are slow 
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (ok != 1) {
 		/*
@@ -410,8 +409,7 @@ int aac_rkt_init(struct aac_dev *dev)
 					dev->name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (request_irq(dev->scsi_host_ptr->irq, aac_rkt_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 
 	{
diff -puN drivers/scsi/aacraid/rx.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/aacraid/rx.c
--- 25/drivers/scsi/aacraid/rx.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/aacraid/rx.c	Wed Aug 17 17:01:09 2005
@@ -166,8 +166,7 @@ static int rx_sync_cmd(struct aac_dev *d
 		/*
 		 *	Yield the processor in case we are slow 
 		 */
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (ok != 1) {
 		/*
@@ -410,8 +409,7 @@ int aac_rx_init(struct aac_dev *dev)
 					dev->name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	if (request_irq(dev->scsi_host_ptr->irq, aac_rx_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev)<0) 
 	{
diff -puN drivers/scsi/aacraid/sa.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/aacraid/sa.c
--- 25/drivers/scsi/aacraid/sa.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/aacraid/sa.c	Wed Aug 17 17:01:09 2005
@@ -189,8 +189,7 @@ static int sa_sync_cmd(struct aac_dev *d
 			ok = 1;
 			break;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if (ok != 1)
@@ -347,8 +346,7 @@ int aac_sa_init(struct aac_dev *dev)
 					name, instance, status);
 			goto error_iounmap;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if (request_irq(dev->scsi_host_ptr->irq, aac_sa_intr, SA_SHIRQ|SA_INTERRUPT, "aacraid", (void *)dev ) < 0) {
diff -puN drivers/scsi/dpt_i2o.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/dpt_i2o.c
--- 25/drivers/scsi/dpt_i2o.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/dpt_i2o.c	Wed Aug 17 17:01:09 2005
@@ -1218,8 +1218,7 @@ static s32 adpt_i2o_post_this(adpt_hba* 
 			printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m == EMPTY_QUEUE);
 		
 	msg = pHba->msg_addr_virt + m;
@@ -1294,8 +1293,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 			printk(KERN_WARNING"Timeout waiting for message!\n");
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (m == EMPTY_QUEUE);
 
 	status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32);
@@ -1327,8 +1325,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 			return -ETIMEDOUT;
 		}
 		rmb();
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	if(*status == 0x01 /*I2O_EXEC_IOP_RESET_IN_PROGRESS*/) {
@@ -1345,8 +1342,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* 
 				printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
 				return -ETIMEDOUT;
 			}
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1);
+			schedule_timeout_uninterruptible(1);
 		} while (m == EMPTY_QUEUE);
 		// Flush the offset
 		adpt_send_nop(pHba, m);
@@ -1917,11 +1913,8 @@ static int adpt_ioctl(struct inode *inod
 		return -ENXIO;
 	}
 
-	while((volatile u32) pHba->state & DPTI_STATE_RESET ) {
-		set_task_state(current,TASK_UNINTERRUPTIBLE);
-		schedule_timeout(2);
-
-	}
+	while((volatile u32) pHba->state & DPTI_STATE_RESET )
+		schedule_timeout_uninterruptible(2);
 
 	switch (cmd) {
 	// TODO: handle 3 cases
@@ -2635,8 +2628,7 @@ static s32 adpt_send_nop(adpt_hba*pHba,u
 			printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name);
 			return 2;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 	msg = (u32 __iomem *)(pHba->msg_addr_virt + m);
 	writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]);
@@ -2670,8 +2662,7 @@ static s32 adpt_i2o_init_outbound_q(adpt
 			printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m == EMPTY_QUEUE);
 
 	msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
@@ -2709,8 +2700,7 @@ static s32 adpt_i2o_init_outbound_q(adpt
 			printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while (1);
 
 	// If the command was successful, fill the fifo with our reply
@@ -2788,8 +2778,7 @@ static s32 adpt_i2o_status_get(adpt_hba*
 					pHba->name);
 			return -ETIMEDOUT;
 		}
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	} while(m==EMPTY_QUEUE);

@@ -2816,8 +2805,7 @@ static s32 adpt_i2o_status_get(adpt_hba*
 			return -ETIMEDOUT;
 		}
 		rmb();
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
+		schedule_timeout_uninterruptible(1);
 	}
 
 	// Set up our number of outbound and inbound messages
diff -puN drivers/scsi/lpfc/lpfc_scsi.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/lpfc/lpfc_scsi.c
--- 25/drivers/scsi/lpfc/lpfc_scsi.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/lpfc/lpfc_scsi.c	Wed Aug 17 17:01:09 2005
@@ -891,8 +891,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -958,8 +957,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			schedule_timeout_uninterruptible(msecs_to_jiffies(500));
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1017,8 +1015,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1116,8 +1113,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
diff -puN drivers/scsi/NCR5380.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/NCR5380.c
--- 25/drivers/scsi/NCR5380.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/NCR5380.c	Wed Aug 17 17:01:09 2005
@@ -599,10 +599,7 @@ static int __init NCR5380_probe_irq(stru
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
 
 	while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
-	{
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(1);
-	}
+		schedule_timeout_uninterruptible(1);
 	
 	NCR5380_write(SELECT_ENABLE_REG, 0);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
diff -puN drivers/scsi/osst.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/osst.c
--- 25/drivers/scsi/osst.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/osst.c	Wed Aug 17 17:01:09 2005
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp, aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			schedule_timeout_interruptible(HZ / OSST_POLL_PER_SEC);
 
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
 			memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(str
 			osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
 			flag = 0;
 			attempts--;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ / 10);
+			schedule_timeout_interruptible(msecs_to_jiffies(100));
 		}
 		if (osst_get_frame_position(STp, aSRpnt) < 0) {		/* additional write error */
 #if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(str
 			debugging = 0;
 		}
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ / 10);
+		schedule_timeout_interruptible(msecs_to_jiffies(100));
 	}
 	printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name);
 #if DEBUG
diff -puN drivers/scsi/qla2xxx/qla_os.c~drivers-scsi-fix-up-schedule_timeout-usage drivers/scsi/qla2xxx/qla_os.c
--- 25/drivers/scsi/qla2xxx/qla_os.c~drivers-scsi-fix-up-schedule_timeout-usage	Wed Aug 17 17:01:09 2005
+++ 25-akpm/drivers/scsi/qla2xxx/qla_os.c	Wed Aug 17 17:01:09 2005
@@ -1944,10 +1944,8 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 
 	/* Make sure all other threads are stopped. */
 	wtime = 60 * HZ;
-	while (ha->dpc_wait && wtime) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		wtime = schedule_timeout(wtime);
-	}
+	while (ha->dpc_wait && wtime)
+		wtime = schedule_timeout_interruptible(wtime);
 
 	/* free ioctl memory */
 	qla2x00_free_ioctl_mem(ha);
@@ -2478,13 +2476,12 @@ qla2x00_timer(scsi_qla_host_t *ha)
 int
 qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
 {
-	const unsigned int step = HZ/10;
+	const unsigned int step = msecs_to_jiffies(100);
 
 	do {
 		if (!down_trylock(sema))
 			return 0;
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(step))
+		if (schedule_timeout_interruptible(step))
 			break;
 	} while ((timeout -= step) > 0);
 
_