]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Bluetooth: MGMT: Use hci_dev_test_and_{set,clear}_flag
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 1 Dec 2021 19:49:49 +0000 (11:49 -0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 09:59:25 +0000 (10:59 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit 6f59f991b4e735323f099ac6490e725ae8c750a5 ]

This make use of hci_dev_test_and_{set,clear}_flag instead of doing 2
operations in a row.

Fixes: cbbdfa6f33198 ("Bluetooth: Enable controller RPA resolution using Experimental feature")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
net/bluetooth/mgmt.c

index d7306c1ffbef535fbd71bec11e56d8db8874fbfb..f09f0a78eb7bee962023668447aab6e11bde4b68 100644 (file)
@@ -3919,10 +3919,10 @@ static int set_zero_key_func(struct sock *sk, struct hci_dev *hdev,
 #endif
 
        if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) {
-               bool changed = hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
-
-               hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+               bool changed;
 
+               changed = hci_dev_test_and_clear_flag(hdev,
+                                                     HCI_ENABLE_LL_PRIVACY);
                if (changed)
                        exp_ll_privacy_feature_changed(false, hdev, sk);
        }
@@ -4017,15 +4017,15 @@ static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev,
        val = !!cp->param[0];
 
        if (val) {
-               changed = !hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
-               hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+               changed = !hci_dev_test_and_set_flag(hdev,
+                                                    HCI_ENABLE_LL_PRIVACY);
                hci_dev_clear_flag(hdev, HCI_ADVERTISING);
 
                /* Enable LL privacy + supported settings changed */
                flags = BIT(0) | BIT(1);
        } else {
-               changed = hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY);
-               hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
+               changed = hci_dev_test_and_clear_flag(hdev,
+                                                     HCI_ENABLE_LL_PRIVACY);
 
                /* Disable LL privacy + supported settings changed */
                flags = BIT(1);