diff options
author | Albert Lee <albertcc@tw.ibm.com> | 2005-10-12 03:04:18 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-18 17:16:13 -0400 |
commit | 07506697d1c615924298406f2357810709c09bcd (patch) | |
tree | bd4f223231a92245b8247c6fb8eb23d9b5c3f3be /drivers/scsi/libata-scsi.c | |
parent | 5a476deff3d17093da39c4eccb2692ba714dcb11 (diff) |
[PATCH] libata CHS: move the initialization of taskfile LBA flags (revise #6)
move the initialization of taskfile LBA flags
"ATA_TFLAG_LBA" and "ATA_TFLAG_LBA48 flags"
to the SCSI translation functions
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
=============
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/scsi/libata-scsi.c')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index c64169ca7ff0..ea7a4d8a6fc9 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -492,7 +492,7 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
492 | tf->flags |= ATA_TFLAG_DEVICE; | 492 | tf->flags |= ATA_TFLAG_DEVICE; |
493 | tf->protocol = ATA_PROT_NODATA; | 493 | tf->protocol = ATA_PROT_NODATA; |
494 | 494 | ||
495 | if ((tf->flags & ATA_TFLAG_LBA48) && | 495 | if ((qc->dev->flags & ATA_DFLAG_LBA48) && |
496 | (ata_id_has_flush_ext(qc->dev->id))) | 496 | (ata_id_has_flush_ext(qc->dev->id))) |
497 | tf->command = ATA_CMD_FLUSH_EXT; | 497 | tf->command = ATA_CMD_FLUSH_EXT; |
498 | else | 498 | else |
@@ -612,8 +612,6 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
612 | { | 612 | { |
613 | struct ata_taskfile *tf = &qc->tf; | 613 | struct ata_taskfile *tf = &qc->tf; |
614 | struct ata_device *dev = qc->dev; | 614 | struct ata_device *dev = qc->dev; |
615 | unsigned int lba = tf->flags & ATA_TFLAG_LBA; | ||
616 | unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48; | ||
617 | u64 dev_sectors = qc->dev->n_sectors; | 615 | u64 dev_sectors = qc->dev->n_sectors; |
618 | u64 block; | 616 | u64 block; |
619 | u32 n_block; | 617 | u32 n_block; |
@@ -634,16 +632,16 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
634 | goto out_of_range; | 632 | goto out_of_range; |
635 | if ((block + n_block) > dev_sectors) | 633 | if ((block + n_block) > dev_sectors) |
636 | goto out_of_range; | 634 | goto out_of_range; |
637 | if (lba48) { | ||
638 | if (n_block > (64 * 1024)) | ||
639 | goto invalid_fld; | ||
640 | } else { | ||
641 | if (n_block > 256) | ||
642 | goto invalid_fld; | ||
643 | } | ||
644 | 635 | ||
645 | if (lba) { | 636 | if (dev->flags & ATA_DFLAG_LBA) { |
646 | if (lba48) { | 637 | tf->flags |= ATA_TFLAG_LBA; |
638 | |||
639 | if (dev->flags & ATA_DFLAG_LBA48) { | ||
640 | if (n_block > (64 * 1024)) | ||
641 | goto invalid_fld; | ||
642 | |||
643 | /* use LBA48 */ | ||
644 | tf->flags |= ATA_TFLAG_LBA48; | ||
647 | tf->command = ATA_CMD_VERIFY_EXT; | 645 | tf->command = ATA_CMD_VERIFY_EXT; |
648 | 646 | ||
649 | tf->hob_nsect = (n_block >> 8) & 0xff; | 647 | tf->hob_nsect = (n_block >> 8) & 0xff; |
@@ -652,6 +650,10 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
652 | tf->hob_lbam = (block >> 32) & 0xff; | 650 | tf->hob_lbam = (block >> 32) & 0xff; |
653 | tf->hob_lbal = (block >> 24) & 0xff; | 651 | tf->hob_lbal = (block >> 24) & 0xff; |
654 | } else { | 652 | } else { |
653 | if (n_block > 256) | ||
654 | goto invalid_fld; | ||
655 | |||
656 | /* use LBA28 */ | ||
655 | tf->command = ATA_CMD_VERIFY; | 657 | tf->command = ATA_CMD_VERIFY; |
656 | 658 | ||
657 | tf->device |= (block >> 24) & 0xf; | 659 | tf->device |= (block >> 24) & 0xf; |
@@ -668,6 +670,9 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
668 | /* CHS */ | 670 | /* CHS */ |
669 | u32 sect, head, cyl, track; | 671 | u32 sect, head, cyl, track; |
670 | 672 | ||
673 | if (n_block > 256) | ||
674 | goto invalid_fld; | ||
675 | |||
671 | /* Convert LBA to CHS */ | 676 | /* Convert LBA to CHS */ |
672 | track = (u32)block / dev->sectors; | 677 | track = (u32)block / dev->sectors; |
673 | cyl = track / dev->heads; | 678 | cyl = track / dev->heads; |
@@ -733,8 +738,6 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
733 | { | 738 | { |
734 | struct ata_taskfile *tf = &qc->tf; | 739 | struct ata_taskfile *tf = &qc->tf; |
735 | struct ata_device *dev = qc->dev; | 740 | struct ata_device *dev = qc->dev; |
736 | unsigned int lba = tf->flags & ATA_TFLAG_LBA; | ||
737 | unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48; | ||
738 | u64 block; | 741 | u64 block; |
739 | u32 n_block; | 742 | u32 n_block; |
740 | 743 | ||
@@ -783,19 +786,24 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) | |||
783 | */ | 786 | */ |
784 | goto nothing_to_do; | 787 | goto nothing_to_do; |
785 | 788 | ||
786 | if (lba) { | 789 | if (dev->flags & ATA_DFLAG_LBA) { |
787 | if (lba48) { | 790 | tf->flags |= ATA_TFLAG_LBA; |
791 | |||
792 | if (dev->flags & ATA_DFLAG_LBA48) { | ||
788 | /* The request -may- be too large for LBA48. */ | 793 | /* The request -may- be too large for LBA48. */ |
789 | if ((block >> 48) || (n_block > 65536)) | 794 | if ((block >> 48) || (n_block > 65536)) |
790 | goto out_of_range; | 795 | goto out_of_range; |
791 | 796 | ||
797 | /* use LBA48 */ | ||
798 | tf->flags |= ATA_TFLAG_LBA48; | ||
799 | |||
792 | tf->hob_nsect = (n_block >> 8) & 0xff; | 800 | tf->hob_nsect = (n_block >> 8) & 0xff; |
793 | 801 | ||
794 | tf->hob_lbah = (block >> 40) & 0xff; | 802 | tf->hob_lbah = (block >> 40) & 0xff; |
795 | tf->hob_lbam = (block >> 32) & 0xff; | 803 | tf->hob_lbam = (block >> 32) & 0xff; |
796 | tf->hob_lbal = (block >> 24) & 0xff; | 804 | tf->hob_lbal = (block >> 24) & 0xff; |
797 | } else { | 805 | } else { |
798 | /* LBA28 */ | 806 | /* use LBA28 */ |
799 | 807 | ||
800 | /* The request -may- be too large for LBA28. */ | 808 | /* The request -may- be too large for LBA28. */ |
801 | if ((block >> 28) || (n_block > 256)) | 809 | if ((block >> 28) || (n_block > 256)) |