diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-05-16 16:57:22 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-13 13:55:33 -0400 |
commit | 230704942283cb3990584ddd6955ac8decfa6a2c (patch) | |
tree | 2834efce3cf32e1f6de9cedb7ee510e70eb662da | |
parent | 80808e431e1ef25856457de82ce141bed6a6313a (diff) |
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>
-rw-r--r-- | include/net/bluetooth/l2cap.h | 1 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 16 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 8 |
3 files changed, 17 insertions, 8 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index d3a150955c44..05bb254c9ebd 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -363,6 +363,7 @@ struct l2cap_ops { | |||
363 | char *name; | 363 | char *name; |
364 | 364 | ||
365 | struct l2cap_chan *(*new_connection) (void *data); | 365 | struct l2cap_chan *(*new_connection) (void *data); |
366 | int (*recv) (void *data, struct sk_buff *skb); | ||
366 | }; | 367 | }; |
367 | 368 | ||
368 | struct l2cap_conn { | 369 | struct l2cap_conn { |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8369f5680391..4cbb48d523e4 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -1698,7 +1698,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1698 | if (!nskb) | 1698 | if (!nskb) |
1699 | continue; | 1699 | continue; |
1700 | 1700 | ||
1701 | if (sock_queue_rcv_skb(sk, nskb)) | 1701 | if (chan->ops->recv(chan->data, nskb)) |
1702 | kfree_skb(nskb); | 1702 | kfree_skb(nskb); |
1703 | } | 1703 | } |
1704 | read_unlock(&conn->chan_lock); | 1704 | read_unlock(&conn->chan_lock); |
@@ -3124,7 +3124,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
3124 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) | 3124 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) |
3125 | goto drop; | 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 | case L2CAP_SDU_START: | 3129 | case L2CAP_SDU_START: |
3130 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) | 3130 | if (chan->conn_state & L2CAP_CONN_SAR_SDU) |
@@ -3190,7 +3190,7 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk | |||
3190 | return -ENOMEM; | 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 | if (err < 0) { | 3194 | if (err < 0) { |
3195 | kfree_skb(_skb); | 3195 | kfree_skb(_skb); |
3196 | chan->conn_state |= L2CAP_CONN_SAR_RETRY; | 3196 | chan->conn_state |= L2CAP_CONN_SAR_RETRY; |
@@ -3358,7 +3358,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3358 | break; | 3358 | break; |
3359 | } | 3359 | } |
3360 | 3360 | ||
3361 | err = sock_queue_rcv_skb(chan->sk, skb); | 3361 | err = chan->ops->recv(chan->data, skb); |
3362 | if (!err) | 3362 | if (!err) |
3363 | return 0; | 3363 | return 0; |
3364 | 3364 | ||
@@ -3419,7 +3419,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf | |||
3419 | 3419 | ||
3420 | if (chan->partial_sdu_len == chan->sdu_len) { | 3420 | if (chan->partial_sdu_len == chan->sdu_len) { |
3421 | _skb = skb_clone(chan->sdu, GFP_ATOMIC); | 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 | if (err < 0) | 3423 | if (err < 0) |
3424 | kfree_skb(_skb); | 3424 | kfree_skb(_skb); |
3425 | } | 3425 | } |
@@ -3886,7 +3886,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
3886 | if (chan->imtu < skb->len) | 3886 | if (chan->imtu < skb->len) |
3887 | goto drop; | 3887 | goto drop; |
3888 | 3888 | ||
3889 | if (!sock_queue_rcv_skb(sk, skb)) | 3889 | if (!chan->ops->recv(chan->data, skb)) |
3890 | goto done; | 3890 | goto done; |
3891 | break; | 3891 | break; |
3892 | 3892 | ||
@@ -3964,7 +3964,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str | |||
3964 | if (l2cap_pi(sk)->chan->imtu < skb->len) | 3964 | if (l2cap_pi(sk)->chan->imtu < skb->len) |
3965 | goto drop; | 3965 | goto drop; |
3966 | 3966 | ||
3967 | if (!sock_queue_rcv_skb(sk, skb)) | 3967 | if (!chan->ops->recv(chan->data, skb)) |
3968 | goto done; | 3968 | goto done; |
3969 | 3969 | ||
3970 | drop: | 3970 | drop: |
@@ -3997,7 +3997,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct | |||
3997 | if (l2cap_pi(sk)->chan->imtu < skb->len) | 3997 | if (l2cap_pi(sk)->chan->imtu < skb->len) |
3998 | goto drop; | 3998 | goto drop; |
3999 | 3999 | ||
4000 | if (!sock_queue_rcv_skb(sk, skb)) | 4000 | if (!chan->ops->recv(chan->data, skb)) |
4001 | goto done; | 4001 | goto done; |
4002 | 4002 | ||
4003 | drop: | 4003 | drop: |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 4050edeaf78b..28cdc7e6df54 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -789,9 +789,17 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) | |||
789 | return l2cap_pi(sk)->chan; | 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 | static struct l2cap_ops l2cap_chan_ops = { | 799 | static struct l2cap_ops l2cap_chan_ops = { |
793 | .name = "L2CAP Socket Interface", | 800 | .name = "L2CAP Socket Interface", |
794 | .new_connection = l2cap_sock_new_connection_cb, | 801 | .new_connection = l2cap_sock_new_connection_cb, |
802 | .recv = l2cap_sock_recv_cb, | ||
795 | }; | 803 | }; |
796 | 804 | ||
797 | static void l2cap_sock_destruct(struct sock *sk) | 805 | static void l2cap_sock_destruct(struct sock *sk) |