[PATCH 13/22] ide: add ide_do_test_unit_ready() helper

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bartlomiej Zolnierkiewicz
Date: Sunday, August 10, 2008 - 8:37 am

* Add ide_do_test_unit_ready() helper and convert ide-{floppy,tape}.c
  to use it.

* Remove no longer used idetape_create_test_unit_ready_cmd().

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-atapi.c  |   11 +++++++++++
 drivers/ide/ide-floppy.c |    6 +-----
 drivers/ide/ide-tape.c   |   10 +---------
 include/linux/ide.h      |    1 +
 4 files changed, 14 insertions(+), 14 deletions(-)

Index: b/drivers/ide/ide-atapi.c
===================================================================
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -162,6 +162,17 @@ int ide_queue_pc_tail(ide_drive_t *drive
 }
 EXPORT_SYMBOL_GPL(ide_queue_pc_tail);
 
+int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk)
+{
+	struct ide_atapi_pc pc;
+
+	ide_init_pc(&pc);
+	pc.c[0] = TEST_UNIT_READY;
+
+	return ide_queue_pc_tail(drive, disk, &pc);
+}
+EXPORT_SYMBOL_GPL(ide_do_test_unit_ready);
+
 int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start)
 {
 	struct ide_atapi_pc pc;
Index: b/drivers/ide/ide-floppy.c
===================================================================
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -772,7 +772,6 @@ static int idefloppy_open(struct inode *
 	struct gendisk *disk = inode->i_bdev->bd_disk;
 	struct ide_floppy_obj *floppy;
 	ide_drive_t *drive;
-	struct ide_atapi_pc pc;
 	int ret = 0;
 
 	debug_log("Reached %s\n", __func__);
@@ -789,10 +788,7 @@ static int idefloppy_open(struct inode *
 		drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
 		/* Just in case */
 
-		ide_init_pc(&pc);
-		pc.c[0] = GPCMD_TEST_UNIT_READY;
-
-		if (ide_queue_pc_tail(drive, disk, &pc))
+		if (ide_do_test_unit_ready(drive, disk))
 			ide_do_start_stop(drive, disk, 1);
 
 		if (ide_floppy_get_capacity(drive)
Index: b/drivers/ide/ide-tape.c
===================================================================
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1118,25 +1118,17 @@ static void idetape_create_write_filemar
 	pc->flags |= PC_FLAG_WAIT_FOR_DSC;
 }
 
-static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
-{
-	ide_init_pc(pc);
-	pc->c[0] = TEST_UNIT_READY;
-}
-
 static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
 {
 	idetape_tape_t *tape = drive->driver_data;
 	struct gendisk *disk = tape->disk;
-	struct ide_atapi_pc pc;
 	int load_attempted = 0;
 
 	/* Wait for the tape to become ready */
 	set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags);
 	timeout += jiffies;
 	while (time_before(jiffies, timeout)) {
-		idetape_create_test_unit_ready_cmd(&pc);
-		if (!ide_queue_pc_tail(drive, disk, &pc))
+		if (ide_do_test_unit_ready(drive, disk) == 0)
 			return 0;
 		if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2)
 		    || (tape->asc == 0x3A)) {
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1140,6 +1140,7 @@ void ide_queue_pc_head(ide_drive_t *, st
 		       struct request *);
 int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *);
 
+int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/22] ide: more work on generic ATAPI support, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:35 am)
[PATCH 01/22] ide-floppy: fixup ide_floppy_io_buffers(), Bartlomiej Zolnierki ..., (Sun Aug 10, 8:35 am)
[PATCH 02/22] ide-scsi: cleanup ide_scsi_io_buffers(), Bartlomiej Zolnierki ..., (Sun Aug 10, 8:35 am)
[PATCH 03/22] ide: add ide_io_buffers() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:35 am)
[PATCH 04/22] ide-floppy: add ide_floppy_set_media_lock() ..., Bartlomiej Zolnierki ..., (Sun Aug 10, 8:35 am)
[PATCH 05/22] ide-tape: add ide_tape_set_media_lock() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 06/22] ide: add ide_init_pc() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 07/22] ide: add ide_queue_pc_head() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 08/22] ide: add ide_queue_pc_tail() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 09/22] ide-floppy: -&gt;{srfp,wp} -&gt; IDE_AFLAG_{SRFP,WP}, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 10/22] ide-floppy: move floppy ioctls handling to i ..., Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 11/22] ide: add ide_set_media_lock() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 12/22] ide: add ide_do_start_stop() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:36 am)
[PATCH 13/22] ide: add ide_do_test_unit_ready() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 14/22] ide: move IDE{FLOPPY,TAPE}_WAIT_CMD defines ..., Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 15/22] ide: drop dsc_handle argument from ide_pc_intr(), Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 16/22] ide: add pointer to the current packet comma ..., Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 17/22] ide: drop 'timeout' and 'expiry' arguments f ..., Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 18/22] ide: add request_sense_{pc,rq} to ide_drive_t, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 19/22] ide: add ide_retry_pc() helper, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 20/22] ide: add -&gt;pc_{update,io}_buffers methods, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 21/22] ide: make ide_pc_intr() static, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:37 am)
[PATCH 22/22] ide: make ide_transfer_pc() static, Bartlomiej Zolnierki ..., (Sun Aug 10, 8:38 am)
Re: [PATCH 11/22] ide: add ide_set_media_lock() helper, Borislav Petkov, (Sun Aug 10, 11:02 pm)
Re: [PATCH 00/22] ide: more work on generic ATAPI support, Borislav Petkov, (Sun Aug 10, 11:36 pm)
Re: [PATCH 11/22] ide: add ide_set_media_lock() helper, Bartlomiej Zolnierki ..., (Tue Aug 12, 2:05 am)
Re: [PATCH 11/22] ide: add ide_set_media_lock() helper, Boris Petkov, (Tue Aug 12, 6:37 am)
Re: [PATCH 11/22] ide: add ide_set_media_lock() helper, Bartlomiej Zolnierki ..., (Tue Aug 12, 10:48 am)
Re: [PATCH 13/22] ide: add ide_do_test_unit_ready() helper, Sergei Shtylyov, (Sat Aug 23, 2:31 pm)
Re: [PATCH 07/22] ide: add ide_queue_pc_head() helper, Sergei Shtylyov, (Sat Aug 23, 2:57 pm)
Re: [PATCH 08/22] ide: add ide_queue_pc_tail() helper, Sergei Shtylyov, (Sat Aug 23, 2:58 pm)