Bluetooth: Simplify num_comp_pkts_evt function
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Wed, 7 Dec 2011 13:56:52 +0000 (15:56 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Sun, 18 Dec 2011 23:35:26 +0000 (21:35 -0200)
Simplify function and remove fourth level of indentation.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/hci_event.c

index 4879683..fc5338f 100644 (file)
@@ -2273,28 +2273,39 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
                count  = get_unaligned_le16(ptr++);
 
                conn = hci_conn_hash_lookup_handle(hdev, handle);
-               if (conn) {
-                       conn->sent -= count;
-
-                       if (conn->type == ACL_LINK) {
+               if (!conn)
+                       continue;
+
+               conn->sent -= count;
+
+               switch (conn->type) {
+               case ACL_LINK:
+                       hdev->acl_cnt += count;
+                       if (hdev->acl_cnt > hdev->acl_pkts)
+                               hdev->acl_cnt = hdev->acl_pkts;
+                       break;
+
+               case LE_LINK:
+                       if (hdev->le_pkts) {
+                               hdev->le_cnt += count;
+                               if (hdev->le_cnt > hdev->le_pkts)
+                                       hdev->le_cnt = hdev->le_pkts;
+                       } else {
                                hdev->acl_cnt += count;
                                if (hdev->acl_cnt > hdev->acl_pkts)
                                        hdev->acl_cnt = hdev->acl_pkts;
-                       } else if (conn->type == LE_LINK) {
-                               if (hdev->le_pkts) {
-                                       hdev->le_cnt += count;
-                                       if (hdev->le_cnt > hdev->le_pkts)
-                                               hdev->le_cnt = hdev->le_pkts;
-                               } else {
-                                       hdev->acl_cnt += count;
-                                       if (hdev->acl_cnt > hdev->acl_pkts)
-                                               hdev->acl_cnt = hdev->acl_pkts;
-                               }
-                       } else {
-                               hdev->sco_cnt += count;
-                               if (hdev->sco_cnt > hdev->sco_pkts)
-                                       hdev->sco_cnt = hdev->sco_pkts;
                        }
+                       break;
+
+               case SCO_LINK:
+                       hdev->sco_cnt += count;
+                       if (hdev->sco_cnt > hdev->sco_pkts)
+                               hdev->sco_cnt = hdev->sco_pkts;
+                       break;
+
+               default:
+                       BT_ERR("Unknown type %d conn %p", conn->type, conn);
+                       break;
                }
        }