diff options
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index d8fdd865dea9..717e114ced52 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -201,7 +201,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
201 | 201 | ||
202 | memset(&task, 0, sizeof(task)); | 202 | memset(&task, 0, sizeof(task)); |
203 | task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ | 203 | task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ |
204 | task.tf_flags |= (IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE); | 204 | task.tf_flags |= (IDE_TFLAG_TF | IDE_TFLAG_DEVICE); |
205 | 205 | ||
206 | if (drive->select.b.lba) { | 206 | if (drive->select.b.lba) { |
207 | if (lba48) { | 207 | if (lba48) { |
@@ -219,13 +219,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
219 | tf->lbal = (u8) block; | 219 | tf->lbal = (u8) block; |
220 | tf->lbam = (u8)(block >> 8); | 220 | tf->lbam = (u8)(block >> 8); |
221 | tf->lbah = (u8)(block >> 16); | 221 | tf->lbah = (u8)(block >> 16); |
222 | #ifdef DEBUG | 222 | |
223 | printk("%s: 0x%02x%02x 0x%02x%02x%02x%02x%02x%02x\n", | 223 | task.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); |
224 | drive->name, tf->hob_nsect, tf->nsect, | ||
225 | tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, | ||
226 | tf->lbah, tf->lbam, tf->lbal); | ||
227 | #endif | ||
228 | task.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); | ||
229 | } else { | 224 | } else { |
230 | tf->nsect = nsectors & 0xff; | 225 | tf->nsect = nsectors & 0xff; |
231 | tf->lbal = block; | 226 | tf->lbal = block; |
@@ -319,9 +314,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) | |||
319 | else | 314 | else |
320 | tf->command = WIN_READ_NATIVE_MAX; | 315 | tf->command = WIN_READ_NATIVE_MAX; |
321 | tf->device = ATA_LBA; | 316 | tf->device = ATA_LBA; |
322 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 317 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
323 | if (lba48) | 318 | if (lba48) |
324 | args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); | 319 | args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); |
325 | /* submit command request */ | 320 | /* submit command request */ |
326 | ide_no_data_taskfile(drive, &args); | 321 | ide_no_data_taskfile(drive, &args); |
327 | 322 | ||
@@ -358,9 +353,9 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) | |||
358 | tf->command = WIN_SET_MAX; | 353 | tf->command = WIN_SET_MAX; |
359 | } | 354 | } |
360 | tf->device |= ATA_LBA; | 355 | tf->device |= ATA_LBA; |
361 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 356 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
362 | if (lba48) | 357 | if (lba48) |
363 | args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_OUT_HOB); | 358 | args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_HOB); |
364 | /* submit command request */ | 359 | /* submit command request */ |
365 | ide_no_data_taskfile(drive, &args); | 360 | ide_no_data_taskfile(drive, &args); |
366 | /* if OK, compute maximum address value */ | 361 | /* if OK, compute maximum address value */ |
@@ -500,7 +495,7 @@ static int smart_enable(ide_drive_t *drive) | |||
500 | tf->lbam = SMART_LCYL_PASS; | 495 | tf->lbam = SMART_LCYL_PASS; |
501 | tf->lbah = SMART_HCYL_PASS; | 496 | tf->lbah = SMART_HCYL_PASS; |
502 | tf->command = WIN_SMART; | 497 | tf->command = WIN_SMART; |
503 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 498 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
504 | return ide_no_data_taskfile(drive, &args); | 499 | return ide_no_data_taskfile(drive, &args); |
505 | } | 500 | } |
506 | 501 | ||
@@ -515,7 +510,7 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) | |||
515 | tf->lbam = SMART_LCYL_PASS; | 510 | tf->lbam = SMART_LCYL_PASS; |
516 | tf->lbah = SMART_HCYL_PASS; | 511 | tf->lbah = SMART_HCYL_PASS; |
517 | tf->command = WIN_SMART; | 512 | tf->command = WIN_SMART; |
518 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 513 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
519 | args.data_phase = TASKFILE_IN; | 514 | args.data_phase = TASKFILE_IN; |
520 | (void) smart_enable(drive); | 515 | (void) smart_enable(drive); |
521 | return ide_raw_taskfile(drive, &args, buf, 1); | 516 | return ide_raw_taskfile(drive, &args, buf, 1); |
@@ -625,8 +620,10 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
625 | 620 | ||
626 | if (drive->special.b.set_multmode) | 621 | if (drive->special.b.set_multmode) |
627 | return -EBUSY; | 622 | return -EBUSY; |
623 | |||
628 | ide_init_drive_cmd (&rq); | 624 | ide_init_drive_cmd (&rq); |
629 | rq.cmd_type = REQ_TYPE_ATA_CMD; | 625 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; |
626 | |||
630 | drive->mult_req = arg; | 627 | drive->mult_req = arg; |
631 | drive->special.b.set_multmode = 1; | 628 | drive->special.b.set_multmode = 1; |
632 | (void) ide_do_drive_cmd (drive, &rq, ide_wait); | 629 | (void) ide_do_drive_cmd (drive, &rq, ide_wait); |
@@ -694,7 +691,7 @@ static int write_cache(ide_drive_t *drive, int arg) | |||
694 | args.tf.feature = arg ? | 691 | args.tf.feature = arg ? |
695 | SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; | 692 | SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; |
696 | args.tf.command = WIN_SETFEATURES; | 693 | args.tf.command = WIN_SETFEATURES; |
697 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 694 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
698 | err = ide_no_data_taskfile(drive, &args); | 695 | err = ide_no_data_taskfile(drive, &args); |
699 | if (err == 0) | 696 | if (err == 0) |
700 | drive->wcache = arg; | 697 | drive->wcache = arg; |
@@ -714,7 +711,7 @@ static int do_idedisk_flushcache (ide_drive_t *drive) | |||
714 | args.tf.command = WIN_FLUSH_CACHE_EXT; | 711 | args.tf.command = WIN_FLUSH_CACHE_EXT; |
715 | else | 712 | else |
716 | args.tf.command = WIN_FLUSH_CACHE; | 713 | args.tf.command = WIN_FLUSH_CACHE; |
717 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 714 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
718 | return ide_no_data_taskfile(drive, &args); | 715 | return ide_no_data_taskfile(drive, &args); |
719 | } | 716 | } |
720 | 717 | ||
@@ -729,7 +726,7 @@ static int set_acoustic (ide_drive_t *drive, int arg) | |||
729 | args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; | 726 | args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; |
730 | args.tf.nsect = arg; | 727 | args.tf.nsect = arg; |
731 | args.tf.command = WIN_SETFEATURES; | 728 | args.tf.command = WIN_SETFEATURES; |
732 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | 729 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
733 | ide_no_data_taskfile(drive, &args); | 730 | ide_no_data_taskfile(drive, &args); |
734 | drive->acoustic = arg; | 731 | drive->acoustic = arg; |
735 | return 0; | 732 | return 0; |
@@ -766,7 +763,6 @@ static void idedisk_add_settings(ide_drive_t *drive) | |||
766 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); | 763 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); |
767 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); | 764 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); |
768 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, &drive->addressing, set_lba_addressing); | 765 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, &drive->addressing, set_lba_addressing); |
769 | ide_add_setting(drive, "bswap", SETTING_READ, TYPE_BYTE, 0, 1, 1, 1, &drive->bswap, NULL); | ||
770 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, id->max_multsect, 1, 1, &drive->mult_count, set_multcount); | 766 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, id->max_multsect, 1, 1, &drive->mult_count, set_multcount); |
771 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr); | 767 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr); |
772 | ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL); | 768 | ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL); |
@@ -975,6 +971,17 @@ static ide_driver_t idedisk_driver = { | |||
975 | #endif | 971 | #endif |
976 | }; | 972 | }; |
977 | 973 | ||
974 | static int idedisk_set_doorlock(ide_drive_t *drive, int on) | ||
975 | { | ||
976 | ide_task_t task; | ||
977 | |||
978 | memset(&task, 0, sizeof(task)); | ||
979 | task.tf.command = on ? WIN_DOORLOCK : WIN_DOORUNLOCK; | ||
980 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
981 | |||
982 | return ide_no_data_taskfile(drive, &task); | ||
983 | } | ||
984 | |||
978 | static int idedisk_open(struct inode *inode, struct file *filp) | 985 | static int idedisk_open(struct inode *inode, struct file *filp) |
979 | { | 986 | { |
980 | struct gendisk *disk = inode->i_bdev->bd_disk; | 987 | struct gendisk *disk = inode->i_bdev->bd_disk; |
@@ -989,17 +996,13 @@ static int idedisk_open(struct inode *inode, struct file *filp) | |||
989 | idkp->openers++; | 996 | idkp->openers++; |
990 | 997 | ||
991 | if (drive->removable && idkp->openers == 1) { | 998 | if (drive->removable && idkp->openers == 1) { |
992 | ide_task_t args; | ||
993 | memset(&args, 0, sizeof(ide_task_t)); | ||
994 | args.tf.command = WIN_DOORLOCK; | ||
995 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | ||
996 | check_disk_change(inode->i_bdev); | 999 | check_disk_change(inode->i_bdev); |
997 | /* | 1000 | /* |
998 | * Ignore the return code from door_lock, | 1001 | * Ignore the return code from door_lock, |
999 | * since the open() has already succeeded, | 1002 | * since the open() has already succeeded, |
1000 | * and the door_lock is irrelevant at this point. | 1003 | * and the door_lock is irrelevant at this point. |
1001 | */ | 1004 | */ |
1002 | if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) | 1005 | if (drive->doorlocking && idedisk_set_doorlock(drive, 1)) |
1003 | drive->doorlocking = 0; | 1006 | drive->doorlocking = 0; |
1004 | } | 1007 | } |
1005 | return 0; | 1008 | return 0; |
@@ -1015,11 +1018,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) | |||
1015 | ide_cacheflush_p(drive); | 1018 | ide_cacheflush_p(drive); |
1016 | 1019 | ||
1017 | if (drive->removable && idkp->openers == 1) { | 1020 | if (drive->removable && idkp->openers == 1) { |
1018 | ide_task_t args; | 1021 | if (drive->doorlocking && idedisk_set_doorlock(drive, 0)) |
1019 | memset(&args, 0, sizeof(ide_task_t)); | ||
1020 | args.tf.command = WIN_DOORUNLOCK; | ||
1021 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | ||
1022 | if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) | ||
1023 | drive->doorlocking = 0; | 1022 | drive->doorlocking = 0; |
1024 | } | 1023 | } |
1025 | 1024 | ||