From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This adds bt_skb_pull which will be used to parse events, it checks the skb contains the given length and then use skb_pull to advance in data which avoid having to rely on another variable to track the position in the buffer. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> --- include/net/bluetooth/bluetooth.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 9125effbf448..449bc8e112f9 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -420,6 +420,18 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, return NULL; } +static inline void *bt_skb_pull(struct sk_buff *skb, size_t len) +{ + void *data = skb->data; + + if (skb->len < len) + return NULL; + + skb_pull(skb, len); + + return data; +} + int bt_to_errno(u16 code); void hci_sock_set_flag(struct sock *sk, int nr); -- 2.30.2