diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2007-10-24 05:20:47 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2007-10-24 05:20:47 -0400 |
commit | 642f149031d70415d9318b919d50b71e4724adbd (patch) | |
tree | e792ad29dedffc6756d55e9d63e18ada35515b4b /drivers | |
parent | bd6dee6f30a0f6943df190b387b5f8fe98a848f3 (diff) |
SG: Change sg_set_page() to take length and offset argument
Most drivers need to set length and offset as well, so may as well fold
those three lines into one.
Add sg_assign_page() for those two locations that only needed to set
the page, where the offset/length is set outside of the function context.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/libata-core.c | 4 | ||||
-rw-r--r-- | drivers/block/cryptoloop.c | 9 | ||||
-rw-r--r-- | drivers/block/ub.c | 9 | ||||
-rw-r--r-- | drivers/ieee1394/dma.c | 4 | ||||
-rw-r--r-- | drivers/infiniband/core/umem.c | 4 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_memfree.c | 9 | ||||
-rw-r--r-- | drivers/md/dm-crypt.c | 8 | ||||
-rw-r--r-- | drivers/media/common/saa7146_core.c | 3 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-udma.c | 6 | ||||
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 10 | ||||
-rw-r--r-- | drivers/net/mlx4/icm.c | 4 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_aux.c | 10 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_def.h | 3 | ||||
-rw-r--r-- | drivers/s390/scsi/zfcp_erp.c | 7 | ||||
-rw-r--r-- | drivers/scsi/ipr.c | 2 | ||||
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 4 | ||||
-rw-r--r-- | drivers/scsi/osst.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 13 | ||||
-rw-r--r-- | drivers/scsi/st.c | 14 |
19 files changed, 41 insertions, 88 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2d147b51c978..b5f7c5913062 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -4689,8 +4689,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4689 | * data in this function or read data in ata_sg_clean. | 4689 | * data in this function or read data in ata_sg_clean. |
4690 | */ | 4690 | */ |
4691 | offset = lsg->offset + lsg->length - qc->pad_len; | 4691 | offset = lsg->offset + lsg->length - qc->pad_len; |
4692 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); | 4692 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT), |
4693 | psg->offset = offset_in_page(offset); | 4693 | qc->pad_len, offset_in_page(offset)); |
4694 | 4694 | ||
4695 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 4695 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
4696 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); | 4696 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); |
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 1b58b010797f..241167878edf 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c | |||
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
150 | u32 iv[4] = { 0, }; | 150 | u32 iv[4] = { 0, }; |
151 | iv[0] = cpu_to_le32(IV & 0xffffffff); | 151 | iv[0] = cpu_to_le32(IV & 0xffffffff); |
152 | 152 | ||
153 | sg_set_page(&sg_in, in_page); | 153 | sg_set_page(&sg_in, in_page, sz, in_offs); |
154 | sg_in.offset = in_offs; | 154 | sg_set_page(&sg_out, out_page, sz, out_offs); |
155 | sg_in.length = sz; | ||
156 | |||
157 | sg_set_page(&sg_out, out_page); | ||
158 | sg_out.offset = out_offs; | ||
159 | sg_out.length = sz; | ||
160 | 155 | ||
161 | desc.info = iv; | 156 | desc.info = iv; |
162 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); | 157 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 14143f2c484d..5e740e14ab35 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -1428,9 +1428,8 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1428 | scmd->state = UB_CMDST_INIT; | 1428 | scmd->state = UB_CMDST_INIT; |
1429 | scmd->nsg = 1; | 1429 | scmd->nsg = 1; |
1430 | sg = &scmd->sgv[0]; | 1430 | sg = &scmd->sgv[0]; |
1431 | sg_set_page(sg, virt_to_page(sc->top_sense)); | 1431 | sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE, |
1432 | sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); | 1432 | (unsigned long)sc->top_sense & (PAGE_SIZE-1)); |
1433 | sg->length = UB_SENSE_SIZE; | ||
1434 | scmd->len = UB_SENSE_SIZE; | 1433 | scmd->len = UB_SENSE_SIZE; |
1435 | scmd->lun = cmd->lun; | 1434 | scmd->lun = cmd->lun; |
1436 | scmd->done = ub_top_sense_done; | 1435 | scmd->done = ub_top_sense_done; |
@@ -1864,9 +1863,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, | |||
1864 | cmd->state = UB_CMDST_INIT; | 1863 | cmd->state = UB_CMDST_INIT; |
1865 | cmd->nsg = 1; | 1864 | cmd->nsg = 1; |
1866 | sg = &cmd->sgv[0]; | 1865 | sg = &cmd->sgv[0]; |
1867 | sg_set_page(sg, virt_to_page(p)); | 1866 | sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1)); |
1868 | sg->offset = (unsigned long)p & (PAGE_SIZE-1); | ||
1869 | sg->length = 8; | ||
1870 | cmd->len = 8; | 1867 | cmd->len = 8; |
1871 | cmd->lun = lun; | 1868 | cmd->lun = lun; |
1872 | cmd->done = ub_probe_done; | 1869 | cmd->done = ub_probe_done; |
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c index 3051e312fdc8..f5f4983dfbf3 100644 --- a/drivers/ieee1394/dma.c +++ b/drivers/ieee1394/dma.c | |||
@@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, | |||
111 | unsigned long va = | 111 | unsigned long va = |
112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); | 112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); |
113 | 113 | ||
114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); | 114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va), |
115 | dma->sglist[i].length = PAGE_SIZE; | 115 | PAGE_SIZE, 0); |
116 | } | 116 | } |
117 | 117 | ||
118 | /* map sglist to the IOMMU */ | 118 | /* map sglist to the IOMMU */ |
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 14159ff29408..4e3128ff73c1 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c | |||
@@ -171,9 +171,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
171 | if (vma_list && | 171 | if (vma_list && |
172 | !is_vm_hugetlb_page(vma_list[i + off])) | 172 | !is_vm_hugetlb_page(vma_list[i + off])) |
173 | umem->hugetlb = 0; | 173 | umem->hugetlb = 0; |
174 | sg_set_page(&chunk->page_list[i], page_list[i + off]); | 174 | sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0); |
175 | chunk->page_list[i].offset = 0; | ||
176 | chunk->page_list[i].length = PAGE_SIZE; | ||
177 | } | 175 | } |
178 | 176 | ||
179 | chunk->nmap = ib_dma_map_sg(context->device, | 177 | chunk->nmap = ib_dma_map_sg(context->device, |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 007b38157fc4..1f4d27d7c16d 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -113,9 +113,7 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m | |||
113 | if (!page) | 113 | if (!page) |
114 | return -ENOMEM; | 114 | return -ENOMEM; |
115 | 115 | ||
116 | sg_set_page(mem, page); | 116 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
117 | mem->length = PAGE_SIZE << order; | ||
118 | mem->offset = 0; | ||
119 | return 0; | 117 | return 0; |
120 | } | 118 | } |
121 | 119 | ||
@@ -481,9 +479,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
481 | if (ret < 0) | 479 | if (ret < 0) |
482 | goto out; | 480 | goto out; |
483 | 481 | ||
484 | sg_set_page(&db_tab->page[i].mem, pages[0]); | 482 | sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, |
485 | db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; | 483 | uaddr & ~PAGE_MASK); |
486 | db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; | ||
487 | 484 | ||
488 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 485 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
489 | if (ret < 0) { | 486 | if (ret < 0) { |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index ac54f697c508..1c159ac68c98 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -351,14 +351,10 @@ static int crypt_convert(struct crypt_config *cc, | |||
351 | struct scatterlist sg_in, sg_out; | 351 | struct scatterlist sg_in, sg_out; |
352 | 352 | ||
353 | sg_init_table(&sg_in, 1); | 353 | sg_init_table(&sg_in, 1); |
354 | sg_set_page(&sg_in, bv_in->bv_page); | 354 | sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in); |
355 | sg_in.offset = bv_in->bv_offset + ctx->offset_in; | ||
356 | sg_in.length = 1 << SECTOR_SHIFT; | ||
357 | 355 | ||
358 | sg_init_table(&sg_out, 1); | 356 | sg_init_table(&sg_out, 1); |
359 | sg_set_page(&sg_out, bv_out->bv_page); | 357 | sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out); |
360 | sg_out.offset = bv_out->bv_offset + ctx->offset_out; | ||
361 | sg_out.length = 1 << SECTOR_SHIFT; | ||
362 | 358 | ||
363 | ctx->offset_in += sg_in.length; | 359 | ctx->offset_in += sg_in.length; |
364 | if (ctx->offset_in >= bv_in->bv_len) { | 360 | if (ctx->offset_in >= bv_in->bv_len) { |
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 2b1f8b4be00a..cb034ead95ab 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -118,8 +118,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
118 | if (NULL == pg) | 118 | if (NULL == pg) |
119 | goto err; | 119 | goto err; |
120 | BUG_ON(PageHighMem(pg)); | 120 | BUG_ON(PageHighMem(pg)); |
121 | sg_set_page(&sglist[i], pg); | 121 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
122 | sglist[i].length = PAGE_SIZE; | ||
123 | } | 122 | } |
124 | return sglist; | 123 | return sglist; |
125 | 124 | ||
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index 912b424e5204..460db03b0ba0 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c | |||
@@ -49,8 +49,6 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
49 | unsigned int len = (i == dma_page->page_count - 1) ? | 49 | unsigned int len = (i == dma_page->page_count - 1) ? |
50 | dma_page->tail : PAGE_SIZE - offset; | 50 | dma_page->tail : PAGE_SIZE - offset; |
51 | 51 | ||
52 | dma->SGlist[map_offset].length = len; | ||
53 | dma->SGlist[map_offset].offset = offset; | ||
54 | if (PageHighMem(dma->map[map_offset])) { | 52 | if (PageHighMem(dma->map[map_offset])) { |
55 | void *src; | 53 | void *src; |
56 | 54 | ||
@@ -63,10 +61,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
63 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); | 61 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); |
64 | kunmap_atomic(src, KM_BOUNCE_READ); | 62 | kunmap_atomic(src, KM_BOUNCE_READ); |
65 | local_irq_restore(flags); | 63 | local_irq_restore(flags); |
66 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); | 64 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset); |
67 | } | 65 | } |
68 | else { | 66 | else { |
69 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); | 67 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset); |
70 | } | 68 | } |
71 | offset = 0; | 69 | offset = 0; |
72 | map_offset++; | 70 | map_offset++; |
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 9ab94a749d81..44ee408e145f 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -67,8 +67,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
67 | if (NULL == pg) | 67 | if (NULL == pg) |
68 | goto err; | 68 | goto err; |
69 | BUG_ON(PageHighMem(pg)); | 69 | BUG_ON(PageHighMem(pg)); |
70 | sg_set_page(&sglist[i], pg); | 70 | sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); |
71 | sglist[i].length = PAGE_SIZE; | ||
72 | } | 71 | } |
73 | return sglist; | 72 | return sglist; |
74 | 73 | ||
@@ -95,16 +94,13 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
95 | if (PageHighMem(pages[0])) | 94 | if (PageHighMem(pages[0])) |
96 | /* DMA to highmem pages might not work */ | 95 | /* DMA to highmem pages might not work */ |
97 | goto highmem; | 96 | goto highmem; |
98 | sg_set_page(&sglist[0], pages[0]); | 97 | sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset); |
99 | sglist[0].offset = offset; | ||
100 | sglist[0].length = PAGE_SIZE - offset; | ||
101 | for (i = 1; i < nr_pages; i++) { | 98 | for (i = 1; i < nr_pages; i++) { |
102 | if (NULL == pages[i]) | 99 | if (NULL == pages[i]) |
103 | goto nopage; | 100 | goto nopage; |
104 | if (PageHighMem(pages[i])) | 101 | if (PageHighMem(pages[i])) |
105 | goto highmem; | 102 | goto highmem; |
106 | sg_set_page(&sglist[i], pages[i]); | 103 | sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0); |
107 | sglist[i].length = PAGE_SIZE; | ||
108 | } | 104 | } |
109 | return sglist; | 105 | return sglist; |
110 | 106 | ||
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 887633b207d9..2a5bef6388fe 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
@@ -101,9 +101,7 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma | |||
101 | if (!page) | 101 | if (!page) |
102 | return -ENOMEM; | 102 | return -ENOMEM; |
103 | 103 | ||
104 | sg_set_page(mem, page); | 104 | sg_set_page(mem, page, PAGE_SIZE << order, 0); |
105 | mem->length = PAGE_SIZE << order; | ||
106 | mem->offset = 0; | ||
107 | return 0; | 105 | return 0; |
108 | } | 106 | } |
109 | 107 | ||
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index d9e7be979760..00118499018b 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -562,8 +562,6 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
562 | sg_init_table(sg_list->sg, sg_list->count); | 562 | sg_init_table(sg_list->sg, sg_list->count); |
563 | 563 | ||
564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { | 564 | for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { |
565 | sg->length = min(size, PAGE_SIZE); | ||
566 | sg->offset = 0; | ||
567 | address = (void *) get_zeroed_page(GFP_KERNEL); | 565 | address = (void *) get_zeroed_page(GFP_KERNEL); |
568 | if (address == NULL) { | 566 | if (address == NULL) { |
569 | sg_list->count = i; | 567 | sg_list->count = i; |
@@ -571,7 +569,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size) | |||
571 | retval = -ENOMEM; | 569 | retval = -ENOMEM; |
572 | goto out; | 570 | goto out; |
573 | } | 571 | } |
574 | zfcp_address_to_sg(address, sg); | 572 | zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE)); |
575 | size -= sg->length; | 573 | size -= sg->length; |
576 | } | 574 | } |
577 | 575 | ||
@@ -1523,10 +1521,8 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool) | |||
1523 | data->ct.req = &data->req; | 1521 | data->ct.req = &data->req; |
1524 | data->ct.resp = &data->resp; | 1522 | data->ct.resp = &data->resp; |
1525 | data->ct.req_count = data->ct.resp_count = 1; | 1523 | data->ct.req_count = data->ct.resp_count = 1; |
1526 | zfcp_address_to_sg(&data->ct_iu_req, &data->req); | 1524 | zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req)); |
1527 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); | 1525 | zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp)); |
1528 | data->req.length = sizeof(struct ct_iu_gid_pn_req); | ||
1529 | data->resp.length = sizeof(struct ct_iu_gid_pn_resp); | ||
1530 | 1526 | ||
1531 | *gid_pn = data; | 1527 | *gid_pn = data; |
1532 | return 0; | 1528 | return 0; |
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 326e7ee232cb..0754542978b6 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h | |||
@@ -74,8 +74,7 @@ zfcp_sg_to_address(struct scatterlist *list) | |||
74 | static inline void | 74 | static inline void |
75 | zfcp_address_to_sg(void *address, struct scatterlist *list) | 75 | zfcp_address_to_sg(void *address, struct scatterlist *list) |
76 | { | 76 | { |
77 | sg_set_page(list, virt_to_page(address)); | 77 | sg_set_buf(list, address, 0); |
78 | list->offset = ((unsigned long) address) & (PAGE_SIZE - 1); | ||
79 | } | 78 | } |
80 | 79 | ||
81 | #define REQUEST_LIST_SIZE 128 | 80 | #define REQUEST_LIST_SIZE 128 |
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index 9438d0b28799..5552b755c08a 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c | |||
@@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
322 | if (address == NULL) | 322 | if (address == NULL) |
323 | goto nomem; | 323 | goto nomem; |
324 | 324 | ||
325 | zfcp_address_to_sg(address, send_els->req); | 325 | zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc)); |
326 | address += PAGE_SIZE >> 1; | 326 | address += PAGE_SIZE >> 1; |
327 | zfcp_address_to_sg(address, send_els->resp); | 327 | zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc)); |
328 | send_els->req_count = send_els->resp_count = 1; | 328 | send_els->req_count = send_els->resp_count = 1; |
329 | 329 | ||
330 | send_els->adapter = adapter; | 330 | send_els->adapter = adapter; |
@@ -336,9 +336,6 @@ zfcp_erp_adisc(struct zfcp_port *port) | |||
336 | adisc = zfcp_sg_to_address(send_els->req); | 336 | adisc = zfcp_sg_to_address(send_els->req); |
337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; | 337 | send_els->ls_code = adisc->code = ZFCP_LS_ADISC; |
338 | 338 | ||
339 | send_els->req->length = sizeof(struct zfcp_ls_adisc); | ||
340 | send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc); | ||
341 | |||
342 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports | 339 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports |
343 | without FC-AL-2 capability, so we don't set it */ | 340 | without FC-AL-2 capability, so we don't set it */ |
344 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); | 341 | adisc->wwpn = fc_host_port_name(adapter->scsi_host); |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 439b97a6a269..0841df01bc19 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) | |||
2890 | return NULL; | 2890 | return NULL; |
2891 | } | 2891 | } |
2892 | 2892 | ||
2893 | sg_set_page(&scatterlist[i], page); | 2893 | sg_set_page(&scatterlist[i], page, 0, 0); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | return sglist; | 2896 | return sglist; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 6ce4109efdf3..097a136398cb 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -79,9 +79,7 @@ static inline void | |||
79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) | 79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) |
80 | { | 80 | { |
81 | sg_init_table(&ibuf->sg, 1); | 81 | sg_init_table(&ibuf->sg, 1); |
82 | sg_set_page(&ibuf->sg, sg_page(sg)); | 82 | sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset); |
83 | ibuf->sg.offset = sg->offset; | ||
84 | ibuf->sg.length = sg->length; | ||
85 | /* | 83 | /* |
86 | * Fastpath: sg element fits into single page | 84 | * Fastpath: sg element fits into single page |
87 | */ | 85 | */ |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 1c5c4b68f20f..4652ad22516b 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -5256,8 +5256,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5256 | 5256 | ||
5257 | STbuffer->sg[0].offset = 0; | 5257 | STbuffer->sg[0].offset = 0; |
5258 | if (page != NULL) { | 5258 | if (page != NULL) { |
5259 | sg_set_page(&STbuffer->sg[0], page); | 5259 | sg_set_page(&STbuffer->sg[0], page, b_size, 0); |
5260 | STbuffer->sg[0].length = b_size; | ||
5261 | STbuffer->b_data = page_address(page); | 5260 | STbuffer->b_data = page_address(page); |
5262 | break; | 5261 | break; |
5263 | } | 5262 | } |
@@ -5285,8 +5284,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
5285 | normalize_buffer(STbuffer); | 5284 | normalize_buffer(STbuffer); |
5286 | return 0; | 5285 | return 0; |
5287 | } | 5286 | } |
5288 | sg_set_page(&STbuffer->sg[segs], page); | 5287 | sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0); |
5289 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; | ||
5290 | got += STbuffer->sg[segs].length; | 5288 | got += STbuffer->sg[segs].length; |
5291 | STbuffer->buffer_size = got; | 5289 | STbuffer->buffer_size = got; |
5292 | STbuffer->sg_segs = ++segs; | 5290 | STbuffer->sg_segs = ++segs; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index cc1971002846..b5fa4f091387 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1717,16 +1717,12 @@ 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 | sg_set_page(sgl, pages[0]); | 1720 | sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK); |
1721 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
1722 | if (nr_pages > 1) { | 1721 | if (nr_pages > 1) { |
1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 1722 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
1724 | count -= sgl[0].length; | 1723 | count -= sgl[0].length; |
1725 | for (i=1; i < nr_pages ; i++) { | 1724 | for (i=1; i < nr_pages ; i++) |
1726 | sg_set_page(&sgl[i], pages[i]); | 1725 | sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0); |
1727 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
1728 | count -= PAGE_SIZE; | ||
1729 | } | ||
1730 | } | 1726 | } |
1731 | else { | 1727 | else { |
1732 | sgl[0].length = count; | 1728 | sgl[0].length = count; |
@@ -1854,8 +1850,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1854 | scatter_elem_sz_prev = ret_sz; | 1850 | scatter_elem_sz_prev = ret_sz; |
1855 | } | 1851 | } |
1856 | } | 1852 | } |
1857 | sg_set_page(sg, p); | 1853 | sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0); |
1858 | sg->length = (ret_sz > num) ? num : ret_sz; | ||
1859 | 1854 | ||
1860 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " | 1855 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " |
1861 | "ret_sz=%d\n", k, num, ret_sz)); | 1856 | "ret_sz=%d\n", k, num, ret_sz)); |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index ce69b9efc102..98dfd6ea209c 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -3797,13 +3797,11 @@ 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_set_page(&sg[i], frp[i].page); | ||
3801 | if (length - count > frp[i].length) | 3800 | if (length - count > frp[i].length) |
3802 | sg[i].length = frp[i].length; | 3801 | sg_set_page(&sg[i], frp[i].page, frp[i].length, 0); |
3803 | else | 3802 | else |
3804 | sg[i].length = length - count; | 3803 | sg_set_page(&sg[i], frp[i].page, length - count, 0); |
3805 | count += sg[i].length; | 3804 | count += sg[i].length; |
3806 | sg[i].offset = 0; | ||
3807 | } | 3805 | } |
3808 | STbp->sg_segs = i; | 3806 | STbp->sg_segs = i; |
3809 | STbp->frp_sg_current = length; | 3807 | STbp->frp_sg_current = length; |
@@ -4446,15 +4444,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa | |||
4446 | } | 4444 | } |
4447 | 4445 | ||
4448 | /* Populate the scatter/gather list */ | 4446 | /* Populate the scatter/gather list */ |
4449 | sg_set_page(&sgl[0], pages[0]); | 4447 | sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK); |
4450 | sgl[0].offset = uaddr & ~PAGE_MASK; | ||
4451 | if (nr_pages > 1) { | 4448 | if (nr_pages > 1) { |
4452 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 4449 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
4453 | count -= sgl[0].length; | 4450 | count -= sgl[0].length; |
4454 | for (i=1; i < nr_pages ; i++) { | 4451 | for (i=1; i < nr_pages ; i++) { |
4455 | sg_set_page(&sgl[i], pages[i]);; | 4452 | sg_set_page(&sgl[i], pages[i], |
4456 | sgl[i].offset = 0; | 4453 | count < PAGE_SIZE ? count : PAGE_SIZE, 0);; |
4457 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | ||
4458 | count -= PAGE_SIZE; | 4454 | count -= PAGE_SIZE; |
4459 | } | 4455 | } |
4460 | } | 4456 | } |