Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278960
b: refs/heads/master
c: 7c7cd3b
h: refs/heads/master
v: v3
  • Loading branch information
Samuel Ortiz authored and John W. Linville committed Dec 14, 2011
1 parent 6297f8b commit 3e35212
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 52858b51b2c779a8f9db32accf774b165522ad81
refs/heads/master: 7c7cd3bfec68fee33b30d177df6a6a0c4bbdc59d
2 changes: 1 addition & 1 deletion trunk/drivers/nfc/pn533.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ static int pn533_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx,
PN533_CMD_DATAEXCH_DATA_MAXLEN +
PN533_FRAME_TAIL_SIZE;

skb_resp = nfc_alloc_skb(skb_resp_len, GFP_KERNEL);
skb_resp = nfc_alloc_recv_skb(skb_resp_len, GFP_KERNEL);
if (!skb_resp) {
rc = -ENOMEM;
goto error;
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/net/nfc/nfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ static inline const char *nfc_device_name(struct nfc_dev *dev)
return dev_name(&dev->dev);
}

struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp);
struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
unsigned int flags, unsigned int size,
unsigned int *err);
struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp);

int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
int ntargets);
Expand Down
30 changes: 27 additions & 3 deletions trunk/net/nfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/nfc.h>

#include "nfc.h"

Expand Down Expand Up @@ -275,12 +276,35 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
}

/**
* nfc_alloc_skb - allocate a skb for data exchange responses
* nfc_alloc_send_skb - allocate a skb for data exchange responses
*
* @size: size to allocate
* @gfp: gfp flags
*/
struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp)
struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
unsigned int flags, unsigned int size,
unsigned int *err)
{
struct sk_buff *skb;
unsigned int total_size;

total_size = size +
dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;

skb = sock_alloc_send_skb(sk, total_size, flags & MSG_DONTWAIT, err);
if (skb)
skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);

return skb;
}

/**
* nfc_alloc_recv_skb - allocate a skb for data exchange responses
*
* @size: size to allocate
* @gfp: gfp flags
*/
struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp)
{
struct sk_buff *skb;
unsigned int total_size;
Expand All @@ -293,7 +317,7 @@ struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp)

return skb;
}
EXPORT_SYMBOL(nfc_alloc_skb);
EXPORT_SYMBOL(nfc_alloc_recv_skb);

/**
* nfc_targets_found - inform that targets were found
Expand Down
7 changes: 2 additions & 5 deletions trunk/net/nfc/rawsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,10 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
if (sock->state != SS_CONNECTED)
return -ENOTCONN;

skb = sock_alloc_send_skb(sk, len + dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE,
msg->msg_flags & MSG_DONTWAIT, &rc);
if (!skb)
skb = nfc_alloc_send_skb(dev, sk, msg->msg_flags, len, &rc);
if (skb == NULL)
return rc;

skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);

rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
if (rc < 0) {
kfree_skb(skb);
Expand Down

0 comments on commit 3e35212

Please sign in to comment.