aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-15 15:21:54 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-15 15:21:54 -0400
commit0b2eea4c5594ceaf13c57eaff7ff226263f1c36f (patch)
tree5ec03a9ae0ae904e5115712b957e957ed4edd165
parent170ee569bbe1005baebf2e9e4c3f4622d14ec851 (diff)
ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
* Check IDEFLOPPY_FLAG_ZIP_DRIVE flag in idefloppy_transfer_pc1() and skip idefloppy_transfer_pc2()-phase if the flag is not set. * Always use idefloppy_transfer_pc1() in idefloppy_issue_pc() and remove no longer needed idefloppy_transfer_pc(). There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-floppy.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 53209a473937..8dbb340dbfc0 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -522,40 +522,6 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
522} 522}
523 523
524/* 524/*
525 * This is the original routine that did the packet transfer.
526 * It fails at high speeds on the Iomega ZIP drive, so there's a slower version
527 * for that drive below. The algorithm is chosen based on drive type
528 */
529static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
530{
531 ide_hwif_t *hwif = drive->hwif;
532 ide_startstop_t startstop;
533 idefloppy_floppy_t *floppy = drive->driver_data;
534 u8 ireason;
535
536 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
537 printk(KERN_ERR "ide-floppy: Strange, packet command "
538 "initiated yet DRQ isn't asserted\n");
539 return startstop;
540 }
541 ireason = hwif->INB(hwif->io_ports.nsect_addr);
542 if ((ireason & CD) == 0 || (ireason & IO)) {
543 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
544 "issuing a packet command\n");
545 return ide_do_reset(drive);
546 }
547
548 /* Set the interrupt routine */
549 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
550
551 /* Send the actual packet */
552 hwif->output_data(drive, NULL, floppy->pc->c, 12);
553
554 return ide_started;
555}
556
557
558/*
559 * What we have here is a classic case of a top half / bottom half interrupt 525 * What we have here is a classic case of a top half / bottom half interrupt
560 * service routine. In interrupt mode, the device sends an interrupt to signal 526 * service routine. In interrupt mode, the device sends an interrupt to signal
561 * that it is ready to receive a packet. However, we need to delay about 2-3 527 * that it is ready to receive a packet. However, we need to delay about 2-3
@@ -580,6 +546,8 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
580{ 546{
581 ide_hwif_t *hwif = drive->hwif; 547 ide_hwif_t *hwif = drive->hwif;
582 idefloppy_floppy_t *floppy = drive->driver_data; 548 idefloppy_floppy_t *floppy = drive->driver_data;
549 ide_expiry_t *expiry;
550 unsigned int timeout;
583 ide_startstop_t startstop; 551 ide_startstop_t startstop;
584 u8 ireason; 552 u8 ireason;
585 553
@@ -602,9 +570,20 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
602 * 40 and 50msec work well. idefloppy_pc_intr will not be actually 570 * 40 and 50msec work well. idefloppy_pc_intr will not be actually
603 * used until after the packet is moved in about 50 msec. 571 * used until after the packet is moved in about 50 msec.
604 */ 572 */
573 if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) {
574 timeout = floppy->ticks;
575 expiry = &idefloppy_transfer_pc2;
576 } else {
577 timeout = IDEFLOPPY_WAIT_CMD;
578 expiry = NULL;
579 }
580
581 ide_set_handler(drive, &idefloppy_pc_intr, timeout, expiry);
582
583 if ((floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) == 0)
584 /* Send the actual packet */
585 hwif->output_data(drive, NULL, floppy->pc->c, 12);
605 586
606 ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks,
607 &idefloppy_transfer_pc2);
608 return ide_started; 587 return ide_started;
609} 588}
610 589
@@ -629,7 +608,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
629{ 608{
630 idefloppy_floppy_t *floppy = drive->driver_data; 609 idefloppy_floppy_t *floppy = drive->driver_data;
631 ide_hwif_t *hwif = drive->hwif; 610 ide_hwif_t *hwif = drive->hwif;
632 ide_handler_t *pkt_xfer_routine;
633 u16 bcount; 611 u16 bcount;
634 u8 dma; 612 u8 dma;
635 613
@@ -675,26 +653,17 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
675 hwif->dma_ops->dma_start(drive); 653 hwif->dma_ops->dma_start(drive);
676 } 654 }
677 655
678 /* Can we transfer the packet when we get the interrupt or wait? */
679 if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) {
680 /* wait */
681 pkt_xfer_routine = &idefloppy_transfer_pc1;
682 } else {
683 /* immediate */
684 pkt_xfer_routine = &idefloppy_transfer_pc;
685 }
686
687 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { 656 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) {
688 /* Issue the packet command */ 657 /* Issue the packet command */
689 ide_execute_command(drive, WIN_PACKETCMD, 658 ide_execute_command(drive, WIN_PACKETCMD,
690 pkt_xfer_routine, 659 &idefloppy_transfer_pc1,
691 IDEFLOPPY_WAIT_CMD, 660 IDEFLOPPY_WAIT_CMD,
692 NULL); 661 NULL);
693 return ide_started; 662 return ide_started;
694 } else { 663 } else {
695 /* Issue the packet command */ 664 /* Issue the packet command */
696 ide_execute_pkt_cmd(drive); 665 ide_execute_pkt_cmd(drive);
697 return (*pkt_xfer_routine) (drive); 666 return idefloppy_transfer_pc1(drive);
698 } 667 }
699} 668}
700 669