Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next
[sfrench/cifs-2.6.git] / net / bluetooth / hci_request.c
index 7f6a581b5b7e14fa7b72db8449afc85a8d9327e2..2a1b64dbf76e446aa76a40a2b8da3adb75b9f954 100644 (file)
@@ -904,9 +904,9 @@ static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance)
 {
        struct adv_info *adv_instance;
 
-       /* Ignore instance 0 */
+       /* Instance 0x00 always set local name */
        if (instance == 0x00)
-               return 0;
+               return 1;
 
        adv_instance = hci_find_adv_instance(hdev, instance);
        if (!adv_instance)
@@ -923,9 +923,9 @@ static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev)
        u8 instance = hdev->cur_adv_instance;
        struct adv_info *adv_instance;
 
-       /* Ignore instance 0 */
+       /* Instance 0x00 always set local name */
        if (instance == 0x00)
-               return 0;
+               return 1;
 
        adv_instance = hci_find_adv_instance(hdev, instance);
        if (!adv_instance)
@@ -1273,6 +1273,14 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
 
        instance_flags = get_adv_instance_flags(hdev, instance);
 
+       /* If instance already has the flags set skip adding it once
+        * again.
+        */
+       if (adv_instance && eir_get_data(adv_instance->adv_data,
+                                        adv_instance->adv_data_len, EIR_FLAGS,
+                                        NULL))
+               goto skip_flags;
+
        /* The Add Advertising command allows userspace to set both the general
         * and limited discoverable flags.
         */
@@ -1305,6 +1313,7 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr)
                }
        }
 
+skip_flags:
        if (adv_instance) {
                memcpy(ptr, adv_instance->adv_data,
                       adv_instance->adv_data_len);
@@ -1690,7 +1699,7 @@ int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance)
         * scheduling it.
         */
        if (adv_instance && adv_instance->duration) {
-               u16 duration = adv_instance->duration * MSEC_PER_SEC;
+               u16 duration = adv_instance->timeout * MSEC_PER_SEC;
 
                /* Time = N * 10 ms */
                adv_set->duration = cpu_to_le16(duration / 10);