diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-03 03:30:39 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:31 -0500 |
commit | 726f0785b608d09bdd64bdbadc09217ebbf9920e (patch) | |
tree | cefc97e9d5fefb2735b1b7a5ca22d3b3cc742b13 /drivers/ata | |
parent | 16454445e1f0ca21ca2f29accb58478a7ff765a2 (diff) |
libata: kill qc->nsect and cursect
libata used two separate sets of variables to record request size and
current offset for ATA and ATAPI. This is confusing and fragile.
This patch replaces qc->nsect/cursect with qc->nbytes/curbytes and
kills them. Also, ata_pio_sector() is updated to use bytes for
qc->cursg_ofs instead of sectors. The field used to be used in bytes
for ATAPI and in sectors for ATA.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/libata-core.c | 14 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 7 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 4 | ||||
-rw-r--r-- | drivers/ata/pata_pdc202xx_old.c | 5 | ||||
-rw-r--r-- | drivers/ata/sata_qstor.c | 2 |
5 files changed, 12 insertions, 20 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 89f3cf57b67..c1444d8f92c 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1249,7 +1249,6 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1249 | buflen += sg[i].length; | 1249 | buflen += sg[i].length; |
1250 | 1250 | ||
1251 | ata_sg_init(qc, sg, n_elem); | 1251 | ata_sg_init(qc, sg, n_elem); |
1252 | qc->nsect = buflen / ATA_SECT_SIZE; | ||
1253 | qc->nbytes = buflen; | 1252 | qc->nbytes = buflen; |
1254 | } | 1253 | } |
1255 | 1254 | ||
@@ -4006,11 +4005,11 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
4006 | unsigned int offset; | 4005 | unsigned int offset; |
4007 | unsigned char *buf; | 4006 | unsigned char *buf; |
4008 | 4007 | ||
4009 | if (qc->cursect == (qc->nsect - 1)) | 4008 | if (qc->curbytes == qc->nbytes - ATA_SECT_SIZE) |
4010 | ap->hsm_task_state = HSM_ST_LAST; | 4009 | ap->hsm_task_state = HSM_ST_LAST; |
4011 | 4010 | ||
4012 | page = sg[qc->cursg].page; | 4011 | page = sg[qc->cursg].page; |
4013 | offset = sg[qc->cursg].offset + qc->cursg_ofs * ATA_SECT_SIZE; | 4012 | offset = sg[qc->cursg].offset + qc->cursg_ofs; |
4014 | 4013 | ||
4015 | /* get the current page and offset */ | 4014 | /* get the current page and offset */ |
4016 | page = nth_page(page, (offset >> PAGE_SHIFT)); | 4015 | page = nth_page(page, (offset >> PAGE_SHIFT)); |
@@ -4035,10 +4034,10 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
4035 | ap->ops->data_xfer(qc->dev, buf + offset, ATA_SECT_SIZE, do_write); | 4034 | ap->ops->data_xfer(qc->dev, buf + offset, ATA_SECT_SIZE, do_write); |
4036 | } | 4035 | } |
4037 | 4036 | ||
4038 | qc->cursect++; | 4037 | qc->curbytes += ATA_SECT_SIZE; |
4039 | qc->cursg_ofs++; | 4038 | qc->cursg_ofs += ATA_SECT_SIZE; |
4040 | 4039 | ||
4041 | if ((qc->cursg_ofs * ATA_SECT_SIZE) == (&sg[qc->cursg])->length) { | 4040 | if (qc->cursg_ofs == (&sg[qc->cursg])->length) { |
4042 | qc->cursg++; | 4041 | qc->cursg++; |
4043 | qc->cursg_ofs = 0; | 4042 | qc->cursg_ofs = 0; |
4044 | } | 4043 | } |
@@ -4063,7 +4062,8 @@ static void ata_pio_sectors(struct ata_queued_cmd *qc) | |||
4063 | 4062 | ||
4064 | WARN_ON(qc->dev->multi_count == 0); | 4063 | WARN_ON(qc->dev->multi_count == 0); |
4065 | 4064 | ||
4066 | nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count); | 4065 | nsect = min((qc->nbytes - qc->curbytes) / ATA_SECT_SIZE, |
4066 | qc->dev->multi_count); | ||
4067 | while (nsect--) | 4067 | while (nsect--) |
4068 | ata_pio_sector(qc); | 4068 | ata_pio_sector(qc); |
4069 | } else | 4069 | } else |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 748435807d6..52c85af7fe9 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1443,15 +1443,10 @@ static void ata_eh_report(struct ata_port *ap) | |||
1443 | }; | 1443 | }; |
1444 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | 1444 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); |
1445 | struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; | 1445 | struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; |
1446 | unsigned int nbytes; | ||
1447 | 1446 | ||
1448 | if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask) | 1447 | if (!(qc->flags & ATA_QCFLAG_FAILED) || !qc->err_mask) |
1449 | continue; | 1448 | continue; |
1450 | 1449 | ||
1451 | nbytes = qc->nbytes; | ||
1452 | if (!nbytes) | ||
1453 | nbytes = qc->nsect << 9; | ||
1454 | |||
1455 | ata_dev_printk(qc->dev, KERN_ERR, | 1450 | ata_dev_printk(qc->dev, KERN_ERR, |
1456 | "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " | 1451 | "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " |
1457 | "tag %d cdb 0x%x data %u %s\n " | 1452 | "tag %d cdb 0x%x data %u %s\n " |
@@ -1461,7 +1456,7 @@ static void ata_eh_report(struct ata_port *ap) | |||
1461 | cmd->lbal, cmd->lbam, cmd->lbah, | 1456 | cmd->lbal, cmd->lbam, cmd->lbah, |
1462 | cmd->hob_feature, cmd->hob_nsect, | 1457 | cmd->hob_feature, cmd->hob_nsect, |
1463 | cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah, | 1458 | cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah, |
1464 | cmd->device, qc->tag, qc->cdb[0], nbytes, | 1459 | cmd->device, qc->tag, qc->cdb[0], qc->nbytes, |
1465 | dma_str[qc->dma_dir], | 1460 | dma_str[qc->dma_dir], |
1466 | res->command, res->feature, res->nsect, | 1461 | res->command, res->feature, res->nsect, |
1467 | res->lbal, res->lbam, res->lbah, | 1462 | res->lbal, res->lbam, res->lbah, |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 6a99c082475..9b5088ab274 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1359,7 +1359,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) | |||
1359 | goto nothing_to_do; | 1359 | goto nothing_to_do; |
1360 | 1360 | ||
1361 | qc->flags |= ATA_QCFLAG_IO; | 1361 | qc->flags |= ATA_QCFLAG_IO; |
1362 | qc->nsect = n_block; | 1362 | qc->nbytes = n_block * ATA_SECT_SIZE; |
1363 | 1363 | ||
1364 | rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, | 1364 | rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, |
1365 | qc->tag); | 1365 | qc->tag); |
@@ -2660,7 +2660,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) | |||
2660 | * TODO: find out if we need to do more here to | 2660 | * TODO: find out if we need to do more here to |
2661 | * cover scatter/gather case. | 2661 | * cover scatter/gather case. |
2662 | */ | 2662 | */ |
2663 | qc->nsect = scmd->request_bufflen / ATA_SECT_SIZE; | 2663 | qc->nbytes = scmd->request_bufflen; |
2664 | 2664 | ||
2665 | /* request result TF */ | 2665 | /* request result TF */ |
2666 | qc->flags |= ATA_QCFLAG_RESULT_TF; | 2666 | qc->flags |= ATA_QCFLAG_RESULT_TF; |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index ad691b9e774..ba982ba68ad 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -189,10 +189,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc) | |||
189 | /* Cases the state machine will not complete correctly without help */ | 189 | /* Cases the state machine will not complete correctly without help */ |
190 | if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA) | 190 | if ((tf->flags & ATA_TFLAG_LBA48) || tf->protocol == ATA_PROT_ATAPI_DMA) |
191 | { | 191 | { |
192 | if (tf->flags & ATA_TFLAG_LBA48) | 192 | len = qc->nbytes; |
193 | len = qc->nsect * 512; | ||
194 | else | ||
195 | len = qc->nbytes; | ||
196 | 193 | ||
197 | if (tf->flags & ATA_TFLAG_WRITE) | 194 | if (tf->flags & ATA_TFLAG_WRITE) |
198 | len |= 0x06000000; | 195 | len |= 0x06000000; |
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index 710909df4ea..0292a79f974 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -325,7 +325,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc) | |||
325 | /* host control block (HCB) */ | 325 | /* host control block (HCB) */ |
326 | buf[ 0] = QS_HCB_HDR; | 326 | buf[ 0] = QS_HCB_HDR; |
327 | buf[ 1] = hflags; | 327 | buf[ 1] = hflags; |
328 | *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nsect * ATA_SECT_SIZE); | 328 | *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nbytes); |
329 | *(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem); | 329 | *(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem); |
330 | addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES; | 330 | addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES; |
331 | *(__le64 *)(&buf[16]) = cpu_to_le64(addr); | 331 | *(__le64 *)(&buf[16]) = cpu_to_le64(addr); |