]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - net/bluetooth/hci_core.c
Bluetooth: Make LE only events conditional on supported commands
[karo-tx-linux.git] / net / bluetooth / hci_core.c
index 556c173ccbc6925b29066aec75bd803cf22d85bf..97734cab25382ec5328186ecbfa7fe529bfb2129 100644 (file)
@@ -534,13 +534,27 @@ static void hci_setup_event_mask(struct hci_request *req)
        } else {
                /* Use a different default for LE-only devices */
                memset(events, 0, sizeof(events));
-               events[0] |= 0x10; /* Disconnection Complete */
-               events[1] |= 0x08; /* Read Remote Version Information Complete */
                events[1] |= 0x20; /* Command Complete */
                events[1] |= 0x40; /* Command Status */
                events[1] |= 0x80; /* Hardware Error */
-               events[2] |= 0x04; /* Number of Completed Packets */
-               events[3] |= 0x02; /* Data Buffer Overflow */
+
+               /* If the controller supports the Disconnect command, enable
+                * the corresponding event. In addition enable packet flow
+                * control related events.
+                */
+               if (hdev->commands[0] & 0x20) {
+                       events[0] |= 0x10; /* Disconnection Complete */
+                       events[2] |= 0x04; /* Number of Completed Packets */
+                       events[3] |= 0x02; /* Data Buffer Overflow */
+               }
+
+               /* If the controller supports the Read Remote Version
+                * Information command, enable the corresponding event.
+                */
+               if (hdev->commands[2] & 0x80)
+                       events[1] |= 0x08; /* Read Remote Version Information
+                                           * Complete
+                                           */
 
                if (hdev->le_features[0] & HCI_LE_ENCRYPTION) {
                        events[0] |= 0x80; /* Encryption Change */