aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSimon Derr <simon.derr@bull.net>2013-06-21 09:32:36 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2013-07-07 23:02:27 -0400
commit5387320d4814aa1e40b50529d960a8f2b3340535 (patch)
tree87b7a46b37e7f2800e65f7e159c9c99d03c65e31 /net
parent17b6fd9d6dfa0faed3a25a6045f7456821ea140a (diff)
9pnet: refactor struct p9_fcall alloc code
Signed-off-by: Simon Derr <simon.derr@bull.net> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/9p/client.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index 5828769d1f3d..db5bf2480a33 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -204,6 +204,17 @@ free_and_return:
204 return ret; 204 return ret;
205} 205}
206 206
207struct p9_fcall *p9_fcall_alloc(int alloc_msize)
208{
209 struct p9_fcall *fc;
210 fc = kmalloc(sizeof(struct p9_fcall) + alloc_msize, GFP_NOFS);
211 if (!fc)
212 return NULL;
213 fc->capacity = alloc_msize;
214 fc->sdata = (char *) fc + sizeof(struct p9_fcall);
215 return fc;
216}
217
207/** 218/**
208 * p9_tag_alloc - lookup/allocate a request by tag 219 * p9_tag_alloc - lookup/allocate a request by tag
209 * @c: client session to lookup tag within 220 * @c: client session to lookup tag within
@@ -256,29 +267,19 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
256 col = tag % P9_ROW_MAXTAG; 267 col = tag % P9_ROW_MAXTAG;
257 268
258 req = &c->reqs[row][col]; 269 req = &c->reqs[row][col];
259 if (!req->tc) { 270 if (!req->wq) {
260 req->wq = kmalloc(sizeof(wait_queue_head_t), GFP_NOFS); 271 req->wq = kmalloc(sizeof(wait_queue_head_t), GFP_NOFS);
261 if (!req->wq) 272 if (!req->wq)
262 goto grow_failed; 273 goto grow_failed;
263
264 init_waitqueue_head(req->wq); 274 init_waitqueue_head(req->wq);
265 req->tc = kmalloc(sizeof(struct p9_fcall) + alloc_msize,
266 GFP_NOFS);
267 if (!req->tc)
268 goto grow_failed;
269
270 req->tc->capacity = alloc_msize;
271 req->tc->sdata = (char *) req->tc + sizeof(struct p9_fcall);
272 } 275 }
273 if (!req->rc) {
274 req->rc = kmalloc(sizeof(struct p9_fcall) + alloc_msize,
275 GFP_NOFS);
276 if (!req->rc)
277 goto grow_failed;
278 276
279 req->rc->capacity = alloc_msize; 277 if (!req->tc)
280 req->rc->sdata = (char *) req->rc + sizeof(struct p9_fcall); 278 req->tc = p9_fcall_alloc(alloc_msize);
281 } 279 if (!req->rc)
280 req->rc = p9_fcall_alloc(alloc_msize);
281 if (!req->tc || !req->rc)
282 goto grow_failed;
282 283
283 p9pdu_reset(req->tc); 284 p9pdu_reset(req->tc);
284 p9pdu_reset(req->rc); 285 p9pdu_reset(req->rc);