Skip to contentSkip to conversation

ide: use wait_drive_not_busy() in drive_cmd_intr()

PATCH In review Bartlomiej Zolnierkiewicz 2 participants 3 messages Dec 9, 2007 – Dec 12, 2007 libata

lore
Share & tools
lore
#0 lore raw

PATCH 12/20 ide: use wait_drive_not_busy() in drive_cmd_intr()

---
 drivers/ide/ide-io.c       |    4 +---
 drivers/ide/ide-taskfile.c |    2 +-
 include/linux/ide.h        |    2 ++
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/ide/ide-io.c +1 -3
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -640,7 +640,6 @@ static ide_startstop_t drive_cmd_intr (i
 	ide_hwif_t *hwif = HWIF(drive);
 	u8 *args = (u8 *) rq->buffer;
 	u8 stat = hwif->INB(IDE_STATUS_REG);
-	int retries = 10;
 
 	local_irq_enable_in_hardirq();
 	if (rq->cmd_type == REQ_TYPE_ATA_CMD &&
@@ -649,8 +648,7 @@ static ide_startstop_t drive_cmd_intr (i
 		drive->io_32bit = 0;
 		hwif->ata_input_data(drive, &args[4], args[3] * SECTOR_WORDS);
 		drive->io_32bit = io_32bit;
-		while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
-			udelay(100);
+		stat = wait_drive_not_busy(drive);
 	}
 
 	if (!OK_STAT(stat, READY_STAT, BAD_STAT))
drivers/ide/ide-taskfile.c +1 -1
Index: b/drivers/ide/ide-taskfile.c
===================================================================
@@ -260,7 +260,7 @@ static ide_startstop_t task_no_data_intr
 	return ide_stopped;
 }
 
-static u8 wait_drive_not_busy(ide_drive_t *drive)
+u8 wait_drive_not_busy(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	int retries;
include/linux/ide.h +2 -0
Index: b/include/linux/ide.h
===================================================================
@@ -994,6 +994,8 @@ ide_startstop_t do_rw_taskfile(ide_drive
 
 void task_end_request(ide_drive_t *, struct request *, u8);
 
+u8 wait_drive_not_busy(ide_drive_t *);
+
 int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
 int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
 
Acked-by on v1 12/20
#1 lore raw
Quoted 1 line · Bartlomiej Zolnierkiewicz

drivers/ide/ide-taskfile.c static ide_startstop_t task_no_data_intr · line 266

Quoted 13 lines

Index: b/drivers/ide/ide-taskfile.c
===================================================================

drivers/ide/ide-taskfile.c +1 -1
@@ -260,7 +260,7 @@ static ide_startstop_t task_no_data_intr
 	return ide_stopped;
 }
 
-static u8 wait_drive_not_busy(ide_drive_t *drive)
+u8 wait_drive_not_busy(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	int retries;

I think you should remove the comment line below:

* (drive_cmd_intr waits that long).

MBR, Sergei

author Acked-by Sergei Shtylyov
#2 lore raw
Quoted 22 lines · Sergei Shtylyov
Quoted 1 line · Bartlomiej Zolnierkiewicz

drivers/ide/ide-taskfile.c static ide_startstop_t task_no_data_intr · line 266

Quoted 13 lines

Index: b/drivers/ide/ide-taskfile.c
===================================================================

drivers/ide/ide-taskfile.c +1 -1
@@ -260,7 +260,7 @@ static ide_startstop_t task_no_data_intr
 	return ide_stopped;
 }
 
-static u8 wait_drive_not_busy(ide_drive_t *drive)
+u8 wait_drive_not_busy(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	int retries;

I think you should remove the comment line below:

Quoted 1 line

* (drive_cmd_intr waits that long).

Done.

[PATCH] ide: use wait_drive_not_busy() in drive_cmd_intr() (take 2)

Use wait_drive_not_busy() in drive_cmd_intr().

v2:
* Fix wait_drive_not_busy() comment (noticed by Sergei).

---
 drivers/ide/ide-io.c       |    4 +---
 drivers/ide/ide-taskfile.c |    5 ++---
 include/linux/ide.h        |    2 ++
 3 files changed, 5 insertions(+), 6 deletions(-)
drivers/ide/ide-io.c +1 -3
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -640,7 +640,6 @@ static ide_startstop_t drive_cmd_intr (i
 	ide_hwif_t *hwif = HWIF(drive);
 	u8 *args = (u8 *) rq->buffer;
 	u8 stat = hwif->INB(IDE_STATUS_REG);
-	int retries = 10;
 
 	local_irq_enable_in_hardirq();
 	if (rq->cmd_type == REQ_TYPE_ATA_CMD &&
@@ -649,8 +648,7 @@ static ide_startstop_t drive_cmd_intr (i
 		drive->io_32bit = 0;
 		hwif->ata_input_data(drive, &args[4], args[3] * SECTOR_WORDS);
 		drive->io_32bit = io_32bit;
-		while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
-			udelay(100);
+		stat = wait_drive_not_busy(drive);
 	}
 
 	if (!OK_STAT(stat, READY_STAT, BAD_STAT))
drivers/ide/ide-taskfile.c +2 -3
Index: b/drivers/ide/ide-taskfile.c
===================================================================
@@ -260,7 +260,7 @@ static ide_startstop_t task_no_data_intr
 	return ide_stopped;
 }
 
-static u8 wait_drive_not_busy(ide_drive_t *drive)
+u8 wait_drive_not_busy(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
 	int retries;
@@ -268,8 +268,7 @@ static u8 wait_drive_not_busy(ide_drive_
 
 	/*
 	 * Last sector was transfered, wait until drive is ready.
-	 * This can take up to 10 usec, but we will wait max 1 ms
-	 * (drive_cmd_intr() waits that long).
+	 * This can take up to 10 usec, but we will wait max 1 ms.
 	 */
 	for (retries = 0; retries < 100; retries++) {
 		if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT)
include/linux/ide.h +2 -0
Index: b/include/linux/ide.h
===================================================================
@@ -994,6 +994,8 @@ ide_startstop_t do_rw_taskfile(ide_drive
 
 void task_end_request(ide_drive_t *, struct request *, u8);
 
+u8 wait_drive_not_busy(ide_drive_t *);
+
 int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
 int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);