diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-12-14 17:47:37 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-12-18 14:37:26 -0500 |
commit | 14c0b60829751135346d71e7d11649c4f72dc9af (patch) | |
tree | 1b1520fdb7a3175f3cba319a5678416da7a168f8 /net/bluetooth/mgmt.c | |
parent | f7c6869cebe631582fdc2ac57459ee217ce9b015 (diff) |
Bluetooth: Remove mgmt_set_service_cache
Instead of having an explicit service cache command we can make the mgmt
API simpler by implicitly enabling the cache when mgmt_read_info is
called for the first time and disabling it when mgmt_set_dev_class is
called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 56 |
1 files changed, 7 insertions, 49 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 34e48101339e..559b938f504c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -316,7 +316,10 @@ static int read_controller_info(struct sock *sk, u16 index) | |||
316 | 316 | ||
317 | hci_dev_lock(hdev); | 317 | hci_dev_lock(hdev); |
318 | 318 | ||
319 | set_bit(HCI_MGMT, &hdev->flags); | 319 | if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) { |
320 | set_bit(HCI_MGMT, &hdev->flags); | ||
321 | set_bit(HCI_SERVICE_CACHE, &hdev->flags); | ||
322 | } | ||
320 | 323 | ||
321 | memset(&rp, 0, sizeof(rp)); | 324 | memset(&rp, 0, sizeof(rp)); |
322 | 325 | ||
@@ -989,6 +992,9 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data, | |||
989 | hdev->major_class = cp->major; | 992 | hdev->major_class = cp->major; |
990 | hdev->minor_class = cp->minor; | 993 | hdev->minor_class = cp->minor; |
991 | 994 | ||
995 | if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags)) | ||
996 | update_eir(hdev); | ||
997 | |||
992 | err = update_class(hdev); | 998 | err = update_class(hdev); |
993 | 999 | ||
994 | if (err == 0) | 1000 | if (err == 0) |
@@ -1000,51 +1006,6 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data, | |||
1000 | return err; | 1006 | return err; |
1001 | } | 1007 | } |
1002 | 1008 | ||
1003 | static int set_service_cache(struct sock *sk, u16 index, unsigned char *data, | ||
1004 | u16 len) | ||
1005 | { | ||
1006 | struct hci_dev *hdev; | ||
1007 | struct mgmt_cp_set_service_cache *cp; | ||
1008 | int err; | ||
1009 | |||
1010 | cp = (void *) data; | ||
1011 | |||
1012 | if (len != sizeof(*cp)) | ||
1013 | return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, | ||
1014 | MGMT_STATUS_INVALID_PARAMS); | ||
1015 | |||
1016 | hdev = hci_dev_get(index); | ||
1017 | if (!hdev) | ||
1018 | return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, | ||
1019 | MGMT_STATUS_INVALID_PARAMS); | ||
1020 | |||
1021 | hci_dev_lock(hdev); | ||
1022 | |||
1023 | BT_DBG("hci%u enable %d", index, cp->enable); | ||
1024 | |||
1025 | if (cp->enable) { | ||
1026 | set_bit(HCI_SERVICE_CACHE, &hdev->flags); | ||
1027 | err = 0; | ||
1028 | } else { | ||
1029 | clear_bit(HCI_SERVICE_CACHE, &hdev->flags); | ||
1030 | err = update_class(hdev); | ||
1031 | if (err == 0) | ||
1032 | err = update_eir(hdev); | ||
1033 | } | ||
1034 | |||
1035 | if (err == 0) | ||
1036 | err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL, | ||
1037 | 0); | ||
1038 | else | ||
1039 | cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, -err); | ||
1040 | |||
1041 | |||
1042 | hci_dev_unlock(hdev); | ||
1043 | hci_dev_put(hdev); | ||
1044 | |||
1045 | return err; | ||
1046 | } | ||
1047 | |||
1048 | static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, | 1009 | static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, |
1049 | u16 len) | 1010 | u16 len) |
1050 | { | 1011 | { |
@@ -2170,9 +2131,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
2170 | case MGMT_OP_SET_DEV_CLASS: | 2131 | case MGMT_OP_SET_DEV_CLASS: |
2171 | err = set_dev_class(sk, index, buf + sizeof(*hdr), len); | 2132 | err = set_dev_class(sk, index, buf + sizeof(*hdr), len); |
2172 | break; | 2133 | break; |
2173 | case MGMT_OP_SET_SERVICE_CACHE: | ||
2174 | err = set_service_cache(sk, index, buf + sizeof(*hdr), len); | ||
2175 | break; | ||
2176 | case MGMT_OP_LOAD_LINK_KEYS: | 2134 | case MGMT_OP_LOAD_LINK_KEYS: |
2177 | err = load_link_keys(sk, index, buf + sizeof(*hdr), len); | 2135 | err = load_link_keys(sk, index, buf + sizeof(*hdr), len); |
2178 | break; | 2136 | break; |