aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-03 03:30:39 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:31 -0500
commit726f0785b608d09bdd64bdbadc09217ebbf9920e (patch)
treecefc97e9d5fefb2735b1b7a5ca22d3b3cc742b13 /drivers/ata/libata-core.c
parent16454445e1f0ca21ca2f29accb58478a7ff765a2 (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/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 89f3cf57b677..c1444d8f92c6 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