diff options
Diffstat (limited to 'net/nfc/rawsock.c')
-rw-r--r-- | net/nfc/rawsock.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index ee7b2b365ef2..2e2f8c6a61fe 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ | ||
25 | |||
24 | #include <net/tcp_states.h> | 26 | #include <net/tcp_states.h> |
25 | #include <linux/nfc.h> | 27 | #include <linux/nfc.h> |
26 | #include <linux/export.h> | 28 | #include <linux/export.h> |
@@ -29,7 +31,7 @@ | |||
29 | 31 | ||
30 | static void rawsock_write_queue_purge(struct sock *sk) | 32 | static void rawsock_write_queue_purge(struct sock *sk) |
31 | { | 33 | { |
32 | nfc_dbg("sk=%p", sk); | 34 | pr_debug("sk=%p\n", sk); |
33 | 35 | ||
34 | spin_lock_bh(&sk->sk_write_queue.lock); | 36 | spin_lock_bh(&sk->sk_write_queue.lock); |
35 | __skb_queue_purge(&sk->sk_write_queue); | 37 | __skb_queue_purge(&sk->sk_write_queue); |
@@ -39,7 +41,7 @@ static void rawsock_write_queue_purge(struct sock *sk) | |||
39 | 41 | ||
40 | static void rawsock_report_error(struct sock *sk, int err) | 42 | static void rawsock_report_error(struct sock *sk, int err) |
41 | { | 43 | { |
42 | nfc_dbg("sk=%p err=%d", sk, err); | 44 | pr_debug("sk=%p err=%d\n", sk, err); |
43 | 45 | ||
44 | sk->sk_shutdown = SHUTDOWN_MASK; | 46 | sk->sk_shutdown = SHUTDOWN_MASK; |
45 | sk->sk_err = -err; | 47 | sk->sk_err = -err; |
@@ -52,7 +54,7 @@ static int rawsock_release(struct socket *sock) | |||
52 | { | 54 | { |
53 | struct sock *sk = sock->sk; | 55 | struct sock *sk = sock->sk; |
54 | 56 | ||
55 | nfc_dbg("sock=%p", sock); | 57 | pr_debug("sock=%p\n", sock); |
56 | 58 | ||
57 | sock_orphan(sk); | 59 | sock_orphan(sk); |
58 | sock_put(sk); | 60 | sock_put(sk); |
@@ -68,14 +70,14 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr, | |||
68 | struct nfc_dev *dev; | 70 | struct nfc_dev *dev; |
69 | int rc = 0; | 71 | int rc = 0; |
70 | 72 | ||
71 | nfc_dbg("sock=%p sk=%p flags=%d", sock, sk, flags); | 73 | pr_debug("sock=%p sk=%p flags=%d\n", sock, sk, flags); |
72 | 74 | ||
73 | if (!addr || len < sizeof(struct sockaddr_nfc) || | 75 | if (!addr || len < sizeof(struct sockaddr_nfc) || |
74 | addr->sa_family != AF_NFC) | 76 | addr->sa_family != AF_NFC) |
75 | return -EINVAL; | 77 | return -EINVAL; |
76 | 78 | ||
77 | nfc_dbg("addr dev_idx=%u target_idx=%u protocol=%u", addr->dev_idx, | 79 | pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", |
78 | addr->target_idx, addr->nfc_protocol); | 80 | addr->dev_idx, addr->target_idx, addr->nfc_protocol); |
79 | 81 | ||
80 | lock_sock(sk); | 82 | lock_sock(sk); |
81 | 83 | ||
@@ -136,7 +138,7 @@ static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb, | |||
136 | 138 | ||
137 | BUG_ON(in_irq()); | 139 | BUG_ON(in_irq()); |
138 | 140 | ||
139 | nfc_dbg("sk=%p err=%d", sk, err); | 141 | pr_debug("sk=%p err=%d\n", sk, err); |
140 | 142 | ||
141 | if (err) | 143 | if (err) |
142 | goto error; | 144 | goto error; |
@@ -172,7 +174,7 @@ static void rawsock_tx_work(struct work_struct *work) | |||
172 | struct sk_buff *skb; | 174 | struct sk_buff *skb; |
173 | int rc; | 175 | int rc; |
174 | 176 | ||
175 | nfc_dbg("sk=%p target_idx=%u", sk, target_idx); | 177 | pr_debug("sk=%p target_idx=%u\n", sk, target_idx); |
176 | 178 | ||
177 | if (sk->sk_shutdown & SEND_SHUTDOWN) { | 179 | if (sk->sk_shutdown & SEND_SHUTDOWN) { |
178 | rawsock_write_queue_purge(sk); | 180 | rawsock_write_queue_purge(sk); |
@@ -198,7 +200,7 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
198 | struct sk_buff *skb; | 200 | struct sk_buff *skb; |
199 | int rc; | 201 | int rc; |
200 | 202 | ||
201 | nfc_dbg("sock=%p sk=%p len=%zu", sock, sk, len); | 203 | pr_debug("sock=%p sk=%p len=%zu\n", sock, sk, len); |
202 | 204 | ||
203 | if (msg->msg_namelen) | 205 | if (msg->msg_namelen) |
204 | return -EOPNOTSUPP; | 206 | return -EOPNOTSUPP; |
@@ -206,13 +208,10 @@ static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
206 | if (sock->state != SS_CONNECTED) | 208 | if (sock->state != SS_CONNECTED) |
207 | return -ENOTCONN; | 209 | return -ENOTCONN; |
208 | 210 | ||
209 | 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); |
210 | msg->msg_flags & MSG_DONTWAIT, &rc); | 212 | if (skb == NULL) |
211 | if (!skb) | ||
212 | return rc; | 213 | return rc; |
213 | 214 | ||
214 | skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE); | ||
215 | |||
216 | rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); | 215 | rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); |
217 | if (rc < 0) { | 216 | if (rc < 0) { |
218 | kfree_skb(skb); | 217 | kfree_skb(skb); |
@@ -239,7 +238,7 @@ static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
239 | int copied; | 238 | int copied; |
240 | int rc; | 239 | int rc; |
241 | 240 | ||
242 | nfc_dbg("sock=%p sk=%p len=%zu flags=%d", sock, sk, len, flags); | 241 | pr_debug("sock=%p sk=%p len=%zu flags=%d\n", sock, sk, len, flags); |
243 | 242 | ||
244 | skb = skb_recv_datagram(sk, flags, noblock, &rc); | 243 | skb = skb_recv_datagram(sk, flags, noblock, &rc); |
245 | if (!skb) | 244 | if (!skb) |
@@ -283,7 +282,7 @@ static const struct proto_ops rawsock_ops = { | |||
283 | 282 | ||
284 | static void rawsock_destruct(struct sock *sk) | 283 | static void rawsock_destruct(struct sock *sk) |
285 | { | 284 | { |
286 | nfc_dbg("sk=%p", sk); | 285 | pr_debug("sk=%p\n", sk); |
287 | 286 | ||
288 | if (sk->sk_state == TCP_ESTABLISHED) { | 287 | if (sk->sk_state == TCP_ESTABLISHED) { |
289 | nfc_deactivate_target(nfc_rawsock(sk)->dev, | 288 | nfc_deactivate_target(nfc_rawsock(sk)->dev, |
@@ -294,7 +293,7 @@ static void rawsock_destruct(struct sock *sk) | |||
294 | skb_queue_purge(&sk->sk_receive_queue); | 293 | skb_queue_purge(&sk->sk_receive_queue); |
295 | 294 | ||
296 | if (!sock_flag(sk, SOCK_DEAD)) { | 295 | if (!sock_flag(sk, SOCK_DEAD)) { |
297 | nfc_err("Freeing alive NFC raw socket %p", sk); | 296 | pr_err("Freeing alive NFC raw socket %p\n", sk); |
298 | return; | 297 | return; |
299 | } | 298 | } |
300 | } | 299 | } |
@@ -304,14 +303,14 @@ static int rawsock_create(struct net *net, struct socket *sock, | |||
304 | { | 303 | { |
305 | struct sock *sk; | 304 | struct sock *sk; |
306 | 305 | ||
307 | nfc_dbg("sock=%p", sock); | 306 | pr_debug("sock=%p\n", sock); |
308 | 307 | ||
309 | if (sock->type != SOCK_SEQPACKET) | 308 | if (sock->type != SOCK_SEQPACKET) |
310 | return -ESOCKTNOSUPPORT; | 309 | return -ESOCKTNOSUPPORT; |
311 | 310 | ||
312 | sock->ops = &rawsock_ops; | 311 | sock->ops = &rawsock_ops; |
313 | 312 | ||
314 | sk = sk_alloc(net, PF_NFC, GFP_KERNEL, nfc_proto->proto); | 313 | sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto); |
315 | if (!sk) | 314 | if (!sk) |
316 | return -ENOMEM; | 315 | return -ENOMEM; |
317 | 316 | ||