aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-10-04 17:41:00 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:54:33 -0400
commitcd1f7d347c9e51f348119811bd41b74346ec57b8 (patch)
tree1c444753fb2587fbeaeb2679facbeff03903f8b3 /net/dccp
parent126acd5bf769fcb80e38a5360ad12b842d6d29d4 (diff)
[CCID2]: Simplify interface
This patch simplifies the interface of ccid2_hc_tx_alloc_seq(): * ccid2_hc_tx_alloc_seq() is always called with an argument of CCID2_SEQBUF_LEN; * other code - ccid2_hc_tx_check_sanity() - even depends on the assumption that ccid2_hc_tx_alloc_seq() has been called with this particular size; * passing the `gfp_t' argument to ccid2_hc_tx_alloc_seq() is redundant with gfp_any(). Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r--net/dccp/ccids/ccid2.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index c199f34c1940..5c6b4f97a664 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -83,8 +83,7 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
83#define ccid2_hc_tx_check_sanity(hctx) 83#define ccid2_hc_tx_check_sanity(hctx)
84#endif 84#endif
85 85
86static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num, 86static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx)
87 gfp_t gfp)
88{ 87{
89 struct ccid2_seq *seqp; 88 struct ccid2_seq *seqp;
90 int i; 89 int i;
@@ -95,16 +94,16 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
95 return -ENOMEM; 94 return -ENOMEM;
96 95
97 /* allocate buffer and initialize linked list */ 96 /* allocate buffer and initialize linked list */
98 seqp = kmalloc(sizeof(*seqp) * num, gfp); 97 seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any());
99 if (seqp == NULL) 98 if (seqp == NULL)
100 return -ENOMEM; 99 return -ENOMEM;
101 100
102 for (i = 0; i < (num - 1); i++) { 101 for (i = 0; i < (CCID2_SEQBUF_LEN - 1); i++) {
103 seqp[i].ccid2s_next = &seqp[i + 1]; 102 seqp[i].ccid2s_next = &seqp[i + 1];
104 seqp[i + 1].ccid2s_prev = &seqp[i]; 103 seqp[i + 1].ccid2s_prev = &seqp[i];
105 } 104 }
106 seqp[num - 1].ccid2s_next = seqp; 105 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = seqp;
107 seqp->ccid2s_prev = &seqp[num - 1]; 106 seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
108 107
109 /* This is the first allocation. Initiate the head and tail. */ 108 /* This is the first allocation. Initiate the head and tail. */
110 if (hctx->ccid2hctx_seqbufc == 0) 109 if (hctx->ccid2hctx_seqbufc == 0)
@@ -114,8 +113,8 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
114 hctx->ccid2hctx_seqh->ccid2s_next = seqp; 113 hctx->ccid2hctx_seqh->ccid2s_next = seqp;
115 seqp->ccid2s_prev = hctx->ccid2hctx_seqh; 114 seqp->ccid2s_prev = hctx->ccid2hctx_seqh;
116 115
117 hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[num - 1]; 116 hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1];
118 seqp[num - 1].ccid2s_next = hctx->ccid2hctx_seqt; 117 seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->ccid2hctx_seqt;
119 } 118 }
120 119
121 /* store the original pointer to the buffer so we can free it */ 120 /* store the original pointer to the buffer so we can free it */
@@ -298,7 +297,7 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
298 int rc; 297 int rc;
299 298
300 ccid2_pr_debug("allocating more space in history\n"); 299 ccid2_pr_debug("allocating more space in history\n");
301 rc = ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, gfp_any()); 300 rc = ccid2_hc_tx_alloc_seq(hctx);
302 BUG_ON(rc); /* XXX what do we do? */ 301 BUG_ON(rc); /* XXX what do we do? */
303 302
304 next = hctx->ccid2hctx_seqh->ccid2s_next; 303 next = hctx->ccid2hctx_seqh->ccid2s_next;
@@ -771,7 +770,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
771 hctx->ccid2hctx_seqbufc = 0; 770 hctx->ccid2hctx_seqbufc = 0;
772 771
773 /* XXX init ~ to window size... */ 772 /* XXX init ~ to window size... */
774 if (ccid2_hc_tx_alloc_seq(hctx, CCID2_SEQBUF_LEN, GFP_ATOMIC) != 0) 773 if (ccid2_hc_tx_alloc_seq(hctx))
775 return -ENOMEM; 774 return -ENOMEM;
776 775
777 hctx->ccid2hctx_sent = 0; 776 hctx->ccid2hctx_sent = 0;