Bluetooth: Simplify read_adv_features code
The code in the Read Advertising Features mgmt command handler is unnecessarily complicated. Clean it up and remove unnecessary variables & branches. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
2ff13894cf
commit
02c04afea9
@ -5788,10 +5788,10 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
|
|||||||
{
|
{
|
||||||
struct mgmt_rp_read_adv_features *rp;
|
struct mgmt_rp_read_adv_features *rp;
|
||||||
size_t rp_len;
|
size_t rp_len;
|
||||||
int err, i;
|
int err;
|
||||||
bool instance;
|
|
||||||
struct adv_info *adv_instance;
|
struct adv_info *adv_instance;
|
||||||
u32 supported_flags;
|
u32 supported_flags;
|
||||||
|
u8 *instance;
|
||||||
|
|
||||||
BT_DBG("%s", hdev->name);
|
BT_DBG("%s", hdev->name);
|
||||||
|
|
||||||
@ -5801,12 +5801,7 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
|
|||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
rp_len = sizeof(*rp);
|
rp_len = sizeof(*rp) + hdev->adv_instance_cnt;
|
||||||
|
|
||||||
instance = hci_dev_test_flag(hdev, HCI_ADVERTISING_INSTANCE);
|
|
||||||
if (instance)
|
|
||||||
rp_len += hdev->adv_instance_cnt;
|
|
||||||
|
|
||||||
rp = kmalloc(rp_len, GFP_ATOMIC);
|
rp = kmalloc(rp_len, GFP_ATOMIC);
|
||||||
if (!rp) {
|
if (!rp) {
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
@ -5819,19 +5814,12 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
|
|||||||
rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
|
rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
|
||||||
rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
|
rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
|
||||||
rp->max_instances = HCI_MAX_ADV_INSTANCES;
|
rp->max_instances = HCI_MAX_ADV_INSTANCES;
|
||||||
|
rp->num_instances = hdev->adv_instance_cnt;
|
||||||
|
|
||||||
if (instance) {
|
instance = rp->instance;
|
||||||
i = 0;
|
list_for_each_entry(adv_instance, &hdev->adv_instances, list) {
|
||||||
list_for_each_entry(adv_instance, &hdev->adv_instances, list) {
|
*instance = adv_instance->instance;
|
||||||
if (i >= hdev->adv_instance_cnt)
|
instance++;
|
||||||
break;
|
|
||||||
|
|
||||||
rp->instance[i] = adv_instance->instance;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
rp->num_instances = hdev->adv_instance_cnt;
|
|
||||||
} else {
|
|
||||||
rp->num_instances = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
Loading…
Reference in New Issue
Block a user