diff options
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index ddce28e77a4e..de611c57b280 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -554,32 +554,13 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
554 | } | 554 | } |
555 | 555 | ||
556 | /* | 556 | /* |
557 | * Add a special packet command request to the tail of the request queue, | ||
558 | * and wait for it to be serviced. | ||
559 | */ | ||
560 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | ||
561 | { | ||
562 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
563 | struct request *rq; | ||
564 | int error; | ||
565 | |||
566 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
567 | rq->buffer = (char *) pc; | ||
568 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
569 | memcpy(rq->cmd, pc->c, 12); | ||
570 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); | ||
571 | blk_put_request(rq); | ||
572 | |||
573 | return error; | ||
574 | } | ||
575 | |||
576 | /* | ||
577 | * Look at the flexible disk page parameters. We ignore the CHS capacity | 557 | * Look at the flexible disk page parameters. We ignore the CHS capacity |
578 | * parameters and use the LBA parameters instead. | 558 | * parameters and use the LBA parameters instead. |
579 | */ | 559 | */ |
580 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | 560 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) |
581 | { | 561 | { |
582 | idefloppy_floppy_t *floppy = drive->driver_data; | 562 | idefloppy_floppy_t *floppy = drive->driver_data; |
563 | struct gendisk *disk = floppy->disk; | ||
583 | struct ide_atapi_pc pc; | 564 | struct ide_atapi_pc pc; |
584 | u8 *page; | 565 | u8 *page; |
585 | int capacity, lba_capacity; | 566 | int capacity, lba_capacity; |
@@ -588,13 +569,13 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
588 | 569 | ||
589 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); | 570 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); |
590 | 571 | ||
591 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 572 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
592 | printk(KERN_ERR "ide-floppy: Can't get flexible disk page" | 573 | printk(KERN_ERR "ide-floppy: Can't get flexible disk page" |
593 | " parameters\n"); | 574 | " parameters\n"); |
594 | return 1; | 575 | return 1; |
595 | } | 576 | } |
596 | floppy->wp = !!(pc.buf[3] & 0x80); | 577 | floppy->wp = !!(pc.buf[3] & 0x80); |
597 | set_disk_ro(floppy->disk, floppy->wp); | 578 | set_disk_ro(disk, floppy->wp); |
598 | page = &pc.buf[8]; | 579 | page = &pc.buf[8]; |
599 | 580 | ||
600 | transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); | 581 | transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); |
@@ -638,7 +619,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
638 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); | 619 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); |
639 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; | 620 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; |
640 | 621 | ||
641 | if (idefloppy_queue_pc_tail(drive, &pc)) | 622 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) |
642 | return 1; | 623 | return 1; |
643 | 624 | ||
644 | floppy->srfp = pc.buf[8 + 2] & 0x40; | 625 | floppy->srfp = pc.buf[8 + 2] & 0x40; |
@@ -652,6 +633,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
652 | static int ide_floppy_get_capacity(ide_drive_t *drive) | 633 | static int ide_floppy_get_capacity(ide_drive_t *drive) |
653 | { | 634 | { |
654 | idefloppy_floppy_t *floppy = drive->driver_data; | 635 | idefloppy_floppy_t *floppy = drive->driver_data; |
636 | struct gendisk *disk = floppy->disk; | ||
655 | struct ide_atapi_pc pc; | 637 | struct ide_atapi_pc pc; |
656 | u8 *cap_desc; | 638 | u8 *cap_desc; |
657 | u8 header_len, desc_cnt; | 639 | u8 header_len, desc_cnt; |
@@ -664,7 +646,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
664 | set_capacity(floppy->disk, 0); | 646 | set_capacity(floppy->disk, 0); |
665 | 647 | ||
666 | idefloppy_create_read_capacity_cmd(&pc); | 648 | idefloppy_create_read_capacity_cmd(&pc); |
667 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 649 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
668 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 650 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
669 | return 1; | 651 | return 1; |
670 | } | 652 | } |
@@ -739,7 +721,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
739 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | 721 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
740 | (void) ide_floppy_get_flexible_disk_page(drive); | 722 | (void) ide_floppy_get_flexible_disk_page(drive); |
741 | 723 | ||
742 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); | 724 | set_capacity(disk, floppy->blocks * floppy->bs_factor); |
725 | |||
743 | return rc; | 726 | return rc; |
744 | } | 727 | } |
745 | 728 | ||
@@ -764,6 +747,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
764 | 747 | ||
765 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | 748 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) |
766 | { | 749 | { |
750 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
767 | struct ide_atapi_pc pc; | 751 | struct ide_atapi_pc pc; |
768 | u8 header_len, desc_cnt; | 752 | u8 header_len, desc_cnt; |
769 | int i, blocks, length, u_array_size, u_index; | 753 | int i, blocks, length, u_array_size, u_index; |
@@ -776,7 +760,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
776 | return -EINVAL; | 760 | return -EINVAL; |
777 | 761 | ||
778 | idefloppy_create_read_capacity_cmd(&pc); | 762 | idefloppy_create_read_capacity_cmd(&pc); |
779 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 763 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) { |
780 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 764 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
781 | return -EIO; | 765 | return -EIO; |
782 | } | 766 | } |
@@ -838,7 +822,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
838 | 822 | ||
839 | if (floppy->srfp) { | 823 | if (floppy->srfp) { |
840 | idefloppy_create_request_sense_cmd(&pc); | 824 | idefloppy_create_request_sense_cmd(&pc); |
841 | if (idefloppy_queue_pc_tail(drive, &pc)) | 825 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) |
842 | return -EIO; | 826 | return -EIO; |
843 | 827 | ||
844 | if (floppy->sense_key == 2 && | 828 | if (floppy->sense_key == 2 && |
@@ -1008,12 +992,13 @@ static ide_driver_t idefloppy_driver = { | |||
1008 | 992 | ||
1009 | static void ide_floppy_set_media_lock(ide_drive_t *drive, int on) | 993 | static void ide_floppy_set_media_lock(ide_drive_t *drive, int on) |
1010 | { | 994 | { |
995 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
1011 | struct ide_atapi_pc pc; | 996 | struct ide_atapi_pc pc; |
1012 | 997 | ||
1013 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 998 | /* IOMEGA Clik! drives do not support lock/unlock commands */ |
1014 | if ((drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE) == 0) { | 999 | if ((drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE) == 0) { |
1015 | idefloppy_create_prevent_cmd(&pc, on); | 1000 | idefloppy_create_prevent_cmd(&pc, on); |
1016 | (void)idefloppy_queue_pc_tail(drive, &pc); | 1001 | (void)ide_queue_pc_tail(drive, floppy->disk, &pc); |
1017 | } | 1002 | } |
1018 | } | 1003 | } |
1019 | 1004 | ||
@@ -1042,9 +1027,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1042 | ide_init_pc(&pc); | 1027 | ide_init_pc(&pc); |
1043 | pc.c[0] = GPCMD_TEST_UNIT_READY; | 1028 | pc.c[0] = GPCMD_TEST_UNIT_READY; |
1044 | 1029 | ||
1045 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 1030 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
1046 | idefloppy_create_start_stop_cmd(&pc, 1); | 1031 | idefloppy_create_start_stop_cmd(&pc, 1); |
1047 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1032 | (void)ide_queue_pc_tail(drive, disk, &pc); |
1048 | } | 1033 | } |
1049 | 1034 | ||
1050 | if (ide_floppy_get_capacity(drive) | 1035 | if (ide_floppy_get_capacity(drive) |
@@ -1123,7 +1108,7 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
1123 | 1108 | ||
1124 | if (cmd == CDROMEJECT) { | 1109 | if (cmd == CDROMEJECT) { |
1125 | idefloppy_create_start_stop_cmd(pc, 2); | 1110 | idefloppy_create_start_stop_cmd(pc, 2); |
1126 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | 1111 | (void)ide_queue_pc_tail(drive, floppy->disk, pc); |
1127 | } | 1112 | } |
1128 | 1113 | ||
1129 | return 0; | 1114 | return 0; |
@@ -1168,7 +1153,7 @@ static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) | |||
1168 | (void) idefloppy_get_sfrp_bit(drive); | 1153 | (void) idefloppy_get_sfrp_bit(drive); |
1169 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); | 1154 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); |
1170 | 1155 | ||
1171 | if (idefloppy_queue_pc_tail(drive, &pc)) | 1156 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) |
1172 | err = -EIO; | 1157 | err = -EIO; |
1173 | 1158 | ||
1174 | out: | 1159 | out: |