Skip to content

Commit

Permalink
Bluetooth: Fix location of TX power field in LE advertising data
Browse files Browse the repository at this point in the history
The TX power field in the LE advertising data should be placed last
since it needs to be possible to enable kernel controlled TX power,
but still allow for userspace provided flags field.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
holtmann authored and Johan Hedberg committed Apr 4, 2015
1 parent fd6413d commit 38c8af6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
}
}

if (instance) {
memcpy(ptr, hdev->adv_instance.adv_data,
hdev->adv_instance.adv_data_len);

ad_len += hdev->adv_instance.adv_data_len;
ptr += hdev->adv_instance.adv_data_len;
}

/* Provide Tx Power only if we can provide a valid value for it */
if (hdev->adv_tx_power != HCI_TX_POWER_INVALID &&
(instance_flags & MGMT_ADV_FLAG_TX_POWER)) {
Expand All @@ -1054,12 +1062,6 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
ptr += 3;
}

if (instance) {
memcpy(ptr, hdev->adv_instance.adv_data,
hdev->adv_instance.adv_data_len);
ad_len += hdev->adv_instance.adv_data_len;
}

return ad_len;
}

Expand Down

0 comments on commit 38c8af6

Please sign in to comment.