Bluetooth: Don't send unnecessary write_le_enable command
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 27 Feb 2012 22:57:24 +0000 (00:57 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 27 Feb 2012 23:52:34 +0000 (01:52 +0200)
If the local host features indicate that LE is already in the state that
is desired there's no point in sending the HCI command to try to change
the setting.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/mgmt.c

index 27830f4016989f512278f07be069f5937a8bd8fe..c4d3bc9c86b5a12c0eceb067f8da97599eae9624 100644 (file)
@@ -1260,7 +1260,7 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len)
        struct pending_cmd *cmd;
        struct hci_dev *hdev;
        int err;
-       u8 val;
+       u8 val, enabled;
 
        BT_DBG("request for hci%u", index);
 
@@ -1280,8 +1280,9 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len)
        }
 
        val = !!cp->val;
+       enabled = !!(hdev->host_features[0] & LMP_HOST_LE);
 
-       if (!hdev_is_powered(hdev)) {
+       if (!hdev_is_powered(hdev) || val == enabled) {
                bool changed = false;
 
                if (val != test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {