summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2011-12-14 10:43:06 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-14 14:50:12 -0500
commit7c7cd3bfec68fee33b30d177df6a6a0c4bbdc59d (patch)
tree7b7332d63303d30c73b4ecd8a300e84d801baa33 /net
parent52858b51b2c779a8f9db32accf774b165522ad81 (diff)
NFC: Add tx skb allocation routine
This is a factorization of the current rawsock tx skb allocation routine, as it will be used by the LLCP code. We also rename nfc_alloc_skb to nfc_alloc_recv_skb for consistency sake. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/core.c30
-rw-r--r--net/nfc/rawsock.c7
2 files changed, 29 insertions, 8 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 2a838b099d82..f53f88ada687 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/nfc.h>
30 31
31#include "nfc.h" 32#include "nfc.h"
32 33
@@ -275,12 +276,35 @@ error:
275} 276}
276 277
277/** 278/**
278 * nfc_alloc_skb - allocate a skb for data exchange responses 279 * nfc_alloc_send_skb - allocate a skb for data exchange responses
279 * 280 *
280 * @size: size to allocate 281 * @size: size to allocate
281 * @gfp: gfp flags 282 * @gfp: gfp flags
282 */ 283 */
283struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp) 284struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
285 unsigned int flags, unsigned int size,
286 unsigned int *err)
287{
288 struct sk_buff *skb;
289 unsigned int total_size;
290
291 total_size = size +
292 dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
293
294 skb = sock_alloc_send_skb(sk, total_size, flags & MSG_DONTWAIT, err);
295 if (skb)
296 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
297
298 return skb;
299}
300
301/**
302 * nfc_alloc_recv_skb - allocate a skb for data exchange responses
303 *
304 * @size: size to allocate
305 * @gfp: gfp flags
306 */
307struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp)
284{ 308{
285 struct sk_buff *skb; 309 struct sk_buff *skb;
286 unsigned int total_size; 310 unsigned int total_size;
@@ -293,7 +317,7 @@ struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp)
293 317
294 return skb; 318 return skb;
295} 319}
296EXPORT_SYMBOL(nfc_alloc_skb); 320EXPORT_SYMBOL(nfc_alloc_recv_skb);
297 321
298/** 322/**
299 * nfc_targets_found - inform that targets were found 323 * nfc_targets_found - inform that targets were found
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index 5e9b991eac13..11ac0a17156e 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -208,13 +208,10 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
208 if (sock->state != SS_CONNECTED) 208 if (sock->state != SS_CONNECTED)
209 return -ENOTCONN; 209 return -ENOTCONN;
210 210
211 skb = sock_alloc_send_skb(sk, len + dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE, 211 skb = nfc_alloc_send_skb(dev, sk, msg->msg_flags, len, &rc);
212 msg->msg_flags & MSG_DONTWAIT, &rc); 212 if (skb == NULL)
213 if (!skb)
214 return rc; 213 return rc;
215 214
216 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
217
218 rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); 215 rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
219 if (rc < 0) { 216 if (rc < 0) {
220 kfree_skb(skb); 217 kfree_skb(skb);