aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
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/sg.c
parent78c2f0b8c285c5305b3e67b0595200541e15eb43 (diff)
[SG] Update drivers to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c30
1 files changed, 15 insertions, 15 deletions
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;