From 642f149031d70415d9318b919d50b71e4724adbd Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 24 Oct 2007 11:20:47 +0200 Subject: 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 --- fs/ecryptfs/crypto.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'fs') diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 0a9882edf562..7a472b129997 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -282,10 +282,8 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, while (size > 0 && i < sg_size) { pg = virt_to_page(addr); offset = offset_in_page(addr); - if (sg) { - sg_set_page(&sg[i], pg); - sg[i].offset = offset; - } + if (sg) + sg_set_page(&sg[i], pg, 0, offset); remainder_of_page = PAGE_CACHE_SIZE - offset; if (size >= remainder_of_page) { if (sg) @@ -716,12 +714,8 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, sg_init_table(&src_sg, 1); sg_init_table(&dst_sg, 1); - sg_set_page(&src_sg, src_page); - src_sg.offset = src_offset; - src_sg.length = size; - sg_set_page(&dst_sg, dst_page); - dst_sg.offset = dst_offset; - dst_sg.length = size; + sg_set_page(&src_sg, src_page, size, src_offset); + sg_set_page(&dst_sg, dst_page, size, dst_offset); return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); } @@ -746,14 +740,11 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, struct scatterlist src_sg, dst_sg; sg_init_table(&src_sg, 1); + sg_set_page(&src_sg, src_page, size, src_offset); + sg_init_table(&dst_sg, 1); + sg_set_page(&dst_sg, dst_page, size, dst_offset); - sg_set_page(&src_sg, src_page); - src_sg.offset = src_offset; - src_sg.length = size; - sg_set_page(&dst_sg, dst_page); - dst_sg.offset = dst_offset; - dst_sg.length = size; return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); } -- cgit v1.2.3-58-ga151