diff options
author | Michał Narajowski <michal.narajowski@codecoup.pl> | 2016-10-05 12:28:27 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2016-10-06 11:52:29 +0200 |
commit | 1b422066658b7cc985fa020066b72d28159d858f (patch) | |
tree | 3a09eedeb83122cfaefcaa5a17fc41d3f0205261 /net/bluetooth/hci_request.h | |
parent | Bluetooth: Add appearance to default scan rsp data (diff) | |
download | linux-1b422066658b7cc985fa020066b72d28159d858f.tar.xz linux-1b422066658b7cc985fa020066b72d28159d858f.zip |
Bluetooth: Refactor append name and appearance
Use eir_append_data to remove code duplication.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_request.h')
-rw-r--r-- | net/bluetooth/hci_request.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index ac1e11006f38..6b06629245a8 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -20,6 +20,8 @@ SOFTWARE IS DISCLAIMED. */ +#include <asm/unaligned.h> + #define hci_req_sync_lock(hdev) mutex_lock(&hdev->req_lock) #define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock) @@ -103,3 +105,24 @@ static inline void hci_update_background_scan(struct hci_dev *hdev) void hci_request_setup(struct hci_dev *hdev); void hci_request_cancel_all(struct hci_dev *hdev); + +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, + u8 *data, u8 data_len) +{ + eir[eir_len++] = sizeof(type) + data_len; + eir[eir_len++] = type; + memcpy(&eir[eir_len], data, data_len); + eir_len += data_len; + + return eir_len; +} + +static inline u16 eir_append_le16(u8 *eir, u16 eir_len, u8 type, u16 data) +{ + eir[eir_len++] = sizeof(type) + sizeof(data); + eir[eir_len++] = type; + put_unaligned_le16(data, &eir[eir_len]); + eir_len += sizeof(data); + + return eir_len; +} |