Commit 230704942283cb3990584ddd6955ac8decfa6a2c

Authored by Gustavo F. Padovan
1 parent 80808e431e

Bluetooth: add recv() callback to l2cap_chan_ops

This abstracts the call to sock_queue_recv_skb() into
l2cap_chan_ops->recv().

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>

Showing 3 changed files with 17 additions and 8 deletions Side-by-side Diff

include/net/bluetooth/l2cap.h
... ... @@ -363,6 +363,7 @@
363 363 char *name;
364 364  
365 365 struct l2cap_chan *(*new_connection) (void *data);
  366 + int (*recv) (void *data, struct sk_buff *skb);
366 367 };
367 368  
368 369 struct l2cap_conn {
net/bluetooth/l2cap_core.c
... ... @@ -1698,7 +1698,7 @@
1698 1698 if (!nskb)
1699 1699 continue;
1700 1700  
1701   - if (sock_queue_rcv_skb(sk, nskb))
  1701 + if (chan->ops->recv(chan->data, nskb))
1702 1702 kfree_skb(nskb);
1703 1703 }
1704 1704 read_unlock(&conn->chan_lock);
... ... @@ -3124,7 +3124,7 @@
3124 3124 if (chan->conn_state & L2CAP_CONN_SAR_SDU)
3125 3125 goto drop;
3126 3126  
3127   - return sock_queue_rcv_skb(chan->sk, skb);
  3127 + return chan->ops->recv(chan->data, skb);
3128 3128  
3129 3129 case L2CAP_SDU_START:
3130 3130 if (chan->conn_state & L2CAP_CONN_SAR_SDU)
... ... @@ -3190,7 +3190,7 @@
3190 3190 return -ENOMEM;
3191 3191 }
3192 3192  
3193   - err = sock_queue_rcv_skb(chan->sk, _skb);
  3193 + err = chan->ops->recv(chan->data, _skb);
3194 3194 if (err < 0) {
3195 3195 kfree_skb(_skb);
3196 3196 chan->conn_state |= L2CAP_CONN_SAR_RETRY;
... ... @@ -3358,7 +3358,7 @@
3358 3358 break;
3359 3359 }
3360 3360  
3361   - err = sock_queue_rcv_skb(chan->sk, skb);
  3361 + err = chan->ops->recv(chan->data, skb);
3362 3362 if (!err)
3363 3363 return 0;
3364 3364  
... ... @@ -3419,7 +3419,7 @@
3419 3419  
3420 3420 if (chan->partial_sdu_len == chan->sdu_len) {
3421 3421 _skb = skb_clone(chan->sdu, GFP_ATOMIC);
3422   - err = sock_queue_rcv_skb(chan->sk, _skb);
  3422 + err = chan->ops->recv(chan->data, _skb);
3423 3423 if (err < 0)
3424 3424 kfree_skb(_skb);
3425 3425 }
... ... @@ -3886,7 +3886,7 @@
3886 3886 if (chan->imtu < skb->len)
3887 3887 goto drop;
3888 3888  
3889   - if (!sock_queue_rcv_skb(sk, skb))
  3889 + if (!chan->ops->recv(chan->data, skb))
3890 3890 goto done;
3891 3891 break;
3892 3892  
... ... @@ -3964,7 +3964,7 @@
3964 3964 if (l2cap_pi(sk)->chan->imtu < skb->len)
3965 3965 goto drop;
3966 3966  
3967   - if (!sock_queue_rcv_skb(sk, skb))
  3967 + if (!chan->ops->recv(chan->data, skb))
3968 3968 goto done;
3969 3969  
3970 3970 drop:
... ... @@ -3997,7 +3997,7 @@
3997 3997 if (l2cap_pi(sk)->chan->imtu < skb->len)
3998 3998 goto drop;
3999 3999  
4000   - if (!sock_queue_rcv_skb(sk, skb))
  4000 + if (!chan->ops->recv(chan->data, skb))
4001 4001 goto done;
4002 4002  
4003 4003 drop:
net/bluetooth/l2cap_sock.c
... ... @@ -789,9 +789,17 @@
789 789 return l2cap_pi(sk)->chan;
790 790 }
791 791  
  792 +static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb)
  793 +{
  794 + struct sock *sk = data;
  795 +
  796 + return sock_queue_rcv_skb(sk, skb);
  797 +}
  798 +
792 799 static struct l2cap_ops l2cap_chan_ops = {
793 800 .name = "L2CAP Socket Interface",
794 801 .new_connection = l2cap_sock_new_connection_cb,
  802 + .recv = l2cap_sock_recv_cb,
795 803 };
796 804  
797 805 static void l2cap_sock_destruct(struct sock *sk)