aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-22 15:19:53 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-22 15:19:53 -0400
commit45711f1af6eff1a6d010703b4862e0d2b9afd056 (patch)
tree3d0048f46e3df9d217d56127462ebe680348bd5a /drivers/scsi
parent78c2f0b8c285c5305b3e67b0595200541e15eb43 (diff)
[SG] Update drivers to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/3w-9xxx.c4
-rw-r--r--drivers/scsi/3w-xxxx.c2
-rw-r--r--drivers/scsi/NCR5380.c6
-rw-r--r--drivers/scsi/NCR53C9x.c4
-rw-r--r--drivers/scsi/NCR53c406a.c6
-rw-r--r--drivers/scsi/aacraid/aachba.c2
-rw-r--r--drivers/scsi/aha152x.c2
-rw-r--r--drivers/scsi/aha1542.c8
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c4
-rw-r--r--drivers/scsi/atari_NCR5380.c6
-rw-r--r--drivers/scsi/eata_pio.c4
-rw-r--r--drivers/scsi/fd_mcs.c6
-rw-r--r--drivers/scsi/fdomain.c7
-rw-r--r--drivers/scsi/gdth.c6
-rw-r--r--drivers/scsi/ibmmca.c2
-rw-r--r--drivers/scsi/ide-scsi.c12
-rw-r--r--drivers/scsi/imm.c8
-rw-r--r--drivers/scsi/in2000.c4
-rw-r--r--drivers/scsi/ipr.c19
-rw-r--r--drivers/scsi/ips.c6
-rw-r--r--drivers/scsi/iscsi_tcp.c15
-rw-r--r--drivers/scsi/megaraid.c8
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c12
-rw-r--r--drivers/scsi/oktagon_esp.c6
-rw-r--r--drivers/scsi/osst.c32
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h2
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c6
-rw-r--r--drivers/scsi/ppa.c7
-rw-r--r--drivers/scsi/ps3rom.c6
-rw-r--r--drivers/scsi/qlogicfas408.c2
-rw-r--r--drivers/scsi/scsi_debug.c4
-rw-r--r--drivers/scsi/scsi_lib.c13
-rw-r--r--drivers/scsi/seagate.c8
-rw-r--r--drivers/scsi/sg.c30
-rw-r--r--drivers/scsi/st.c8
-rw-r--r--drivers/scsi/sun3_NCR5380.c3
-rw-r--r--drivers/scsi/sym53c416.c2
-rw-r--r--drivers/scsi/tmscsim.c5
-rw-r--r--drivers/scsi/ultrastor.c2
-rw-r--r--drivers/scsi/wd33c93.c6
-rw-r--r--drivers/scsi/wd7000.c2
41 files changed, 139 insertions, 158 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index fb14014ee16e..afb262b4be15 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1840,7 +1840,7 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1840 (scsi_bufflen(srb) < TW_MIN_SGL_LENGTH)) { 1840 (scsi_bufflen(srb) < TW_MIN_SGL_LENGTH)) {
1841 if (srb->sc_data_direction == DMA_TO_DEVICE || srb->sc_data_direction == DMA_BIDIRECTIONAL) { 1841 if (srb->sc_data_direction == DMA_TO_DEVICE || srb->sc_data_direction == DMA_BIDIRECTIONAL) {
1842 struct scatterlist *sg = scsi_sglist(srb); 1842 struct scatterlist *sg = scsi_sglist(srb);
1843 char *buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1843 char *buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1844 memcpy(tw_dev->generic_buffer_virt[request_id], buf, sg->length); 1844 memcpy(tw_dev->generic_buffer_virt[request_id], buf, sg->length);
1845 kunmap_atomic(buf - sg->offset, KM_IRQ0); 1845 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1846 } 1846 }
@@ -1919,7 +1919,7 @@ static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re
1919 char *buf; 1919 char *buf;
1920 unsigned long flags = 0; 1920 unsigned long flags = 0;
1921 local_irq_save(flags); 1921 local_irq_save(flags);
1922 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1922 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1923 memcpy(buf, tw_dev->generic_buffer_virt[request_id], sg->length); 1923 memcpy(buf, tw_dev->generic_buffer_virt[request_id], sg->length);
1924 kunmap_atomic(buf - sg->offset, KM_IRQ0); 1924 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1925 local_irq_restore(flags); 1925 local_irq_restore(flags);
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index a64153b96034..59716ebeb10c 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1469,7 +1469,7 @@ static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id,
1469 struct scatterlist *sg = scsi_sglist(cmd); 1469 struct scatterlist *sg = scsi_sglist(cmd);
1470 1470
1471 local_irq_save(flags); 1471 local_irq_save(flags);
1472 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1472 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1473 transfer_len = min(sg->length, len); 1473 transfer_len = min(sg->length, len);
1474 1474
1475 memcpy(buf, data, transfer_len); 1475 memcpy(buf, data, transfer_len);
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 988f0bc5eda5..2597209183d0 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -298,8 +298,7 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
298 if (cmd->use_sg) { 298 if (cmd->use_sg) {
299 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; 299 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
300 cmd->SCp.buffers_residual = cmd->use_sg - 1; 300 cmd->SCp.buffers_residual = cmd->use_sg - 1;
301 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ 301 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
302 cmd->SCp.buffer->offset;
303 cmd->SCp.this_residual = cmd->SCp.buffer->length; 302 cmd->SCp.this_residual = cmd->SCp.buffer->length;
304 } else { 303 } else {
305 cmd->SCp.buffer = NULL; 304 cmd->SCp.buffer = NULL;
@@ -2143,8 +2142,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
2143 ++cmd->SCp.buffer; 2142 ++cmd->SCp.buffer;
2144 --cmd->SCp.buffers_residual; 2143 --cmd->SCp.buffers_residual;
2145 cmd->SCp.this_residual = cmd->SCp.buffer->length; 2144 cmd->SCp.this_residual = cmd->SCp.buffer->length;
2146 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ 2145 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
2147 cmd->SCp.buffer->offset;
2148 dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual)); 2146 dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual));
2149 } 2147 }
2150 /* 2148 /*
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 96e8e29aa05d..5b0efc903918 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -927,7 +927,7 @@ static void esp_get_dmabufs(struct NCR_ESP *esp, Scsi_Cmnd *sp)
927 esp->dma_mmu_get_scsi_sgl(esp, sp); 927 esp->dma_mmu_get_scsi_sgl(esp, sp);
928 else 928 else
929 sp->SCp.ptr = 929 sp->SCp.ptr =
930 (char *) virt_to_phys((page_address(sp->SCp.buffer->page) + sp->SCp.buffer->offset)); 930 (char *) virt_to_phys(sg_virt(sp->SCp.buffer));
931 } 931 }
932} 932}
933 933
@@ -1748,7 +1748,7 @@ static inline void advance_sg(struct NCR_ESP *esp, Scsi_Cmnd *sp)
1748 if (esp->dma_advance_sg) 1748 if (esp->dma_advance_sg)
1749 esp->dma_advance_sg (sp); 1749 esp->dma_advance_sg (sp);
1750 else 1750 else
1751 sp->SCp.ptr = (char *) virt_to_phys((page_address(sp->SCp.buffer->page) + sp->SCp.buffer->offset)); 1751 sp->SCp.ptr = (char *) virt_to_phys(sg_virt(sp->SCp.buffer));
1752 1752
1753} 1753}
1754 1754
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index 3168a1794849..137d065db3da 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -875,8 +875,7 @@ static void NCR53c406a_intr(void *dev_id)
875 outb(TRANSFER_INFO | DMA_OP, CMD_REG); 875 outb(TRANSFER_INFO | DMA_OP, CMD_REG);
876#if USE_PIO 876#if USE_PIO
877 scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { 877 scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) {
878 NCR53c406a_pio_write(page_address(sg->page) + sg->offset, 878 NCR53c406a_pio_write(sg_virt(sg), sg->length);
879 sg->length);
880 } 879 }
881 REG0; 880 REG0;
882#endif /* USE_PIO */ 881#endif /* USE_PIO */
@@ -897,8 +896,7 @@ static void NCR53c406a_intr(void *dev_id)
897 outb(TRANSFER_INFO | DMA_OP, CMD_REG); 896 outb(TRANSFER_INFO | DMA_OP, CMD_REG);
898#if USE_PIO 897#if USE_PIO
899 scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { 898 scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) {
900 NCR53c406a_pio_read(page_address(sg->page) + sg->offset, 899 NCR53c406a_pio_read(sg_virt(sg), sg->length);
901 sg->length);
902 } 900 }
903 REG0; 901 REG0;
904#endif /* USE_PIO */ 902#endif /* USE_PIO */
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 80e448d0f3db..a77ab8d693d4 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -356,7 +356,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne
356 int transfer_len; 356 int transfer_len;
357 struct scatterlist *sg = scsi_sglist(scsicmd); 357 struct scatterlist *sg = scsi_sglist(scsicmd);
358 358
359 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 359 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
360 transfer_len = min(sg->length, len + offset); 360 transfer_len = min(sg->length, len + offset);
361 361
362 transfer_len -= offset; 362 transfer_len -= offset;
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a58c265dc8af..ea8c69947644 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -613,7 +613,7 @@ struct aha152x_scdata {
613#define SCNEXT(SCpnt) SCDATA(SCpnt)->next 613#define SCNEXT(SCpnt) SCDATA(SCpnt)->next
614#define SCSEM(SCpnt) SCDATA(SCpnt)->done 614#define SCSEM(SCpnt) SCDATA(SCpnt)->done
615 615
616#define SG_ADDRESS(buffer) ((char *) (page_address((buffer)->page)+(buffer)->offset)) 616#define SG_ADDRESS(buffer) ((char *) sg_virt((buffer)))
617 617
618/* state handling */ 618/* state handling */
619static void seldi_run(struct Scsi_Host *shpnt); 619static void seldi_run(struct Scsi_Host *shpnt);
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 961a1882cb7e..bbcc2c52d79f 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -49,7 +49,7 @@
49#include "aha1542.h" 49#include "aha1542.h"
50 50
51#define SCSI_BUF_PA(address) isa_virt_to_bus(address) 51#define SCSI_BUF_PA(address) isa_virt_to_bus(address)
52#define SCSI_SG_PA(sgent) (isa_page_to_bus((sgent)->page) + (sgent)->offset) 52#define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset)
53 53
54static void BAD_DMA(void *address, unsigned int length) 54static void BAD_DMA(void *address, unsigned int length)
55{ 55{
@@ -66,8 +66,7 @@ static void BAD_SG_DMA(Scsi_Cmnd * SCpnt,
66 int badseg) 66 int badseg)
67{ 67{
68 printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n", 68 printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n",
69 badseg, nseg, 69 badseg, nseg, sg_virt(sgp),
70 page_address(sgp->page) + sgp->offset,
71 (unsigned long long)SCSI_SG_PA(sgp), 70 (unsigned long long)SCSI_SG_PA(sgp),
72 sgp->length); 71 sgp->length);
73 72
@@ -712,8 +711,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
712 printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); 711 printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i);
713 scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { 712 scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) {
714 printk(KERN_CRIT "%d: %p %d\n", i, 713 printk(KERN_CRIT "%d: %p %d\n", i,
715 (page_address(sg->page) + 714 sg_virt(sg), sg->length);
716 sg->offset), sg->length);
717 }; 715 };
718 printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); 716 printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr);
719 ptr = (unsigned char *) &cptr[i]; 717 ptr = (unsigned char *) &cptr[i];
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index f81777586b8f..f7a252885a5c 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1343,7 +1343,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
1343 /* 4 bytes: Areca io control code */ 1343 /* 4 bytes: Areca io control code */
1344 1344
1345 sg = scsi_sglist(cmd); 1345 sg = scsi_sglist(cmd);
1346 buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1346 buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1347 if (scsi_sg_count(cmd) > 1) { 1347 if (scsi_sg_count(cmd) > 1) {
1348 retvalue = ARCMSR_MESSAGE_FAIL; 1348 retvalue = ARCMSR_MESSAGE_FAIL;
1349 goto message_out; 1349 goto message_out;
@@ -1593,7 +1593,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb,
1593 strncpy(&inqdata[32], "R001", 4); /* Product Revision */ 1593 strncpy(&inqdata[32], "R001", 4); /* Product Revision */
1594 1594
1595 sg = scsi_sglist(cmd); 1595 sg = scsi_sglist(cmd);
1596 buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1596 buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1597 1597
1598 memcpy(buffer, inqdata, sizeof(inqdata)); 1598 memcpy(buffer, inqdata, sizeof(inqdata));
1599 sg = scsi_sglist(cmd); 1599 sg = scsi_sglist(cmd);
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 52d0b87e9aa4..d1780980fb20 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -515,8 +515,7 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd)
515 if (cmd->use_sg) { 515 if (cmd->use_sg) {
516 cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer; 516 cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer;
517 cmd->SCp.buffers_residual = cmd->use_sg - 1; 517 cmd->SCp.buffers_residual = cmd->use_sg - 1;
518 cmd->SCp.ptr = (char *)page_address(cmd->SCp.buffer->page) + 518 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
519 cmd->SCp.buffer->offset;
520 cmd->SCp.this_residual = cmd->SCp.buffer->length; 519 cmd->SCp.this_residual = cmd->SCp.buffer->length;
521 /* ++roman: Try to merge some scatter-buffers if they are at 520 /* ++roman: Try to merge some scatter-buffers if they are at
522 * contiguous physical addresses. 521 * contiguous physical addresses.
@@ -2054,8 +2053,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
2054 ++cmd->SCp.buffer; 2053 ++cmd->SCp.buffer;
2055 --cmd->SCp.buffers_residual; 2054 --cmd->SCp.buffers_residual;
2056 cmd->SCp.this_residual = cmd->SCp.buffer->length; 2055 cmd->SCp.this_residual = cmd->SCp.buffer->length;
2057 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + 2056 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
2058 cmd->SCp.buffer->offset;
2059 /* ++roman: Try to merge some scatter-buffers if 2057 /* ++roman: Try to merge some scatter-buffers if
2060 * they are at contiguous physical addresses. 2058 * they are at contiguous physical addresses.
2061 */ 2059 */
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 96180bb47e41..982c5092be11 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -172,7 +172,7 @@ static void IncStat(struct scsi_pointer *SCp, unsigned int Increment)
172 SCp->Status = 0; 172 SCp->Status = 0;
173 else { 173 else {
174 SCp->buffer++; 174 SCp->buffer++;
175 SCp->ptr = page_address(SCp->buffer->page) + SCp->buffer->offset; 175 SCp->ptr = sg_virt(SCp->buffer);
176 SCp->this_residual = SCp->buffer->length; 176 SCp->this_residual = SCp->buffer->length;
177 } 177 }
178 } 178 }
@@ -410,7 +410,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
410 } else { 410 } else {
411 cmd->SCp.buffer = cmd->request_buffer; 411 cmd->SCp.buffer = cmd->request_buffer;
412 cmd->SCp.buffers_residual = cmd->use_sg; 412 cmd->SCp.buffers_residual = cmd->use_sg;
413 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; 413 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
414 cmd->SCp.this_residual = cmd->SCp.buffer->length; 414 cmd->SCp.this_residual = cmd->SCp.buffer->length;
415 } 415 }
416 cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes 416 cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 668569e8856b..8335b608e571 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -973,7 +973,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id)
973 if (current_SC->SCp.buffers_residual) { 973 if (current_SC->SCp.buffers_residual) {
974 --current_SC->SCp.buffers_residual; 974 --current_SC->SCp.buffers_residual;
975 ++current_SC->SCp.buffer; 975 ++current_SC->SCp.buffer;
976 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; 976 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
977 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 977 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
978 } else 978 } else
979 break; 979 break;
@@ -1006,7 +1006,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id)
1006 if (!current_SC->SCp.this_residual && current_SC->SCp.buffers_residual) { 1006 if (!current_SC->SCp.this_residual && current_SC->SCp.buffers_residual) {
1007 --current_SC->SCp.buffers_residual; 1007 --current_SC->SCp.buffers_residual;
1008 ++current_SC->SCp.buffer; 1008 ++current_SC->SCp.buffer;
1009 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; 1009 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1010 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 1010 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1011 } 1011 }
1012 } 1012 }
@@ -1109,7 +1109,7 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
1109 1109
1110 if (current_SC->use_sg) { 1110 if (current_SC->use_sg) {
1111 current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer; 1111 current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer;
1112 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; 1112 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1113 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 1113 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1114 current_SC->SCp.buffers_residual = current_SC->use_sg - 1; 1114 current_SC->SCp.buffers_residual = current_SC->use_sg - 1;
1115 } else { 1115 } else {
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 5d282e6a6ae1..2cd6b4959eb2 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -1321,7 +1321,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id)
1321 if (current_SC->SCp.buffers_residual) { 1321 if (current_SC->SCp.buffers_residual) {
1322 --current_SC->SCp.buffers_residual; 1322 --current_SC->SCp.buffers_residual;
1323 ++current_SC->SCp.buffer; 1323 ++current_SC->SCp.buffer;
1324 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; 1324 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1325 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 1325 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1326 } else 1326 } else
1327 break; 1327 break;
@@ -1354,7 +1354,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id)
1354 && current_SC->SCp.buffers_residual) { 1354 && current_SC->SCp.buffers_residual) {
1355 --current_SC->SCp.buffers_residual; 1355 --current_SC->SCp.buffers_residual;
1356 ++current_SC->SCp.buffer; 1356 ++current_SC->SCp.buffer;
1357 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; 1357 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1358 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 1358 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1359 } 1359 }
1360 } 1360 }
@@ -1439,8 +1439,7 @@ static int fdomain_16x0_queue(struct scsi_cmnd *SCpnt,
1439 1439
1440 if (scsi_sg_count(current_SC)) { 1440 if (scsi_sg_count(current_SC)) {
1441 current_SC->SCp.buffer = scsi_sglist(current_SC); 1441 current_SC->SCp.buffer = scsi_sglist(current_SC);
1442 current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) 1442 current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer);
1443 + current_SC->SCp.buffer->offset;
1444 current_SC->SCp.this_residual = current_SC->SCp.buffer->length; 1443 current_SC->SCp.this_residual = current_SC->SCp.buffer->length;
1445 current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1; 1444 current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1;
1446 } else { 1445 } else {
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 3ac080ee6e2f..5ab3ce762485 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -2374,18 +2374,18 @@ static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp,
2374 if (cpsum+cpnow > cpcount) 2374 if (cpsum+cpnow > cpcount)
2375 cpnow = cpcount - cpsum; 2375 cpnow = cpcount - cpsum;
2376 cpsum += cpnow; 2376 cpsum += cpnow;
2377 if (!sl->page) { 2377 if (!sg_page(sl)) {
2378 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", 2378 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
2379 ha->hanum); 2379 ha->hanum);
2380 return; 2380 return;
2381 } 2381 }
2382 local_irq_save(flags); 2382 local_irq_save(flags);
2383 address = kmap_atomic(sl->page, KM_BIO_SRC_IRQ) + sl->offset; 2383 address = kmap_atomic(sg_page(sl), KM_BIO_SRC_IRQ) + sl->offset;
2384 if (to_buffer) 2384 if (to_buffer)
2385 memcpy(buffer, address, cpnow); 2385 memcpy(buffer, address, cpnow);
2386 else 2386 else
2387 memcpy(address, buffer, cpnow); 2387 memcpy(address, buffer, cpnow);
2388 flush_dcache_page(sl->page); 2388 flush_dcache_page(sg_page(sl));
2389 kunmap_atomic(address, KM_BIO_SRC_IRQ); 2389 kunmap_atomic(address, KM_BIO_SRC_IRQ);
2390 local_irq_restore(flags); 2390 local_irq_restore(flags);
2391 if (cpsum == cpcount) 2391 if (cpsum == cpcount)
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
index 714e6273a70d..db004a450732 100644
--- a/drivers/scsi/ibmmca.c
+++ b/drivers/scsi/ibmmca.c
@@ -1828,7 +1828,7 @@ static int ibmmca_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1828 BUG_ON(scsi_sg_count(cmd) > 16); 1828 BUG_ON(scsi_sg_count(cmd) > 16);
1829 1829
1830 scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { 1830 scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) {
1831 ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sg->page) + sg->offset); 1831 ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sg_page(sg)) + sg->offset);
1832 ld(shpnt)[ldn].sge[i].byte_length = sg->length; 1832 ld(shpnt)[ldn].sge[i].byte_length = sg->length;
1833 } 1833 }
1834 scb->enable |= IM_POINTER_TO_LIST; 1834 scb->enable |= IM_POINTER_TO_LIST;
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 252d1806467f..8d0244c2e7d4 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -175,18 +175,18 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
175 175
176 while (bcount) { 176 while (bcount) {
177 count = min(pc->sg->length - pc->b_count, bcount); 177 count = min(pc->sg->length - pc->b_count, bcount);
178 if (PageHighMem(pc->sg->page)) { 178 if (PageHighMem(sg_page(pc->sg))) {
179 unsigned long flags; 179 unsigned long flags;
180 180
181 local_irq_save(flags); 181 local_irq_save(flags);
182 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + 182 buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) +
183 pc->sg->offset; 183 pc->sg->offset;
184 drive->hwif->atapi_input_bytes(drive, 184 drive->hwif->atapi_input_bytes(drive,
185 buf + pc->b_count, count); 185 buf + pc->b_count, count);
186 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); 186 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
187 local_irq_restore(flags); 187 local_irq_restore(flags);
188 } else { 188 } else {
189 buf = page_address(pc->sg->page) + pc->sg->offset; 189 buf = sg_virt(pc->sg);
190 drive->hwif->atapi_input_bytes(drive, 190 drive->hwif->atapi_input_bytes(drive,
191 buf + pc->b_count, count); 191 buf + pc->b_count, count);
192 } 192 }
@@ -212,18 +212,18 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
212 212
213 while (bcount) { 213 while (bcount) {
214 count = min(pc->sg->length - pc->b_count, bcount); 214 count = min(pc->sg->length - pc->b_count, bcount);
215 if (PageHighMem(pc->sg->page)) { 215 if (PageHighMem(sg_page(pc->sg))) {
216 unsigned long flags; 216 unsigned long flags;
217 217
218 local_irq_save(flags); 218 local_irq_save(flags);
219 buf = kmap_atomic(pc->sg->page, KM_IRQ0) + 219 buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) +
220 pc->sg->offset; 220 pc->sg->offset;
221 drive->hwif->atapi_output_bytes(drive, 221 drive->hwif->atapi_output_bytes(drive,
222 buf + pc->b_count, count); 222 buf + pc->b_count, count);
223 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); 223 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
224 local_irq_restore(flags); 224 local_irq_restore(flags);
225 } else { 225 } else {
226 buf = page_address(pc->sg->page) + pc->sg->offset; 226 buf = sg_virt(pc->sg);
227 drive->hwif->atapi_output_bytes(drive, 227 drive->hwif->atapi_output_bytes(drive,
228 buf + pc->b_count, count); 228 buf + pc->b_count, count);
229 } 229 }
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 74cdc1f0a78f..a3d0c6b14958 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -705,9 +705,7 @@ static int imm_completion(struct scsi_cmnd *cmd)
705 cmd->SCp.buffer++; 705 cmd->SCp.buffer++;
706 cmd->SCp.this_residual = 706 cmd->SCp.this_residual =
707 cmd->SCp.buffer->length; 707 cmd->SCp.buffer->length;
708 cmd->SCp.ptr = 708 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
709 page_address(cmd->SCp.buffer->page) +
710 cmd->SCp.buffer->offset;
711 709
712 /* 710 /*
713 * Make sure that we transfer even number of bytes 711 * Make sure that we transfer even number of bytes
@@ -844,9 +842,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
844 cmd->SCp.buffer = 842 cmd->SCp.buffer =
845 (struct scatterlist *) cmd->request_buffer; 843 (struct scatterlist *) cmd->request_buffer;
846 cmd->SCp.this_residual = cmd->SCp.buffer->length; 844 cmd->SCp.this_residual = cmd->SCp.buffer->length;
847 cmd->SCp.ptr = 845 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
848 page_address(cmd->SCp.buffer->page) +
849 cmd->SCp.buffer->offset;
850 } else { 846 } else {
851 /* else fill the only available buffer */ 847 /* else fill the only available buffer */
852 cmd->SCp.buffer = NULL; 848 cmd->SCp.buffer = NULL;
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index ab7cbf3449ce..c8b452f2878c 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -372,7 +372,7 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
372 if (cmd->use_sg) { 372 if (cmd->use_sg) {
373 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; 373 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
374 cmd->SCp.buffers_residual = cmd->use_sg - 1; 374 cmd->SCp.buffers_residual = cmd->use_sg - 1;
375 cmd->SCp.ptr = (char *) page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; 375 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
376 cmd->SCp.this_residual = cmd->SCp.buffer->length; 376 cmd->SCp.this_residual = cmd->SCp.buffer->length;
377 } else { 377 } else {
378 cmd->SCp.buffer = NULL; 378 cmd->SCp.buffer = NULL;
@@ -764,7 +764,7 @@ static void transfer_bytes(Scsi_Cmnd * cmd, int data_in_dir)
764 ++cmd->SCp.buffer; 764 ++cmd->SCp.buffer;
765 --cmd->SCp.buffers_residual; 765 --cmd->SCp.buffers_residual;
766 cmd->SCp.this_residual = cmd->SCp.buffer->length; 766 cmd->SCp.this_residual = cmd->SCp.buffer->length;
767 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; 767 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
768 } 768 }
769 769
770/* Set up hardware registers */ 770/* Set up hardware registers */
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index c316a0bcae6c..439b97a6a269 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2872,6 +2872,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2872 } 2872 }
2873 2873
2874 scatterlist = sglist->scatterlist; 2874 scatterlist = sglist->scatterlist;
2875 sg_init_table(scatterlist, num_elem);
2875 2876
2876 sglist->order = order; 2877 sglist->order = order;
2877 sglist->num_sg = num_elem; 2878 sglist->num_sg = num_elem;
@@ -2884,12 +2885,12 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2884 2885
2885 /* Free up what we already allocated */ 2886 /* Free up what we already allocated */
2886 for (j = i - 1; j >= 0; j--) 2887 for (j = i - 1; j >= 0; j--)
2887 __free_pages(scatterlist[j].page, order); 2888 __free_pages(sg_page(&scatterlist[j]), order);
2888 kfree(sglist); 2889 kfree(sglist);
2889 return NULL; 2890 return NULL;
2890 } 2891 }
2891 2892
2892 scatterlist[i].page = page; 2893 sg_set_page(&scatterlist[i], page);
2893 } 2894 }
2894 2895
2895 return sglist; 2896 return sglist;
@@ -2910,7 +2911,7 @@ static void ipr_free_ucode_buffer(struct ipr_sglist *sglist)
2910 int i; 2911 int i;
2911 2912
2912 for (i = 0; i < sglist->num_sg; i++) 2913 for (i = 0; i < sglist->num_sg; i++)
2913 __free_pages(sglist->scatterlist[i].page, sglist->order); 2914 __free_pages(sg_page(&sglist->scatterlist[i]), sglist->order);
2914 2915
2915 kfree(sglist); 2916 kfree(sglist);
2916} 2917}
@@ -2940,9 +2941,11 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist,
2940 scatterlist = sglist->scatterlist; 2941 scatterlist = sglist->scatterlist;
2941 2942
2942 for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) { 2943 for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
2943 kaddr = kmap(scatterlist[i].page); 2944 struct page *page = sg_page(&scatterlist[i]);
2945
2946 kaddr = kmap(page);
2944 memcpy(kaddr, buffer, bsize_elem); 2947 memcpy(kaddr, buffer, bsize_elem);
2945 kunmap(scatterlist[i].page); 2948 kunmap(page);
2946 2949
2947 scatterlist[i].length = bsize_elem; 2950 scatterlist[i].length = bsize_elem;
2948 2951
@@ -2953,9 +2956,11 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist,
2953 } 2956 }
2954 2957
2955 if (len % bsize_elem) { 2958 if (len % bsize_elem) {
2956 kaddr = kmap(scatterlist[i].page); 2959 struct page *page = sg_page(&scatterlist[i]);
2960
2961 kaddr = kmap(page);
2957 memcpy(kaddr, buffer, len % bsize_elem); 2962 memcpy(kaddr, buffer, len % bsize_elem);
2958 kunmap(scatterlist[i].page); 2963 kunmap(page);
2959 2964
2960 scatterlist[i].length = len % bsize_elem; 2965 scatterlist[i].length = len % bsize_elem;
2961 } 2966 }
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index edaac2714c5a..5c5a9b2628fc 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -1515,7 +1515,7 @@ static int ips_is_passthru(struct scsi_cmnd *SC)
1515 /* kmap_atomic() ensures addressability of the user buffer.*/ 1515 /* kmap_atomic() ensures addressability of the user buffer.*/
1516 /* local_irq_save() protects the KM_IRQ0 address slot. */ 1516 /* local_irq_save() protects the KM_IRQ0 address slot. */
1517 local_irq_save(flags); 1517 local_irq_save(flags);
1518 buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 1518 buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
1519 if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && 1519 if (buffer && buffer[0] == 'C' && buffer[1] == 'O' &&
1520 buffer[2] == 'P' && buffer[3] == 'P') { 1520 buffer[2] == 'P' && buffer[3] == 'P') {
1521 kunmap_atomic(buffer - sg->offset, KM_IRQ0); 1521 kunmap_atomic(buffer - sg->offset, KM_IRQ0);
@@ -3523,7 +3523,7 @@ ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
3523 /* kmap_atomic() ensures addressability of the data buffer.*/ 3523 /* kmap_atomic() ensures addressability of the data buffer.*/
3524 /* local_irq_save() protects the KM_IRQ0 address slot. */ 3524 /* local_irq_save() protects the KM_IRQ0 address slot. */
3525 local_irq_save(flags); 3525 local_irq_save(flags);
3526 buffer = kmap_atomic(sg[i].page, KM_IRQ0) + sg[i].offset; 3526 buffer = kmap_atomic(sg_page(&sg[i]), KM_IRQ0) + sg[i].offset;
3527 memcpy(buffer, &cdata[xfer_cnt], min_cnt); 3527 memcpy(buffer, &cdata[xfer_cnt], min_cnt);
3528 kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); 3528 kunmap_atomic(buffer - sg[i].offset, KM_IRQ0);
3529 local_irq_restore(flags); 3529 local_irq_restore(flags);
@@ -3556,7 +3556,7 @@ ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count)
3556 /* kmap_atomic() ensures addressability of the data buffer.*/ 3556 /* kmap_atomic() ensures addressability of the data buffer.*/
3557 /* local_irq_save() protects the KM_IRQ0 address slot. */ 3557 /* local_irq_save() protects the KM_IRQ0 address slot. */
3558 local_irq_save(flags); 3558 local_irq_save(flags);
3559 buffer = kmap_atomic(sg[i].page, KM_IRQ0) + sg[i].offset; 3559 buffer = kmap_atomic(sg_page(&sg[i]), KM_IRQ0) + sg[i].offset;
3560 memcpy(&cdata[xfer_cnt], buffer, min_cnt); 3560 memcpy(&cdata[xfer_cnt], buffer, min_cnt);
3561 kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); 3561 kunmap_atomic(buffer - sg[i].offset, KM_IRQ0);
3562 local_irq_restore(flags); 3562 local_irq_restore(flags);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index a21455d0274c..6ce4109efdf3 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -70,9 +70,7 @@ module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
70static inline void 70static inline void
71iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size) 71iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size)
72{ 72{
73 ibuf->sg.page = virt_to_page(vbuf); 73 sg_init_one(&ibuf->sg, vbuf, size);
74 ibuf->sg.offset = offset_in_page(vbuf);
75 ibuf->sg.length = size;
76 ibuf->sent = 0; 74 ibuf->sent = 0;
77 ibuf->use_sendmsg = 1; 75 ibuf->use_sendmsg = 1;
78} 76}
@@ -80,13 +78,14 @@ iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size)
80static inline void 78static inline void
81iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) 79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)
82{ 80{
83 ibuf->sg.page = sg->page; 81 sg_init_table(&ibuf->sg, 1);
82 sg_set_page(&ibuf->sg, sg_page(sg));
84 ibuf->sg.offset = sg->offset; 83 ibuf->sg.offset = sg->offset;
85 ibuf->sg.length = sg->length; 84 ibuf->sg.length = sg->length;
86 /* 85 /*
87 * Fastpath: sg element fits into single page 86 * Fastpath: sg element fits into single page
88 */ 87 */
89 if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg->page)) 88 if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg_page(sg)))
90 ibuf->use_sendmsg = 0; 89 ibuf->use_sendmsg = 0;
91 else 90 else
92 ibuf->use_sendmsg = 1; 91 ibuf->use_sendmsg = 1;
@@ -716,7 +715,7 @@ static int iscsi_scsi_data_in(struct iscsi_conn *conn)
716 for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) { 715 for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) {
717 char *dest; 716 char *dest;
718 717
719 dest = kmap_atomic(sg[i].page, KM_SOFTIRQ0); 718 dest = kmap_atomic(sg_page(&sg[i]), KM_SOFTIRQ0);
720 rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset, 719 rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset,
721 sg[i].length, offset); 720 sg[i].length, offset);
722 kunmap_atomic(dest, KM_SOFTIRQ0); 721 kunmap_atomic(dest, KM_SOFTIRQ0);
@@ -1103,9 +1102,9 @@ iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags)
1103 * slab case. 1102 * slab case.
1104 */ 1103 */
1105 if (buf->use_sendmsg) 1104 if (buf->use_sendmsg)
1106 res = sock_no_sendpage(sk, buf->sg.page, offset, size, flags); 1105 res = sock_no_sendpage(sk, sg_page(&buf->sg), offset, size, flags);
1107 else 1106 else
1108 res = tcp_conn->sendpage(sk, buf->sg.page, offset, size, flags); 1107 res = tcp_conn->sendpage(sk, sg_page(&buf->sg), offset, size, flags);
1109 1108
1110 if (res >= 0) { 1109 if (res >= 0) {
1111 conn->txdata_octets += res; 1110 conn->txdata_octets += res;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 10d1aff9938a..66c652035730 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -658,7 +658,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
658 struct scatterlist *sg; 658 struct scatterlist *sg;
659 659
660 sg = scsi_sglist(cmd); 660 sg = scsi_sglist(cmd);
661 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; 661 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
662 662
663 memset(buf, 0, cmd->cmnd[4]); 663 memset(buf, 0, cmd->cmnd[4]);
664 kunmap_atomic(buf - sg->offset, KM_IRQ0); 664 kunmap_atomic(buf - sg->offset, KM_IRQ0);
@@ -1542,10 +1542,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
1542 if( cmd->cmnd[0] == INQUIRY && !islogical ) { 1542 if( cmd->cmnd[0] == INQUIRY && !islogical ) {
1543 1543
1544 sgl = scsi_sglist(cmd); 1544 sgl = scsi_sglist(cmd);
1545 if( sgl->page ) { 1545 if( sg_page(sgl) ) {
1546 c = *(unsigned char *) 1546 c = *(unsigned char *) sg_virt(&sgl[0]);
1547 page_address((&sgl[0])->page) +
1548 (&sgl[0])->offset;
1549 } else { 1547 } else {
1550 printk(KERN_WARNING 1548 printk(KERN_WARNING
1551 "megaraid: invalid sg.\n"); 1549 "megaraid: invalid sg.\n");
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 78779209ac89..c8923108183a 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -1584,10 +1584,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
1584 caddr_t vaddr; 1584 caddr_t vaddr;
1585 1585
1586 sgl = scsi_sglist(scp); 1586 sgl = scsi_sglist(scp);
1587 if (sgl->page) { 1587 if (sg_page(sgl)) {
1588 vaddr = (caddr_t) 1588 vaddr = (caddr_t) sg_virt(&sgl[0]);
1589 (page_address((&sgl[0])->page)
1590 + (&sgl[0])->offset);
1591 1589
1592 memset(vaddr, 0, scp->cmnd[4]); 1590 memset(vaddr, 0, scp->cmnd[4]);
1593 } 1591 }
@@ -2328,10 +2326,8 @@ megaraid_mbox_dpc(unsigned long devp)
2328 && IS_RAID_CH(raid_dev, scb->dev_channel)) { 2326 && IS_RAID_CH(raid_dev, scb->dev_channel)) {
2329 2327
2330 sgl = scsi_sglist(scp); 2328 sgl = scsi_sglist(scp);
2331 if (sgl->page) { 2329 if (sg_page(sgl)) {
2332 c = *(unsigned char *) 2330 c = *(unsigned char *) sg_virt(&sgl[0]);
2333 (page_address((&sgl[0])->page) +
2334 (&sgl[0])->offset);
2335 } else { 2331 } else {
2336 con_log(CL_ANN, (KERN_WARNING 2332 con_log(CL_ANN, (KERN_WARNING
2337 "megaraid mailbox: invalid sg:%d\n", 2333 "megaraid mailbox: invalid sg:%d\n",
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index 26a6d55faf3e..8e5eadbd5c51 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -550,8 +550,7 @@ void dma_mmu_get_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp)
550 550
551void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp) 551void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp)
552{ 552{
553 sp->SCp.ptr = page_address(sp->SCp.buffer->page)+ 553 sp->SCp.ptr = sg_virt(sp->SCp.buffer);
554 sp->SCp.buffer->offset;
555} 554}
556 555
557void dma_mmu_release_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp) 556void dma_mmu_release_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp)
@@ -564,8 +563,7 @@ void dma_mmu_release_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp)
564 563
565void dma_advance_sg(Scsi_Cmnd *sp) 564void dma_advance_sg(Scsi_Cmnd *sp)
566{ 565{
567 sp->SCp.ptr = page_address(sp->SCp.buffer->page)+ 566 sp->SCp.ptr = sg_virt(sp->SCp.buffer);
568 sp->SCp.buffer->offset;
569} 567}
570 568
571 569
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 331b789937c4..1c5c4b68f20f 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -542,7 +542,7 @@ static int osst_verify_frame(struct osst_tape * STp, int frame_seq_number, int q
542 if (STp->raw) { 542 if (STp->raw) {
543 if (STp->buffer->syscall_result) { 543 if (STp->buffer->syscall_result) {
544 for (i=0; i < STp->buffer->sg_segs; i++) 544 for (i=0; i < STp->buffer->sg_segs; i++)
545 memset(page_address(STp->buffer->sg[i].page), 545 memset(page_address(sg_page(&STp->buffer->sg[i])),
546 0, STp->buffer->sg[i].length); 546 0, STp->buffer->sg[i].length);
547 strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); 547 strcpy(STp->buffer->b_data, "READ ERROR ON FRAME");
548 } else 548 } else
@@ -4437,7 +4437,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4437 for (i = 0, b_size = 0; 4437 for (i = 0, b_size = 0;
4438 (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); 4438 (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE);
4439 b_size += STp->buffer->sg[i++].length); 4439 b_size += STp->buffer->sg[i++].length);
4440 STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size); 4440 STp->buffer->aux = (os_aux_t *) (page_address(sg_page(&STp->buffer->sg[i])) + OS_DATA_SIZE - b_size);
4441#if DEBUG 4441#if DEBUG
4442 printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, 4442 printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name,
4443 STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); 4443 STp->buffer->b_data, page_address(STp->buffer->sg[0].page));
@@ -5252,25 +5252,26 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5252 /* Try to allocate the first segment up to OS_DATA_SIZE and the others 5252 /* Try to allocate the first segment up to OS_DATA_SIZE and the others
5253 big enough to reach the goal (code assumes no segments in place) */ 5253 big enough to reach the goal (code assumes no segments in place) */
5254 for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) { 5254 for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) {
5255 STbuffer->sg[0].page = alloc_pages(priority, order); 5255 struct page *page = alloc_pages(priority, order);
5256
5256 STbuffer->sg[0].offset = 0; 5257 STbuffer->sg[0].offset = 0;
5257 if (STbuffer->sg[0].page != NULL) { 5258 if (page != NULL) {
5259 sg_set_page(&STbuffer->sg[0], page);
5258 STbuffer->sg[0].length = b_size; 5260 STbuffer->sg[0].length = b_size;
5259 STbuffer->b_data = page_address(STbuffer->sg[0].page); 5261 STbuffer->b_data = page_address(page);
5260 break; 5262 break;
5261 } 5263 }
5262 } 5264 }
5263 if (STbuffer->sg[0].page == NULL) { 5265 if (sg_page(&STbuffer->sg[0]) == NULL) {
5264 printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n"); 5266 printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n");
5265 return 0; 5267 return 0;
5266 } 5268 }
5267 /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */ 5269 /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */
5268 for (segs=STbuffer->sg_segs=1, got=b_size; 5270 for (segs=STbuffer->sg_segs=1, got=b_size;
5269 segs < max_segs && got < OS_FRAME_SIZE; ) { 5271 segs < max_segs && got < OS_FRAME_SIZE; ) {
5270 STbuffer->sg[segs].page = 5272 struct page *page = alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order);
5271 alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order);
5272 STbuffer->sg[segs].offset = 0; 5273 STbuffer->sg[segs].offset = 0;
5273 if (STbuffer->sg[segs].page == NULL) { 5274 if (page == NULL) {
5274 if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) { 5275 if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) {
5275 b_size /= 2; /* Large enough for the rest of the buffers */ 5276 b_size /= 2; /* Large enough for the rest of the buffers */
5276 order--; 5277 order--;
@@ -5284,6 +5285,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5284 normalize_buffer(STbuffer); 5285 normalize_buffer(STbuffer);
5285 return 0; 5286 return 0;
5286 } 5287 }
5288 sg_set_page(&STbuffer->sg[segs], page);
5287 STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; 5289 STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size;
5288 got += STbuffer->sg[segs].length; 5290 got += STbuffer->sg[segs].length;
5289 STbuffer->buffer_size = got; 5291 STbuffer->buffer_size = got;
@@ -5316,7 +5318,7 @@ static void normalize_buffer(struct osst_buffer *STbuffer)
5316 b_size < STbuffer->sg[i].length; 5318 b_size < STbuffer->sg[i].length;
5317 b_size *= 2, order++); 5319 b_size *= 2, order++);
5318 5320
5319 __free_pages(STbuffer->sg[i].page, order); 5321 __free_pages(sg_page(&STbuffer->sg[i]), order);
5320 STbuffer->buffer_size -= STbuffer->sg[i].length; 5322 STbuffer->buffer_size -= STbuffer->sg[i].length;
5321 } 5323 }
5322#if DEBUG 5324#if DEBUG
@@ -5344,7 +5346,7 @@ static int append_to_buffer(const char __user *ubp, struct osst_buffer *st_bp, i
5344 for ( ; i < st_bp->sg_segs && do_count > 0; i++) { 5346 for ( ; i < st_bp->sg_segs && do_count > 0; i++) {
5345 cnt = st_bp->sg[i].length - offset < do_count ? 5347 cnt = st_bp->sg[i].length - offset < do_count ?
5346 st_bp->sg[i].length - offset : do_count; 5348 st_bp->sg[i].length - offset : do_count;
5347 res = copy_from_user(page_address(st_bp->sg[i].page) + offset, ubp, cnt); 5349 res = copy_from_user(page_address(sg_page(&st_bp->sg[i])) + offset, ubp, cnt);
5348 if (res) 5350 if (res)
5349 return (-EFAULT); 5351 return (-EFAULT);
5350 do_count -= cnt; 5352 do_count -= cnt;
@@ -5377,7 +5379,7 @@ static int from_buffer(struct osst_buffer *st_bp, char __user *ubp, int do_count
5377 for ( ; i < st_bp->sg_segs && do_count > 0; i++) { 5379 for ( ; i < st_bp->sg_segs && do_count > 0; i++) {
5378 cnt = st_bp->sg[i].length - offset < do_count ? 5380 cnt = st_bp->sg[i].length - offset < do_count ?
5379 st_bp->sg[i].length - offset : do_count; 5381 st_bp->sg[i].length - offset : do_count;
5380 res = copy_to_user(ubp, page_address(st_bp->sg[i].page) + offset, cnt); 5382 res = copy_to_user(ubp, page_address(sg_page(&st_bp->sg[i])) + offset, cnt);
5381 if (res) 5383 if (res)
5382 return (-EFAULT); 5384 return (-EFAULT);
5383 do_count -= cnt; 5385 do_count -= cnt;
@@ -5410,7 +5412,7 @@ static int osst_zero_buffer_tail(struct osst_buffer *st_bp)
5410 i < st_bp->sg_segs && do_count > 0; i++) { 5412 i < st_bp->sg_segs && do_count > 0; i++) {
5411 cnt = st_bp->sg[i].length - offset < do_count ? 5413 cnt = st_bp->sg[i].length - offset < do_count ?
5412 st_bp->sg[i].length - offset : do_count ; 5414 st_bp->sg[i].length - offset : do_count ;
5413 memset(page_address(st_bp->sg[i].page) + offset, 0, cnt); 5415 memset(page_address(sg_page(&st_bp->sg[i])) + offset, 0, cnt);
5414 do_count -= cnt; 5416 do_count -= cnt;
5415 offset = 0; 5417 offset = 0;
5416 } 5418 }
@@ -5430,7 +5432,7 @@ static int osst_copy_to_buffer(struct osst_buffer *st_bp, unsigned char *ptr)
5430 for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { 5432 for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) {
5431 cnt = st_bp->sg[i].length < do_count ? 5433 cnt = st_bp->sg[i].length < do_count ?
5432 st_bp->sg[i].length : do_count ; 5434 st_bp->sg[i].length : do_count ;
5433 memcpy(page_address(st_bp->sg[i].page), ptr, cnt); 5435 memcpy(page_address(sg_page(&st_bp->sg[i])), ptr, cnt);
5434 do_count -= cnt; 5436 do_count -= cnt;
5435 ptr += cnt; 5437 ptr += cnt;
5436 } 5438 }
@@ -5451,7 +5453,7 @@ static int osst_copy_from_buffer(struct osst_buffer *st_bp, unsigned char *ptr)
5451 for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { 5453 for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) {
5452 cnt = st_bp->sg[i].length < do_count ? 5454 cnt = st_bp->sg[i].length < do_count ?
5453 st_bp->sg[i].length : do_count ; 5455 st_bp->sg[i].length : do_count ;
5454 memcpy(ptr, page_address(st_bp->sg[i].page), cnt); 5456 memcpy(ptr, page_address(sg_page(&st_bp->sg[i])), cnt);
5455 do_count -= cnt; 5457 do_count -= cnt;
5456 ptr += cnt; 5458 ptr += cnt;
5457 } 5459 }
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index 98397559c53b..7db28cd49446 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -393,7 +393,7 @@ enum _burst_mode {
393#define MSG_EXT_SDTR 0x01 393#define MSG_EXT_SDTR 0x01
394 394
395/* scatter-gather table */ 395/* scatter-gather table */
396# define BUFFER_ADDR ((char *)((unsigned int)(SCpnt->SCp.buffer->page) + SCpnt->SCp.buffer->offset)) 396# define BUFFER_ADDR ((char *)((sg_virt(SCpnt->SCp.buffer))))
397 397
398#endif /*__nsp_cs__*/ 398#endif /*__nsp_cs__*/
399/* end */ 399/* end */
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 190e2a7d7067..969b9387a0c3 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -443,8 +443,7 @@ SYM53C500_intr(int irq, void *dev_id)
443 443
444 scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { 444 scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) {
445 SYM53C500_pio_write(fast_pio, port_base, 445 SYM53C500_pio_write(fast_pio, port_base,
446 page_address(sg->page) + sg->offset, 446 sg_virt(sg), sg->length);
447 sg->length);
448 } 447 }
449 REG0(port_base); 448 REG0(port_base);
450 } 449 }
@@ -463,8 +462,7 @@ SYM53C500_intr(int irq, void *dev_id)
463 462
464 scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { 463 scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) {
465 SYM53C500_pio_read(fast_pio, port_base, 464 SYM53C500_pio_read(fast_pio, port_base,
466 page_address(sg->page) + sg->offset, 465 sg_virt(sg), sg->length);
467 sg->length);
468 } 466 }
469 REG0(port_base); 467 REG0(port_base);
470 } 468 }
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 67b6d76a6c8d..67ee51a3d7e1 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -608,9 +608,7 @@ static int ppa_completion(struct scsi_cmnd *cmd)
608 cmd->SCp.buffer++; 608 cmd->SCp.buffer++;
609 cmd->SCp.this_residual = 609 cmd->SCp.this_residual =
610 cmd->SCp.buffer->length; 610 cmd->SCp.buffer->length;
611 cmd->SCp.ptr = 611 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
612 page_address(cmd->SCp.buffer->page) +
613 cmd->SCp.buffer->offset;
614 } 612 }
615 } 613 }
616 /* Now check to see if the drive is ready to comunicate */ 614 /* Now check to see if the drive is ready to comunicate */
@@ -756,8 +754,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
756 /* if many buffers are available, start filling the first */ 754 /* if many buffers are available, start filling the first */
757 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; 755 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
758 cmd->SCp.this_residual = cmd->SCp.buffer->length; 756 cmd->SCp.this_residual = cmd->SCp.buffer->length;
759 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + 757 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
760 cmd->SCp.buffer->offset;
761 } else { 758 } else {
762 /* else fill the only available buffer */ 759 /* else fill the only available buffer */
763 cmd->SCp.buffer = NULL; 760 cmd->SCp.buffer = NULL;
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index 0f43d1d046d9..03f19b8d19c9 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -111,14 +111,14 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
111 req_len = act_len = 0; 111 req_len = act_len = 0;
112 scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { 112 scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) {
113 if (active) { 113 if (active) {
114 kaddr = kmap_atomic(sgpnt->page, KM_IRQ0); 114 kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0);
115 len = sgpnt->length; 115 len = sgpnt->length;
116 if ((req_len + len) > buflen) { 116 if ((req_len + len) > buflen) {
117 active = 0; 117 active = 0;
118 len = buflen - req_len; 118 len = buflen - req_len;
119 } 119 }
120 memcpy(kaddr + sgpnt->offset, buf + req_len, len); 120 memcpy(kaddr + sgpnt->offset, buf + req_len, len);
121 flush_kernel_dcache_page(sgpnt->page); 121 flush_kernel_dcache_page(sg_page(sgpnt));
122 kunmap_atomic(kaddr, KM_IRQ0); 122 kunmap_atomic(kaddr, KM_IRQ0);
123 act_len += len; 123 act_len += len;
124 } 124 }
@@ -147,7 +147,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd *cmd, void *buf)
147 147
148 req_len = fin = 0; 148 req_len = fin = 0;
149 scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { 149 scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) {
150 kaddr = kmap_atomic(sgpnt->page, KM_IRQ0); 150 kaddr = kmap_atomic(sg_page(sgpnt->page), KM_IRQ0);
151 len = sgpnt->length; 151 len = sgpnt->length;
152 if ((req_len + len) > buflen) { 152 if ((req_len + len) > buflen) {
153 len = buflen - req_len; 153 len = buflen - req_len;
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 2bfbf26c00ed..de7b3bc2cbc9 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -317,7 +317,7 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
317 return ((priv->qabort == 1 ? 317 return ((priv->qabort == 1 ?
318 DID_ABORT : DID_RESET) << 16); 318 DID_ABORT : DID_RESET) << 16);
319 } 319 }
320 buf = page_address(sg->page) + sg->offset; 320 buf = sg_virt(sg);
321 if (ql_pdma(priv, phase, buf, sg->length)) 321 if (ql_pdma(priv, phase, buf, sg->length))
322 break; 322 break;
323 } 323 }
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 72ee4c9cfb1a..46cae5a212de 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -625,7 +625,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
625 scsi_for_each_sg(scp, sg, scp->use_sg, k) { 625 scsi_for_each_sg(scp, sg, scp->use_sg, k) {
626 if (active) { 626 if (active) {
627 kaddr = (unsigned char *) 627 kaddr = (unsigned char *)
628 kmap_atomic(sg->page, KM_USER0); 628 kmap_atomic(sg_page(sg), KM_USER0);
629 if (NULL == kaddr) 629 if (NULL == kaddr)
630 return (DID_ERROR << 16); 630 return (DID_ERROR << 16);
631 kaddr_off = (unsigned char *)kaddr + sg->offset; 631 kaddr_off = (unsigned char *)kaddr + sg->offset;
@@ -672,7 +672,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
672 sg = scsi_sglist(scp); 672 sg = scsi_sglist(scp);
673 req_len = fin = 0; 673 req_len = fin = 0;
674 for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) { 674 for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) {
675 kaddr = (unsigned char *)kmap_atomic(sg->page, KM_USER0); 675 kaddr = (unsigned char *)kmap_atomic(sg_page(sg), KM_USER0);
676 if (NULL == kaddr) 676 if (NULL == kaddr)
677 return -1; 677 return -1;
678 kaddr_off = (unsigned char *)kaddr + sg->offset; 678 kaddr_off = (unsigned char *)kaddr + sg->offset;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index aac8a02cbe80..61fdaf02f251 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -295,7 +295,7 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
295 int i, err, nr_vecs = 0; 295 int i, err, nr_vecs = 0;
296 296
297 for_each_sg(sgl, sg, nsegs, i) { 297 for_each_sg(sgl, sg, nsegs, i) {
298 page = sg->page; 298 page = sg_page(sg);
299 off = sg->offset; 299 off = sg->offset;
300 len = sg->length; 300 len = sg->length;
301 data_len += len; 301 data_len += len;
@@ -764,7 +764,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
764 if (unlikely(!sgl)) 764 if (unlikely(!sgl))
765 goto enomem; 765 goto enomem;
766 766
767 memset(sgl, 0, sizeof(*sgl) * sgp->size); 767 sg_init_table(sgl, sgp->size);
768 768
769 /* 769 /*
770 * first loop through, set initial index and return value 770 * first loop through, set initial index and return value
@@ -781,6 +781,13 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
781 sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); 781 sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl);
782 782
783 /* 783 /*
784 * if we have nothing left, mark the last segment as
785 * end-of-list
786 */
787 if (!left)
788 sg_mark_end(sgl, this);
789
790 /*
784 * don't allow subsequent mempool allocs to sleep, it would 791 * don't allow subsequent mempool allocs to sleep, it would
785 * violate the mempool principle. 792 * violate the mempool principle.
786 */ 793 */
@@ -2353,7 +2360,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
2353 *offset = *offset - len_complete + sg->offset; 2360 *offset = *offset - len_complete + sg->offset;
2354 2361
2355 /* Assumption: contiguous pages can be accessed as "page + i" */ 2362 /* Assumption: contiguous pages can be accessed as "page + i" */
2356 page = nth_page(sg->page, (*offset >> PAGE_SHIFT)); 2363 page = nth_page(sg_page(sg), (*offset >> PAGE_SHIFT));
2357 *offset &= ~PAGE_MASK; 2364 *offset &= ~PAGE_MASK;
2358 2365
2359 /* Bytes in this sg-entry from *offset to the end of the page */ 2366 /* Bytes in this sg-entry from *offset to the end of the page */
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
index ce80fa9ad815..b11324479b5b 100644
--- a/drivers/scsi/seagate.c
+++ b/drivers/scsi/seagate.c
@@ -999,14 +999,14 @@ connect_loop:
999 for (i = 0; i < nobuffs; ++i) 999 for (i = 0; i < nobuffs; ++i)
1000 printk("scsi%d : buffer %d address = %p length = %d\n", 1000 printk("scsi%d : buffer %d address = %p length = %d\n",
1001 hostno, i, 1001 hostno, i,
1002 page_address(buffer[i].page) + buffer[i].offset, 1002 sg_virt(&buffer[i]),
1003 buffer[i].length); 1003 buffer[i].length);
1004 } 1004 }
1005#endif 1005#endif
1006 1006
1007 buffer = (struct scatterlist *) SCint->request_buffer; 1007 buffer = (struct scatterlist *) SCint->request_buffer;
1008 len = buffer->length; 1008 len = buffer->length;
1009 data = page_address(buffer->page) + buffer->offset; 1009 data = sg_virt(buffer);
1010 } else { 1010 } else {
1011 DPRINTK (DEBUG_SG, "scsi%d : scatter gather not requested.\n", hostno); 1011 DPRINTK (DEBUG_SG, "scsi%d : scatter gather not requested.\n", hostno);
1012 buffer = NULL; 1012 buffer = NULL;
@@ -1239,7 +1239,7 @@ connect_loop:
1239 --nobuffs; 1239 --nobuffs;
1240 ++buffer; 1240 ++buffer;
1241 len = buffer->length; 1241 len = buffer->length;
1242 data = page_address(buffer->page) + buffer->offset; 1242 data = sg_virt(buffer);
1243 DPRINTK (DEBUG_SG, 1243 DPRINTK (DEBUG_SG,
1244 "scsi%d : next scatter-gather buffer len = %d address = %08x\n", 1244 "scsi%d : next scatter-gather buffer len = %d address = %08x\n",
1245 hostno, len, data); 1245 hostno, len, data);
@@ -1396,7 +1396,7 @@ connect_loop:
1396 --nobuffs; 1396 --nobuffs;
1397 ++buffer; 1397 ++buffer;
1398 len = buffer->length; 1398 len = buffer->length;
1399 data = page_address(buffer->page) + buffer->offset; 1399 data = sg_virt(buffer);
1400 DPRINTK (DEBUG_SG, "scsi%d : next scatter-gather buffer len = %d address = %08x\n", hostno, len, data); 1400 DPRINTK (DEBUG_SG, "scsi%d : next scatter-gather buffer len = %d address = %08x\n", hostno, len, data);
1401 } 1401 }
1402 break; 1402 break;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 7238b2dfc497..cc1971002846 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1169,7 +1169,7 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
1169 len = vma->vm_end - sa; 1169 len = vma->vm_end - sa;
1170 len = (len < sg->length) ? len : sg->length; 1170 len = (len < sg->length) ? len : sg->length;
1171 if (offset < len) { 1171 if (offset < len) {
1172 page = virt_to_page(page_address(sg->page) + offset); 1172 page = virt_to_page(page_address(sg_page(sg)) + offset);
1173 get_page(page); /* increment page count */ 1173 get_page(page); /* increment page count */
1174 break; 1174 break;
1175 } 1175 }
@@ -1717,13 +1717,13 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1717 goto out_unlock; */ 1717 goto out_unlock; */
1718 } 1718 }
1719 1719
1720 sgl[0].page = pages[0]; 1720 sg_set_page(sgl, pages[0]);
1721 sgl[0].offset = uaddr & ~PAGE_MASK; 1721 sgl[0].offset = uaddr & ~PAGE_MASK;
1722 if (nr_pages > 1) { 1722 if (nr_pages > 1) {
1723 sgl[0].length = PAGE_SIZE - sgl[0].offset; 1723 sgl[0].length = PAGE_SIZE - sgl[0].offset;
1724 count -= sgl[0].length; 1724 count -= sgl[0].length;
1725 for (i=1; i < nr_pages ; i++) { 1725 for (i=1; i < nr_pages ; i++) {
1726 sgl[i].page = pages[i]; 1726 sg_set_page(&sgl[i], pages[i]);
1727 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; 1727 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
1728 count -= PAGE_SIZE; 1728 count -= PAGE_SIZE;
1729 } 1729 }
@@ -1754,7 +1754,7 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
1754 int i; 1754 int i;
1755 1755
1756 for (i=0; i < nr_pages; i++) { 1756 for (i=0; i < nr_pages; i++) {
1757 struct page *page = sgl[i].page; 1757 struct page *page = sg_page(&sgl[i]);
1758 1758
1759 if (dirtied) 1759 if (dirtied)
1760 SetPageDirty(page); 1760 SetPageDirty(page);
@@ -1854,7 +1854,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1854 scatter_elem_sz_prev = ret_sz; 1854 scatter_elem_sz_prev = ret_sz;
1855 } 1855 }
1856 } 1856 }
1857 sg->page = p; 1857 sg_set_page(sg, p);
1858 sg->length = (ret_sz > num) ? num : ret_sz; 1858 sg->length = (ret_sz > num) ? num : ret_sz;
1859 1859
1860 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " 1860 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
@@ -1907,14 +1907,14 @@ sg_write_xfer(Sg_request * srp)
1907 onum = 1; 1907 onum = 1;
1908 1908
1909 ksglen = sg->length; 1909 ksglen = sg->length;
1910 p = page_address(sg->page); 1910 p = page_address(sg_page(sg));
1911 for (j = 0, k = 0; j < onum; ++j) { 1911 for (j = 0, k = 0; j < onum; ++j) {
1912 res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); 1912 res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up);
1913 if (res) 1913 if (res)
1914 return res; 1914 return res;
1915 1915
1916 for (; p; sg = sg_next(sg), ksglen = sg->length, 1916 for (; p; sg = sg_next(sg), ksglen = sg->length,
1917 p = page_address(sg->page)) { 1917 p = page_address(sg_page(sg))) {
1918 if (usglen <= 0) 1918 if (usglen <= 0)
1919 break; 1919 break;
1920 if (ksglen > usglen) { 1920 if (ksglen > usglen) {
@@ -1991,12 +1991,12 @@ sg_remove_scat(Sg_scatter_hold * schp)
1991 } else { 1991 } else {
1992 int k; 1992 int k;
1993 1993
1994 for (k = 0; (k < schp->k_use_sg) && sg->page; 1994 for (k = 0; (k < schp->k_use_sg) && sg_page(sg);
1995 ++k, sg = sg_next(sg)) { 1995 ++k, sg = sg_next(sg)) {
1996 SCSI_LOG_TIMEOUT(5, printk( 1996 SCSI_LOG_TIMEOUT(5, printk(
1997 "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", 1997 "sg_remove_scat: k=%d, pg=0x%p, len=%d\n",
1998 k, sg->page, sg->length)); 1998 k, sg_page(sg), sg->length));
1999 sg_page_free(sg->page, sg->length); 1999 sg_page_free(sg_page(sg), sg->length);
2000 } 2000 }
2001 } 2001 }
2002 kfree(schp->buffer); 2002 kfree(schp->buffer);
@@ -2038,7 +2038,7 @@ sg_read_xfer(Sg_request * srp)
2038 } else 2038 } else
2039 onum = 1; 2039 onum = 1;
2040 2040
2041 p = page_address(sg->page); 2041 p = page_address(sg_page(sg));
2042 ksglen = sg->length; 2042 ksglen = sg->length;
2043 for (j = 0, k = 0; j < onum; ++j) { 2043 for (j = 0, k = 0; j < onum; ++j) {
2044 res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); 2044 res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up);
@@ -2046,7 +2046,7 @@ sg_read_xfer(Sg_request * srp)
2046 return res; 2046 return res;
2047 2047
2048 for (; p; sg = sg_next(sg), ksglen = sg->length, 2048 for (; p; sg = sg_next(sg), ksglen = sg->length,
2049 p = page_address(sg->page)) { 2049 p = page_address(sg_page(sg))) {
2050 if (usglen <= 0) 2050 if (usglen <= 0)
2051 break; 2051 break;
2052 if (ksglen > usglen) { 2052 if (ksglen > usglen) {
@@ -2092,15 +2092,15 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer)
2092 if ((!outp) || (num_read_xfer <= 0)) 2092 if ((!outp) || (num_read_xfer <= 0))
2093 return 0; 2093 return 0;
2094 2094
2095 for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, sg = sg_next(sg)) { 2095 for (k = 0; (k < schp->k_use_sg) && sg_page(sg); ++k, sg = sg_next(sg)) {
2096 num = sg->length; 2096 num = sg->length;
2097 if (num > num_read_xfer) { 2097 if (num > num_read_xfer) {
2098 if (__copy_to_user(outp, page_address(sg->page), 2098 if (__copy_to_user(outp, page_address(sg_page(sg)),
2099 num_read_xfer)) 2099 num_read_xfer))
2100 return -EFAULT; 2100 return -EFAULT;
2101 break; 2101 break;
2102 } else { 2102 } else {
2103 if (__copy_to_user(outp, page_address(sg->page), 2103 if (__copy_to_user(outp, page_address(sg_page(sg)),
2104 num)) 2104 num))
2105 return -EFAULT; 2105 return -EFAULT;
2106 num_read_xfer -= num; 2106 num_read_xfer -= num;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 73c44cbdea47..ce69b9efc102 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3797,7 +3797,7 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
3797 sg = &(STbp->sg[0]); 3797 sg = &(STbp->sg[0]);
3798 frp = STbp->frp; 3798 frp = STbp->frp;
3799 for (i=count=0; count < length; i++) { 3799 for (i=count=0; count < length; i++) {
3800 sg[i].page = frp[i].page; 3800 sg_set_page(&sg[i], frp[i].page);
3801 if (length - count > frp[i].length) 3801 if (length - count > frp[i].length)
3802 sg[i].length = frp[i].length; 3802 sg[i].length = frp[i].length;
3803 else 3803 else
@@ -4446,14 +4446,14 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4446 } 4446 }
4447 4447
4448 /* Populate the scatter/gather list */ 4448 /* Populate the scatter/gather list */
4449 sgl[0].page = pages[0]; 4449 sg_set_page(&sgl[0], pages[0]);
4450 sgl[0].offset = uaddr & ~PAGE_MASK; 4450 sgl[0].offset = uaddr & ~PAGE_MASK;
4451 if (nr_pages > 1) { 4451 if (nr_pages > 1) {
4452 sgl[0].length = PAGE_SIZE - sgl[0].offset; 4452 sgl[0].length = PAGE_SIZE - sgl[0].offset;
4453 count -= sgl[0].length; 4453 count -= sgl[0].length;
4454 for (i=1; i < nr_pages ; i++) { 4454 for (i=1; i < nr_pages ; i++) {
4455 sg_set_page(&sgl[i], pages[i]);;
4455 sgl[i].offset = 0; 4456 sgl[i].offset = 0;
4456 sgl[i].page = pages[i];
4457 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; 4457 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
4458 count -= PAGE_SIZE; 4458 count -= PAGE_SIZE;
4459 } 4459 }
@@ -4483,7 +4483,7 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p
4483 int i; 4483 int i;
4484 4484
4485 for (i=0; i < nr_pages; i++) { 4485 for (i=0; i < nr_pages; i++) {
4486 struct page *page = sgl[i].page; 4486 struct page *page = sg_page(&sgl[i]);
4487 4487
4488 if (dirtied) 4488 if (dirtied)
4489 SetPageDirty(page); 4489 SetPageDirty(page);
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 4aafe89b557f..2dcde373b20e 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -272,8 +272,7 @@ static struct scsi_host_template *the_template = NULL;
272#define HOSTNO instance->host_no 272#define HOSTNO instance->host_no
273#define H_NO(cmd) (cmd)->device->host->host_no 273#define H_NO(cmd) (cmd)->device->host->host_no
274 274
275#define SGADDR(buffer) (void *)(((unsigned long)page_address((buffer)->page)) + \ 275#define SGADDR(buffer) (void *)(((unsigned long)sg_virt(((buffer)))))
276 (buffer)->offset)
277 276
278#ifdef SUPPORT_TAGS 277#ifdef SUPPORT_TAGS
279 278
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
index 8befab7e9839..90cee94d9522 100644
--- a/drivers/scsi/sym53c416.c
+++ b/drivers/scsi/sym53c416.c
@@ -196,7 +196,7 @@ static unsigned int sym53c416_base_3[2] = {0,0};
196 196
197#define MAXHOSTS 4 197#define MAXHOSTS 4
198 198
199#define SG_ADDRESS(buffer) ((char *) (page_address((buffer)->page)+(buffer)->offset)) 199#define SG_ADDRESS(buffer) ((char *) sg_virt((buffer)))
200 200
201enum phases 201enum phases
202{ 202{
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 5c72ca31a47a..44193049c4ae 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -430,10 +430,7 @@ static __inline__ void dc390_Going_remove (struct dc390_dcb* pDCB, struct dc390_
430 430
431static struct scatterlist* dc390_sg_build_single(struct scatterlist *sg, void *addr, unsigned int length) 431static struct scatterlist* dc390_sg_build_single(struct scatterlist *sg, void *addr, unsigned int length)
432{ 432{
433 memset(sg, 0, sizeof(struct scatterlist)); 433 sg_init_one(sg, addr, length);
434 sg->page = virt_to_page(addr);
435 sg->length = length;
436 sg->offset = (unsigned long)addr & ~PAGE_MASK;
437 return sg; 434 return sg;
438} 435}
439 436
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index ea72bbeb8f9d..6d1f0edd7985 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -681,7 +681,7 @@ static inline void build_sg_list(struct mscp *mscp, struct scsi_cmnd *SCpnt)
681 681
682 max = scsi_sg_count(SCpnt); 682 max = scsi_sg_count(SCpnt);
683 scsi_for_each_sg(SCpnt, sg, max, i) { 683 scsi_for_each_sg(SCpnt, sg, max, i) {
684 mscp->sglist[i].address = isa_page_to_bus(sg->page) + sg->offset; 684 mscp->sglist[i].address = isa_page_to_bus(sg_page(sg)) + sg->offset;
685 mscp->sglist[i].num_bytes = sg->length; 685 mscp->sglist[i].num_bytes = sg->length;
686 transfer_length += sg->length; 686 transfer_length += sg->length;
687 } 687 }
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index 0e8e642fd3b0..fdbb92d1f722 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -410,8 +410,7 @@ wd33c93_queuecommand(struct scsi_cmnd *cmd,
410 if (cmd->use_sg) { 410 if (cmd->use_sg) {
411 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; 411 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
412 cmd->SCp.buffers_residual = cmd->use_sg - 1; 412 cmd->SCp.buffers_residual = cmd->use_sg - 1;
413 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + 413 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
414 cmd->SCp.buffer->offset;
415 cmd->SCp.this_residual = cmd->SCp.buffer->length; 414 cmd->SCp.this_residual = cmd->SCp.buffer->length;
416 } else { 415 } else {
417 cmd->SCp.buffer = NULL; 416 cmd->SCp.buffer = NULL;
@@ -745,8 +744,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd,
745 ++cmd->SCp.buffer; 744 ++cmd->SCp.buffer;
746 --cmd->SCp.buffers_residual; 745 --cmd->SCp.buffers_residual;
747 cmd->SCp.this_residual = cmd->SCp.buffer->length; 746 cmd->SCp.this_residual = cmd->SCp.buffer->length;
748 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + 747 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
749 cmd->SCp.buffer->offset;
750 } 748 }
751 if (!cmd->SCp.this_residual) /* avoid bogus setups */ 749 if (!cmd->SCp.this_residual) /* avoid bogus setups */
752 return; 750 return;
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 255c611e78b8..03cd44f231df 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -1123,7 +1123,7 @@ static int wd7000_queuecommand(struct scsi_cmnd *SCpnt,
1123 any2scsi(scb->maxlen, nseg * sizeof(Sgb)); 1123 any2scsi(scb->maxlen, nseg * sizeof(Sgb));
1124 1124
1125 scsi_for_each_sg(SCpnt, sg, nseg, i) { 1125 scsi_for_each_sg(SCpnt, sg, nseg, i) {
1126 any2scsi(sgb[i].ptr, isa_page_to_bus(sg->page) + sg->offset); 1126 any2scsi(sgb[i].ptr, isa_page_to_bus(sg_page(sg)) + sg->offset);
1127 any2scsi(sgb[i].len, sg->length); 1127 any2scsi(sgb[i].len, sg->length);
1128 } 1128 }
1129 } else { 1129 } else {