ide: add ide_execute_pkt_cmd() helper
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 28 Apr 2008 21:44:39 +0000 (23:44 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 28 Apr 2008 21:44:39 +0000 (23:44 +0200)
Add ide_execute_pkt_cmd() helper for executing PACKET command,
then convert ATAPI device drivers to use it.

As a nice side-effect this fixes ide-{floppy,tape,scsi} w.r.t.
ide_lock taking (ide-cd was OK).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-cd.c
drivers/ide/ide-floppy.c
drivers/ide/ide-iops.c
drivers/ide/ide-tape.c
drivers/scsi/ide-scsi.c
include/linux/ide.h

index 095e50a93869170efce20a3caf305b7ab57f1d43..0881ddc5831ebf4d7a9a7532736e07e66335b626 100644 (file)
@@ -555,14 +555,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
                                    ATAPI_WAIT_PC, cdrom_timer_expiry);
                return ide_started;
        } else {
-               unsigned long flags;
-
-               /* packet command */
-               spin_lock_irqsave(&ide_lock, flags);
-               hwif->OUTBSYNC(drive, WIN_PACKETCMD,
-                              hwif->io_ports.command_addr);
-               ndelay(400);
-               spin_unlock_irqrestore(&ide_lock, flags);
+               ide_execute_pkt_cmd(drive);
 
                return (*handler) (drive);
        }
index da79248633a470abed7d9c9bd350bf966c77c68f..0039789b0eb985679f2c3379e7f08078ad186354 100644 (file)
@@ -696,9 +696,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
                return ide_started;
        } else {
                /* Issue the packet command */
-               hwif->OUTBSYNC(drive, WIN_PACKETCMD,
-                              hwif->io_ports.command_addr);
-               ndelay(400);
+               ide_execute_pkt_cmd(drive);
                return (*pkt_xfer_routine) (drive);
        }
 }
index 7f2b4edc63699101a392924c9bc4c3a30ea30c8b..dfe47d5eb157555986a9b8055bf17704bb118ce2 100644 (file)
@@ -801,9 +801,19 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
        ndelay(400);
        spin_unlock_irqrestore(&ide_lock, flags);
 }
-
 EXPORT_SYMBOL(ide_execute_command);
 
+void ide_execute_pkt_cmd(ide_drive_t *drive)
+{
+       ide_hwif_t *hwif = drive->hwif;
+       unsigned long flags;
+
+       spin_lock_irqsave(&ide_lock, flags);
+       hwif->OUTBSYNC(drive, WIN_PACKETCMD, hwif->io_ports.command_addr);
+       ndelay(400);
+       spin_unlock_irqrestore(&ide_lock, flags);
+}
+EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
 
 /* needed below */
 static ide_startstop_t do_reset1 (ide_drive_t *, int);
index dc88431a23599b80bcefec6dcb3d9b47dbe1e8ce..71d07d740add2b12645b351af7215c26ace6caa3 100644 (file)
@@ -1056,9 +1056,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
                                    IDETAPE_WAIT_CMD, NULL);
                return ide_started;
        } else {
-               hwif->OUTBSYNC(drive, WIN_PACKETCMD,
-                              hwif->io_ports.command_addr);
-               ndelay(400);
+               ide_execute_pkt_cmd(drive);
                return idetape_transfer_pc(drive);
        }
 }
index 8b1c783e259b2ef53f86b2d7140d0d7717b7c9e9..7964cc146152dfb2e464cc4d63143938224e0cab 100644 (file)
@@ -574,9 +574,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
                return ide_started;
        } else {
                /* Issue the packet command */
-               hwif->OUTBSYNC(drive, WIN_PACKETCMD,
-                              hwif->io_ports.command_addr);
-               ndelay(400);
+               ide_execute_pkt_cmd(drive);
                return idescsi_transfer_pc(drive);
        }
 }
index 5ab9773b75fbcb110c67d1f1216f0cd835f542f1..3927996d2f82c29a48a17abfd6509ff6c45870dc 100644 (file)
@@ -822,6 +822,8 @@ extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigne
 void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int,
                         ide_expiry_t *);
 
+void ide_execute_pkt_cmd(ide_drive_t *);
+
 ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
 
 ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);