Thread (19 messages) flat view 19 messages, 2 authors, 2012-02-21

Re: [PATCH 6/9] Bluetooth: mgmt: Fix New Settings event for connectable/discoverable

From: Johan Hedberg <hidden>
Date: 2012-02-21 17:46:00

Hi Marcel,

On Tue, Feb 21, 2012, Marcel Holtmann wrote:
quoted
 	if (!hdev_is_powered(hdev)) {
+		bool changed = false;
+
 		if (cp->val) {
+			if (!test_and_set_bit(HCI_DISCOVERABLE,
+							&hdev->dev_flags))
+				changed = true;
 			set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
-			set_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
-		} else
-			clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
+		} else {
+			if (test_and_clear_bit(HCI_DISCOVERABLE,
+							&hdev->dev_flags))
+				changed = true;
+		}
+
does it really need to be this complicated? If we remove the set_bit for
CONNECTABLE, then we can just send this one out. Since we know that
something changed.
Since we don't treat trying to change a setting to a value it already
has as an error it's not guaranteed that there will always be a change
in settings. Therefore, we do always need to send the cmd_complete but
not always the new_settings event. In the new set of patches I sent I've
simplified this logic a bit but the check is still there.

Johan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help