Skip to contentSkip to conversation

Bluetooth: Provide default implementation for L2CAP alloc_skb callback

PATCH New Marcel Holtmann 1 participant 1 message Jun 16, 2014

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 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.

---
 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
index 92511034d1d4..525c75abe1d4 100644
@@ -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
index 0fd8d1dda709..4e03a77b5a80 100644
@@ -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