Bluetooth: Refactor advertising report processing into its own function
As preparation for merging ADV_IND/ADV_SCAN_IND and SCAN_RSP together into a single mgmt Device Found event refactor individual advertising report handling into a separate function. This will help keep the code more readable as more logic gets added. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
e8b1ab9e6d
commit
4af605d8c4
|
@ -3975,25 +3975,30 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
|
||||||
|
u8 bdaddr_type, s8 rssi, u8 *data, u8 len)
|
||||||
|
{
|
||||||
|
if (type == LE_ADV_IND || type == LE_ADV_DIRECT_IND)
|
||||||
|
check_pending_le_conn(hdev, bdaddr, bdaddr_type);
|
||||||
|
|
||||||
|
mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, rssi, 0, 1,
|
||||||
|
data, len);
|
||||||
|
}
|
||||||
|
|
||||||
static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_le_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
u8 num_reports = skb->data[0];
|
u8 num_reports = skb->data[0];
|
||||||
void *ptr = &skb->data[1];
|
void *ptr = &skb->data[1];
|
||||||
s8 rssi;
|
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
while (num_reports--) {
|
while (num_reports--) {
|
||||||
struct hci_ev_le_advertising_info *ev = ptr;
|
struct hci_ev_le_advertising_info *ev = ptr;
|
||||||
|
s8 rssi;
|
||||||
if (ev->evt_type == LE_ADV_IND ||
|
|
||||||
ev->evt_type == LE_ADV_DIRECT_IND)
|
|
||||||
check_pending_le_conn(hdev, &ev->bdaddr,
|
|
||||||
ev->bdaddr_type);
|
|
||||||
|
|
||||||
rssi = ev->data[ev->length];
|
rssi = ev->data[ev->length];
|
||||||
mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type,
|
process_adv_report(hdev, ev->evt_type, &ev->bdaddr,
|
||||||
NULL, rssi, 0, 1, ev->data, ev->length);
|
ev->bdaddr_type, rssi, ev->data, ev->length);
|
||||||
|
|
||||||
ptr += sizeof(*ev) + ev->length + 1;
|
ptr += sizeof(*ev) + ev->length + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue