Bluetooth: Provide default implementation for L2CAP alloc_skb callback
Subsystems (2)
Marcel Holtmann
maintainerPATCH 1/2 Bluetooth: Provide default implementation for L2CAP alloc_skb callback
For all internal L2CAP channels, the alloc_skb callback will be exactly the same. To make it simple, provide a default implementation that all internal channel can just reference.
Signed-off-by Marcel Holtmann <[email protected]>
Tested-by Jukka Rissanen <[email protected]>
--- include/net/bluetooth/l2cap.h | 13 +++++++++++++ net/bluetooth/a2mp.c | 17 +++-------------- 2 files changed, 16 insertions(+), 14 deletions(-)
include/net/bluetooth/l2cap.h +13 -0
@@ -857,6 +857,19 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)return 0 ; } +static inline struct sk_buff *l2cap_chan_no_alloc_skb (struct l2cap_chan *chan, +unsigned long hdr_len, +unsigned long len,int nb) +{ +struct sk_buff *skb; + + skb =bt_skb_alloc (hdr_len + len,GFP_KERNEL ); +if (!skb) +return ERR_PTR (-ENOMEM ); + +return skb; +} +extern bool disable_ertm;int l2cap_init_sockets (void );
net/bluetooth/a2mp.c +3 -14
@@ -692,25 +692,14 @@ static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state, } } -static struct sk_buff *a2mp_chan_alloc_skb_cb (struct l2cap_chan *chan, -unsigned long hdr_len, -unsigned long len,int nb) -{ -struct sk_buff *skb; - - skb =bt_skb_alloc (hdr_len + len,GFP_KERNEL ); -if (!skb) -return ERR_PTR (-ENOMEM ); - -return skb; -} -static const struct l2cap_ops a2mp_chan_ops = { .name ="L2CAP A2MP channel" , .recv = a2mp_chan_recv_cb, .close = a2mp_chan_close_cb, .state_change = a2mp_chan_state_change_cb, - .alloc_skb = a2mp_chan_alloc_skb_cb, + +/* Use default kernel implementation */ + .alloc_skb = l2cap_chan_no_alloc_skb,/* Not implemented for A2MP */ .new_connection = l2cap_chan_no_new_connection,
Signature · 1 line
1.9.3