return false;
 }
 
+static void set_random_addr(struct hci_request *req, bdaddr_t *rpa);
+static int hci_update_random_address(struct hci_request *req,
+                                    bool require_privacy, bool use_rpa,
+                                    u8 *own_addr_type)
+{
+       struct hci_dev *hdev = req->hdev;
+       int err;
+
+       /* If privacy is enabled use a resolvable private address. If
+        * current RPA has expired or there is something else than
+        * the current RPA in use, then generate a new one.
+        */
+       if (use_rpa) {
+               /* If Controller supports LL Privacy use own address type is
+                * 0x03
+                */
+               if (use_ll_privacy(hdev))
+                       *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
+               else
+                       *own_addr_type = ADDR_LE_DEV_RANDOM;
+
+               if (rpa_valid(hdev))
+                       return 0;
+
+               err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
+               if (err < 0) {
+                       bt_dev_err(hdev, "failed to generate new RPA");
+                       return err;
+               }
+
+               set_random_addr(req, &hdev->rpa);
+
+               return 0;
+       }
+
+       /* In case of required privacy without resolvable private address,
+        * use an non-resolvable private address. This is useful for active
+        * scanning and non-connectable advertising.
+        */
+       if (require_privacy) {
+               bdaddr_t nrpa;
+
+               while (true) {
+                       /* The non-resolvable private address is generated
+                        * from random six bytes with the two most significant
+                        * bits cleared.
+                        */
+                       get_random_bytes(&nrpa, 6);
+                       nrpa.b[5] &= 0x3f;
+
+                       /* The non-resolvable private address shall not be
+                        * equal to the public address.
+                        */
+                       if (bacmp(&hdev->bdaddr, &nrpa))
+                               break;
+               }
+
+               *own_addr_type = ADDR_LE_DEV_RANDOM;
+               set_random_addr(req, &nrpa);
+               return 0;
+       }
+
+       /* If forcing static address is in use or there is no public
+        * address use the static address as random address (but skip
+        * the HCI command if the current random address is already the
+        * static one.
+        *
+        * In case BR/EDR has been disabled on a dual-mode controller
+        * and a static address has been configured, then use that
+        * address instead of the public BR/EDR address.
+        */
+       if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ||
+           !bacmp(&hdev->bdaddr, BDADDR_ANY) ||
+           (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) &&
+            bacmp(&hdev->static_addr, BDADDR_ANY))) {
+               *own_addr_type = ADDR_LE_DEV_RANDOM;
+               if (bacmp(&hdev->static_addr, &hdev->random_addr))
+                       hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
+                                   &hdev->static_addr);
+               return 0;
+       }
+
+       /* Neither privacy nor static address is being used so use a
+        * public address.
+        */
+       *own_addr_type = ADDR_LE_DEV_PUBLIC;
+
+       return 0;
+}
+
 /* Ensure to call hci_req_add_le_scan_disable() first to disable the
  * controller based address resolution to be able to reconfigure
  * resolving list.
                                   &hdev->interleave_scan, timeout);
 }
 
-int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
-                          bool use_rpa, struct adv_info *adv_instance,
-                          u8 *own_addr_type, bdaddr_t *rand_addr)
-{
-       int err;
-
-       bacpy(rand_addr, BDADDR_ANY);
-
-       /* If privacy is enabled use a resolvable private address. If
-        * current RPA has expired then generate a new one.
-        */
-       if (use_rpa) {
-               /* If Controller supports LL Privacy use own address type is
-                * 0x03
-                */
-               if (use_ll_privacy(hdev))
-                       *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
-               else
-                       *own_addr_type = ADDR_LE_DEV_RANDOM;
-
-               if (adv_instance) {
-                       if (adv_rpa_valid(adv_instance))
-                               return 0;
-               } else {
-                       if (rpa_valid(hdev))
-                               return 0;
-               }
-
-               err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
-               if (err < 0) {
-                       bt_dev_err(hdev, "failed to generate new RPA");
-                       return err;
-               }
-
-               bacpy(rand_addr, &hdev->rpa);
-
-               return 0;
-       }
-
-       /* In case of required privacy without resolvable private address,
-        * use an non-resolvable private address. This is useful for
-        * non-connectable advertising.
-        */
-       if (require_privacy) {
-               bdaddr_t nrpa;
-
-               while (true) {
-                       /* The non-resolvable private address is generated
-                        * from random six bytes with the two most significant
-                        * bits cleared.
-                        */
-                       get_random_bytes(&nrpa, 6);
-                       nrpa.b[5] &= 0x3f;
-
-                       /* The non-resolvable private address shall not be
-                        * equal to the public address.
-                        */
-                       if (bacmp(&hdev->bdaddr, &nrpa))
-                               break;
-               }
-
-               *own_addr_type = ADDR_LE_DEV_RANDOM;
-               bacpy(rand_addr, &nrpa);
-
-               return 0;
-       }
-
-       /* No privacy so use a public address. */
-       *own_addr_type = ADDR_LE_DEV_PUBLIC;
-
-       return 0;
-}
-
 static void set_random_addr(struct hci_request *req, bdaddr_t *rpa)
 {
        struct hci_dev *hdev = req->hdev;
        hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6, rpa);
 }
 
-int hci_update_random_address(struct hci_request *req, bool require_privacy,
-                             bool use_rpa, u8 *own_addr_type)
-{
-       struct hci_dev *hdev = req->hdev;
-       int err;
-
-       /* If privacy is enabled use a resolvable private address. If
-        * current RPA has expired or there is something else than
-        * the current RPA in use, then generate a new one.
-        */
-       if (use_rpa) {
-               /* If Controller supports LL Privacy use own address type is
-                * 0x03
-                */
-               if (use_ll_privacy(hdev))
-                       *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
-               else
-                       *own_addr_type = ADDR_LE_DEV_RANDOM;
-
-               if (rpa_valid(hdev))
-                       return 0;
-
-               err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
-               if (err < 0) {
-                       bt_dev_err(hdev, "failed to generate new RPA");
-                       return err;
-               }
-
-               set_random_addr(req, &hdev->rpa);
-
-               return 0;
-       }
-
-       /* In case of required privacy without resolvable private address,
-        * use an non-resolvable private address. This is useful for active
-        * scanning and non-connectable advertising.
-        */
-       if (require_privacy) {
-               bdaddr_t nrpa;
-
-               while (true) {
-                       /* The non-resolvable private address is generated
-                        * from random six bytes with the two most significant
-                        * bits cleared.
-                        */
-                       get_random_bytes(&nrpa, 6);
-                       nrpa.b[5] &= 0x3f;
-
-                       /* The non-resolvable private address shall not be
-                        * equal to the public address.
-                        */
-                       if (bacmp(&hdev->bdaddr, &nrpa))
-                               break;
-               }
-
-               *own_addr_type = ADDR_LE_DEV_RANDOM;
-               set_random_addr(req, &nrpa);
-               return 0;
-       }
-
-       /* If forcing static address is in use or there is no public
-        * address use the static address as random address (but skip
-        * the HCI command if the current random address is already the
-        * static one.
-        *
-        * In case BR/EDR has been disabled on a dual-mode controller
-        * and a static address has been configured, then use that
-        * address instead of the public BR/EDR address.
-        */
-       if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ||
-           !bacmp(&hdev->bdaddr, BDADDR_ANY) ||
-           (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) &&
-            bacmp(&hdev->static_addr, BDADDR_ANY))) {
-               *own_addr_type = ADDR_LE_DEV_RANDOM;
-               if (bacmp(&hdev->static_addr, &hdev->random_addr))
-                       hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
-                                   &hdev->static_addr);
-               return 0;
-       }
-
-       /* Neither privacy nor static address is being used so use a
-        * public address.
-        */
-       *own_addr_type = ADDR_LE_DEV_PUBLIC;
-
-       return 0;
-}
-
-void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn,
-                     u8 reason)
+static void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn,
+                            u8 reason)
 {
        switch (conn->state) {
        case BT_CONNECTED:
 
        return __hci_cmd_sync_status(hdev, HCI_OP_LE_PA_TERM_SYNC,
                                     sizeof(cp), &cp, HCI_CMD_TIMEOUT);
 }
+
+int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
+                          bool use_rpa, struct adv_info *adv_instance,
+                          u8 *own_addr_type, bdaddr_t *rand_addr)
+{
+       int err;
+
+       bacpy(rand_addr, BDADDR_ANY);
+
+       /* If privacy is enabled use a resolvable private address. If
+        * current RPA has expired then generate a new one.
+        */
+       if (use_rpa) {
+               /* If Controller supports LL Privacy use own address type is
+                * 0x03
+                */
+               if (use_ll_privacy(hdev))
+                       *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
+               else
+                       *own_addr_type = ADDR_LE_DEV_RANDOM;
+
+               if (adv_instance) {
+                       if (adv_rpa_valid(adv_instance))
+                               return 0;
+               } else {
+                       if (rpa_valid(hdev))
+                               return 0;
+               }
+
+               err = smp_generate_rpa(hdev, hdev->irk, &hdev->rpa);
+               if (err < 0) {
+                       bt_dev_err(hdev, "failed to generate new RPA");
+                       return err;
+               }
+
+               bacpy(rand_addr, &hdev->rpa);
+
+               return 0;
+       }
+
+       /* In case of required privacy without resolvable private address,
+        * use an non-resolvable private address. This is useful for
+        * non-connectable advertising.
+        */
+       if (require_privacy) {
+               bdaddr_t nrpa;
+
+               while (true) {
+                       /* The non-resolvable private address is generated
+                        * from random six bytes with the two most significant
+                        * bits cleared.
+                        */
+                       get_random_bytes(&nrpa, 6);
+                       nrpa.b[5] &= 0x3f;
+
+                       /* The non-resolvable private address shall not be
+                        * equal to the public address.
+                        */
+                       if (bacmp(&hdev->bdaddr, &nrpa))
+                               break;
+               }
+
+               *own_addr_type = ADDR_LE_DEV_RANDOM;
+               bacpy(rand_addr, &nrpa);
+
+               return 0;
+       }
+
+       /* No privacy so use a public address. */
+       *own_addr_type = ADDR_LE_DEV_PUBLIC;
+
+       return 0;
+}