diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-21 12:40:05 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-21 13:04:39 -0500 |
commit | 0224d2fafbbed4ac0cb05d08d3adab506a398451 (patch) | |
tree | 58462169f8332f6db8874e60996cfb599b5ba91b | |
parent | beadb2bddce5810dc668da156b4c2ca457940250 (diff) |
Bluetooth: mgmt: Fix New Settings event for connectable/discoverable
When powered off and doing changes to the Connectable or Discoverable
setting we should also send an appropriate New Settings event in
addition to the command response.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | net/bluetooth/mgmt.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 439ec786ff8c..08b867a4d0e6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -876,11 +876,20 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) | |||
876 | } | 876 | } |
877 | 877 | ||
878 | if (!hdev_is_powered(hdev)) { | 878 | if (!hdev_is_powered(hdev)) { |
879 | if (cp->val) | 879 | bool changed = false; |
880 | set_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 880 | |
881 | else | 881 | if (!!cp->val != test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) { |
882 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 882 | change_bit(HCI_DISCOVERABLE, &hdev->dev_flags); |
883 | changed = true; | ||
884 | } | ||
885 | |||
883 | err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); | 886 | err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); |
887 | if (err < 0) | ||
888 | goto failed; | ||
889 | |||
890 | if (changed) | ||
891 | err = new_settings(hdev, sk); | ||
892 | |||
884 | goto failed; | 893 | goto failed; |
885 | } | 894 | } |
886 | 895 | ||
@@ -938,13 +947,25 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) | |||
938 | hci_dev_lock(hdev); | 947 | hci_dev_lock(hdev); |
939 | 948 | ||
940 | if (!hdev_is_powered(hdev)) { | 949 | if (!hdev_is_powered(hdev)) { |
950 | bool changed = false; | ||
951 | |||
952 | if (!!cp->val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | ||
953 | changed = true; | ||
954 | |||
941 | if (cp->val) | 955 | if (cp->val) |
942 | set_bit(HCI_CONNECTABLE, &hdev->dev_flags); | 956 | set_bit(HCI_CONNECTABLE, &hdev->dev_flags); |
943 | else { | 957 | else { |
944 | clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); | 958 | clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); |
945 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); | 959 | clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); |
946 | } | 960 | } |
961 | |||
947 | err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); | 962 | err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); |
963 | if (err < 0) | ||
964 | goto failed; | ||
965 | |||
966 | if (changed) | ||
967 | err = new_settings(hdev, sk); | ||
968 | |||
948 | goto failed; | 969 | goto failed; |
949 | } | 970 | } |
950 | 971 | ||