summaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-01-15 21:01:23 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 17:01:28 +0200
commit1dc06093a9f353ef19b7b5180602884d0ce065c5 (patch)
treeea919a19d06f60f0843ada9d198a4870e58037f1 /net/bluetooth
parent6759a67579a927f2a92f398cf67555e6cc92d0ff (diff)
downloadop-kernel-dev-1dc06093a9f353ef19b7b5180602884d0ce065c5.zip
op-kernel-dev-1dc06093a9f353ef19b7b5180602884d0ce065c5.tar.gz
Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
There's no need to have a separate device class field since the same information can be encoded into the EIR data. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/mgmt.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b7e7fdf..bec64c9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2786,23 +2786,29 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
{
char buf[512];
struct mgmt_ev_device_found *ev = (void *) buf;
- size_t ev_size = sizeof(*ev) + eir_len;
+ size_t ev_size;
- if (ev_size > sizeof(buf))
+ /* Leave 5 bytes for a potential CoD field */
+ if (sizeof(*ev) + eir_len + 5 > sizeof(buf))
return -EINVAL;
+ memset(buf, 0, sizeof(buf));
+
bacpy(&ev->addr.bdaddr, bdaddr);
ev->addr.type = link_to_mgmt(link_type, addr_type);
ev->rssi = rssi;
ev->confirm_name = cfm_name;
- if (eir_len > 0) {
- put_unaligned_le16(eir_len, &ev->eir_len);
+ if (eir_len > 0)
memcpy(ev->eir, eir, eir_len);
- }
- if (dev_class)
- memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class));
+ if (dev_class && !eir_has_data_type(ev->eir, eir_len, EIR_CLASS_OF_DEV))
+ eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
+ dev_class, 3);
+
+ put_unaligned_le16(eir_len, &ev->eir_len);
+
+ ev_size = sizeof(*ev) + eir_len;
return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
}
OpenPOWER on IntegriCloud