aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid Hardeman <david@2gen.com>2005-09-17 03:55:31 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2005-10-29 20:19:43 -0400
commit378f058cc49bcda7fa63d3cd86d2f9a0a5188b1c (patch)
treeed99548aa459054c7b046f0ac96af2cc50683e6e /net
parentd32311fed70d12f14e585feb4653571b1e2b0e6d (diff)
[PATCH] Use sg_set_buf/sg_init_one where applicable
This patch uses sg_set_buf/sg_init_one in some places where it was duplicated. Signed-off-by: David Hardeman <david@2gen.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: Greg KH <greg@kroah.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jeff Garzik <jgarzik@pobox.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c23
2 files changed, 9 insertions, 24 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a970b4727ce8..41edc14851e8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -75,7 +75,7 @@
75#ifdef CONFIG_IPV6_PRIVACY 75#ifdef CONFIG_IPV6_PRIVACY
76#include <linux/random.h> 76#include <linux/random.h>
77#include <linux/crypto.h> 77#include <linux/crypto.h>
78#include <asm/scatterlist.h> 78#include <linux/scatterlist.h>
79#endif 79#endif
80 80
81#include <asm/uaccess.h> 81#include <asm/uaccess.h>
@@ -1217,12 +1217,8 @@ static int __ipv6_regen_rndid(struct inet6_dev *idev)
1217 struct net_device *dev; 1217 struct net_device *dev;
1218 struct scatterlist sg[2]; 1218 struct scatterlist sg[2];
1219 1219
1220 sg[0].page = virt_to_page(idev->entropy); 1220 sg_set_buf(&sg[0], idev->entropy, 8);
1221 sg[0].offset = offset_in_page(idev->entropy); 1221 sg_set_buf(&sg[1], idev->work_eui64, 8);
1222 sg[0].length = 8;
1223 sg[1].page = virt_to_page(idev->work_eui64);
1224 sg[1].offset = offset_in_page(idev->work_eui64);
1225 sg[1].length = 8;
1226 1222
1227 dev = idev->dev; 1223 dev = idev->dev;
1228 1224
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 3f3d5437f02d..e65e1f979275 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -37,7 +37,7 @@
37#include <linux/types.h> 37#include <linux/types.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <asm/scatterlist.h> 40#include <linux/scatterlist.h>
41#include <linux/crypto.h> 41#include <linux/crypto.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/pagemap.h> 43#include <linux/pagemap.h>
@@ -75,9 +75,7 @@ krb5_encrypt(
75 memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm)); 75 memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm));
76 76
77 memcpy(out, in, length); 77 memcpy(out, in, length);
78 sg[0].page = virt_to_page(out); 78 sg_set_buf(&sg[0], out, length);
79 sg[0].offset = offset_in_page(out);
80 sg[0].length = length;
81 79
82 ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv); 80 ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv);
83 81
@@ -117,9 +115,7 @@ krb5_decrypt(
117 memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm)); 115 memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm));
118 116
119 memcpy(out, in, length); 117 memcpy(out, in, length);
120 sg[0].page = virt_to_page(out); 118 sg_set_buf(&sg[0], out, length);
121 sg[0].offset = offset_in_page(out);
122 sg[0].length = length;
123 119
124 ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv); 120 ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv);
125 121
@@ -132,13 +128,6 @@ out:
132 128
133EXPORT_SYMBOL(krb5_decrypt); 129EXPORT_SYMBOL(krb5_decrypt);
134 130
135static void
136buf_to_sg(struct scatterlist *sg, char *ptr, int len) {
137 sg->page = virt_to_page(ptr);
138 sg->offset = offset_in_page(ptr);
139 sg->length = len;
140}
141
142static int 131static int
143process_xdr_buf(struct xdr_buf *buf, int offset, int len, 132process_xdr_buf(struct xdr_buf *buf, int offset, int len,
144 int (*actor)(struct scatterlist *, void *), void *data) 133 int (*actor)(struct scatterlist *, void *), void *data)
@@ -152,7 +141,7 @@ process_xdr_buf(struct xdr_buf *buf, int offset, int len,
152 thislen = buf->head[0].iov_len - offset; 141 thislen = buf->head[0].iov_len - offset;
153 if (thislen > len) 142 if (thislen > len)
154 thislen = len; 143 thislen = len;
155 buf_to_sg(sg, buf->head[0].iov_base + offset, thislen); 144 sg_set_buf(sg, buf->head[0].iov_base + offset, thislen);
156 ret = actor(sg, data); 145 ret = actor(sg, data);
157 if (ret) 146 if (ret)
158 goto out; 147 goto out;
@@ -195,7 +184,7 @@ process_xdr_buf(struct xdr_buf *buf, int offset, int len,
195 thislen = buf->tail[0].iov_len - offset; 184 thislen = buf->tail[0].iov_len - offset;
196 if (thislen > len) 185 if (thislen > len)
197 thislen = len; 186 thislen = len;
198 buf_to_sg(sg, buf->tail[0].iov_base + offset, thislen); 187 sg_set_buf(sg, buf->tail[0].iov_base + offset, thislen);
199 ret = actor(sg, data); 188 ret = actor(sg, data);
200 len -= thislen; 189 len -= thislen;
201 } 190 }
@@ -241,7 +230,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
241 goto out; 230 goto out;
242 231
243 crypto_digest_init(tfm); 232 crypto_digest_init(tfm);
244 buf_to_sg(sg, header, hdrlen); 233 sg_set_buf(sg, header, hdrlen);
245 crypto_digest_update(tfm, sg, 1); 234 crypto_digest_update(tfm, sg, 1);
246 process_xdr_buf(body, body_offset, body->len - body_offset, 235 process_xdr_buf(body, body_offset, body->len - body_offset,
247 checksummer, tfm); 236 checksummer, tfm);