aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/pdc_adma.c8
-rw-r--r--drivers/scsi/sata_mv.c16
-rw-r--r--drivers/scsi/sata_sil24.c15
3 files changed, 23 insertions, 16 deletions
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 53b8db4be1a9..c6825da6ae20 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -293,14 +293,14 @@ static void adma_eng_timeout(struct ata_port *ap)
293 293
294static int adma_fill_sg(struct ata_queued_cmd *qc) 294static int adma_fill_sg(struct ata_queued_cmd *qc)
295{ 295{
296 struct scatterlist *sg = qc->sg; 296 struct scatterlist *sg;
297 struct ata_port *ap = qc->ap; 297 struct ata_port *ap = qc->ap;
298 struct adma_port_priv *pp = ap->private_data; 298 struct adma_port_priv *pp = ap->private_data;
299 u8 *buf = pp->pkt; 299 u8 *buf = pp->pkt;
300 int nelem, i = (2 + buf[3]) * 8; 300 int i = (2 + buf[3]) * 8;
301 u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0); 301 u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0);
302 302
303 for (nelem = 0; nelem < qc->n_elem; nelem++,sg++) { 303 ata_for_each_sg(sg, qc) {
304 u32 addr; 304 u32 addr;
305 u32 len; 305 u32 len;
306 306
@@ -312,7 +312,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
312 *(__le32 *)(buf + i) = cpu_to_le32(len); 312 *(__le32 *)(buf + i) = cpu_to_le32(len);
313 i += 4; 313 i += 4;
314 314
315 if ((nelem + 1) == qc->n_elem) 315 if (ata_sg_is_last(sg, qc))
316 pFLAGS |= pEND; 316 pFLAGS |= pEND;
317 buf[i++] = pFLAGS; 317 buf[i++] = pFLAGS;
318 buf[i++] = qc->dev->dma_mode & 0xf; 318 buf[i++] = qc->dev->dma_mode & 0xf;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index d457f5673476..be7c378dcd36 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -785,22 +785,24 @@ static void mv_port_stop(struct ata_port *ap)
785static void mv_fill_sg(struct ata_queued_cmd *qc) 785static void mv_fill_sg(struct ata_queued_cmd *qc)
786{ 786{
787 struct mv_port_priv *pp = qc->ap->private_data; 787 struct mv_port_priv *pp = qc->ap->private_data;
788 unsigned int i; 788 unsigned int i = 0;
789 struct scatterlist *sg;
789 790
790 for (i = 0; i < qc->n_elem; i++) { 791 ata_for_each_sg(sg, qc) {
791 u32 sg_len; 792 u32 sg_len;
792 dma_addr_t addr; 793 dma_addr_t addr;
793 794
794 addr = sg_dma_address(&qc->sg[i]); 795 addr = sg_dma_address(sg);
795 sg_len = sg_dma_len(&qc->sg[i]); 796 sg_len = sg_dma_len(sg);
796 797
797 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff); 798 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff);
798 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); 799 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
799 assert(0 == (sg_len & ~MV_DMA_BOUNDARY)); 800 assert(0 == (sg_len & ~MV_DMA_BOUNDARY));
800 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len); 801 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len);
801 } 802 if (ata_sg_is_last(sg, qc))
802 if (0 < qc->n_elem) { 803 pp->sg_tbl[i].flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL);
803 pp->sg_tbl[qc->n_elem - 1].flags_size |= EPRD_FLAG_END_OF_TBL; 804
805 i++;
804 } 806 }
805} 807}
806 808
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 19857814d69f..e16d1815cda0 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -416,15 +416,20 @@ static void sil24_phy_reset(struct ata_port *ap)
416static inline void sil24_fill_sg(struct ata_queued_cmd *qc, 416static inline void sil24_fill_sg(struct ata_queued_cmd *qc,
417 struct sil24_cmd_block *cb) 417 struct sil24_cmd_block *cb)
418{ 418{
419 struct scatterlist *sg = qc->sg;
420 struct sil24_sge *sge = cb->sge; 419 struct sil24_sge *sge = cb->sge;
421 unsigned i; 420 struct scatterlist *sg;
421 unsigned int idx = 0;
422 422
423 for (i = 0; i < qc->n_elem; i++, sg++, sge++) { 423 ata_for_each_sg(sg, qc) {
424 sge->addr = cpu_to_le64(sg_dma_address(sg)); 424 sge->addr = cpu_to_le64(sg_dma_address(sg));
425 sge->cnt = cpu_to_le32(sg_dma_len(sg)); 425 sge->cnt = cpu_to_le32(sg_dma_len(sg));
426 sge->flags = 0; 426 if (ata_sg_is_last(sg, qc))
427 sge->flags = i < qc->n_elem - 1 ? 0 : cpu_to_le32(SGE_TRM); 427 sge->flags = cpu_to_le32(SGE_TRM);
428 else
429 sge->flags = 0;
430
431 sge++;
432 idx++;
428 } 433 }
429} 434}
430 435