summaryrefslogtreecommitdiff
path: root/net/bluetooth/eir.h
diff options
context:
space:
mode:
authorRadoslaw Biernacki <rad@semihalf.com>2022-02-01 23:10:33 +0300
committerMarcel Holtmann <marcel@holtmann.org>2022-03-04 18:10:49 +0300
commitc2b2a1a77f6b2694b7249073083ad6a0c918eef3 (patch)
treef2158c122773f40045ba07d9525aea3b81a81208 /net/bluetooth/eir.h
parentba17bb62ce415950753c19d16bb43b2bd3701158 (diff)
downloadlinux-c2b2a1a77f6b2694b7249073083ad6a0c918eef3.tar.xz
Bluetooth: Improve skb handling in mgmt_device_connected()
This patch introduce eir_skb_put_data() that can be used to simplify operations on eir in goal of eliminating the necessity of intermediary buffers. eir_skb_put_data() is in pair to what eir_append_data() does with help of eir_len, but without awkwardness when passing return value to skb_put() (as it returns updated offset not size). Signed-off-by: Radoslaw Biernacki <rad@semihalf.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'net/bluetooth/eir.h')
-rw-r--r--net/bluetooth/eir.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/bluetooth/eir.h b/net/bluetooth/eir.h
index e5876751f07e..43f1945bffc5 100644
--- a/net/bluetooth/eir.h
+++ b/net/bluetooth/eir.h
@@ -41,6 +41,21 @@ static inline u16 eir_append_le16(u8 *eir, u16 eir_len, u8 type, u16 data)
return eir_len;
}
+static inline u16 eir_skb_put_data(struct sk_buff *skb, u8 type, u8 *data, u8 data_len)
+{
+ u8 *eir;
+ u16 eir_len;
+
+ eir_len = eir_precalc_len(data_len);
+ eir = skb_put(skb, eir_len);
+ WARN_ON(sizeof(type) + data_len > U8_MAX);
+ eir[0] = sizeof(type) + data_len;
+ eir[1] = type;
+ memcpy(&eir[2], data, data_len);
+
+ return eir_len;
+}
+
static inline void *eir_get_data(u8 *eir, size_t eir_len, u8 type,
size_t *data_len)
{