]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Bluetooth: Remove mgmt_set_service_cache
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 14 Dec 2011 22:47:37 +0000 (00:47 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Sun, 18 Dec 2011 19:37:26 +0000 (17:37 -0200)
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>
include/net/bluetooth/hci_core.h
include/net/bluetooth/mgmt.h
net/bluetooth/hci_sock.c
net/bluetooth/mgmt.c

index 72f84d6d4d3afecc716b5c5652c4b4d33e1e7ded..cc17f739dfffaca5a24f2820cac6f6ab7ad7a77d 100644 (file)
@@ -943,12 +943,16 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr);
 /* HCI info for socket */
 #define hci_pi(sk) ((struct hci_pinfo *) sk)
 
+/* HCI socket flags */
+#define HCI_PI_MGMT_INIT       0
+
 struct hci_pinfo {
        struct bt_sock    bt;
        struct hci_dev    *hdev;
        struct hci_filter filter;
        __u32             cmsg_mask;
        unsigned short   channel;
+       unsigned long     flags;
 };
 
 /* HCI security filter */
index bf217ccb86bf7291b6a82e0bf04cd5088510835e..bdb0a581149ccf795a560c5aaece07e5696931f5 100644 (file)
@@ -121,11 +121,6 @@ struct mgmt_cp_set_dev_class {
        __u8 minor;
 } __packed;
 
-#define MGMT_OP_SET_SERVICE_CACHE      0x000C
-struct mgmt_cp_set_service_cache {
-       __u8 enable;
-} __packed;
-
 struct mgmt_link_key_info {
        bdaddr_t bdaddr;
        u8 type;
index cd064068d94acdd63b0bd3837af207d269f73eb7..189a667c293bb3d4f53ec2d33e8dd94432201cce 100644 (file)
@@ -343,8 +343,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
        if (haddr.hci_channel > HCI_CHANNEL_CONTROL)
                return -EINVAL;
 
-       if (haddr.hci_channel == HCI_CHANNEL_CONTROL && !enable_mgmt)
-               return -EINVAL;
+       if (haddr.hci_channel == HCI_CHANNEL_CONTROL) {
+               if (!enable_mgmt)
+                       return -EINVAL;
+               set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags);
+       }
 
        lock_sock(sk);
 
index 34e48101339e409100ed19451ab9d097cb59190b..559b938f504c73cc37e4ff6a4d94418e0673fbd9 100644 (file)
@@ -316,7 +316,10 @@ static int read_controller_info(struct sock *sk, u16 index)
 
        hci_dev_lock(hdev);
 
-       set_bit(HCI_MGMT, &hdev->flags);
+       if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) {
+               set_bit(HCI_MGMT, &hdev->flags);
+               set_bit(HCI_SERVICE_CACHE, &hdev->flags);
+       }
 
        memset(&rp, 0, sizeof(rp));
 
@@ -989,6 +992,9 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
        hdev->major_class = cp->major;
        hdev->minor_class = cp->minor;
 
+       if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags))
+               update_eir(hdev);
+
        err = update_class(hdev);
 
        if (err == 0)
@@ -1000,51 +1006,6 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
        return err;
 }
 
-static int set_service_cache(struct sock *sk, u16 index,  unsigned char *data,
-                                                                       u16 len)
-{
-       struct hci_dev *hdev;
-       struct mgmt_cp_set_service_cache *cp;
-       int err;
-
-       cp = (void *) data;
-
-       if (len != sizeof(*cp))
-               return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE,
-                                               MGMT_STATUS_INVALID_PARAMS);
-
-       hdev = hci_dev_get(index);
-       if (!hdev)
-               return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE,
-                                               MGMT_STATUS_INVALID_PARAMS);
-
-       hci_dev_lock(hdev);
-
-       BT_DBG("hci%u enable %d", index, cp->enable);
-
-       if (cp->enable) {
-               set_bit(HCI_SERVICE_CACHE, &hdev->flags);
-               err = 0;
-       } else {
-               clear_bit(HCI_SERVICE_CACHE, &hdev->flags);
-               err = update_class(hdev);
-               if (err == 0)
-                       err = update_eir(hdev);
-       }
-
-       if (err == 0)
-               err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL,
-                                                                       0);
-       else
-               cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, -err);
-
-
-       hci_dev_unlock(hdev);
-       hci_dev_put(hdev);
-
-       return err;
-}
-
 static int load_link_keys(struct sock *sk, u16 index, unsigned char *data,
                                                                u16 len)
 {
@@ -2170,9 +2131,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
        case MGMT_OP_SET_DEV_CLASS:
                err = set_dev_class(sk, index, buf + sizeof(*hdr), len);
                break;
-       case MGMT_OP_SET_SERVICE_CACHE:
-               err = set_service_cache(sk, index, buf + sizeof(*hdr), len);
-               break;
        case MGMT_OP_LOAD_LINK_KEYS:
                err = load_link_keys(sk, index, buf + sizeof(*hdr), len);
                break;