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