aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2011-11-01 04:58:56 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-11-07 14:24:46 -0500
commit8035ded466049ca2fe8c04564a0fa00f222abe3f (patch)
treef589157028c85ebaa17be9f329405d1ccffa6304 /net/bluetooth/hci_core.c
parent457f48507deb0e8c8dd299c7d8dce7c2c0e291e8 (diff)
Bluetooth: replace list_for_each with list_for_each_entry whenever possible
When all items in the list have the same type there is no much of a point to use list_for_each except if you want to use the list pointer itself. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 557ff90331b9..f04f2eca2028 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -319,8 +319,7 @@ static void hci_linkpol_req(struct hci_dev *hdev, unsigned long opt)
319 * Device is held on return. */ 319 * Device is held on return. */
320struct hci_dev *hci_dev_get(int index) 320struct hci_dev *hci_dev_get(int index)
321{ 321{
322 struct hci_dev *hdev = NULL; 322 struct hci_dev *hdev = NULL, *d;
323 struct list_head *p;
324 323
325 BT_DBG("%d", index); 324 BT_DBG("%d", index);
326 325
@@ -328,8 +327,7 @@ struct hci_dev *hci_dev_get(int index)
328 return NULL; 327 return NULL;
329 328
330 read_lock(&hci_dev_list_lock); 329 read_lock(&hci_dev_list_lock);
331 list_for_each(p, &hci_dev_list) { 330 list_for_each_entry(d, &hci_dev_list, list) {
332 struct hci_dev *d = list_entry(p, struct hci_dev, list);
333 if (d->id == index) { 331 if (d->id == index) {
334 hdev = hci_dev_hold(d); 332 hdev = hci_dev_hold(d);
335 break; 333 break;
@@ -794,9 +792,9 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
794 792
795int hci_get_dev_list(void __user *arg) 793int hci_get_dev_list(void __user *arg)
796{ 794{
795 struct hci_dev *hdev;
797 struct hci_dev_list_req *dl; 796 struct hci_dev_list_req *dl;
798 struct hci_dev_req *dr; 797 struct hci_dev_req *dr;
799 struct list_head *p;
800 int n = 0, size, err; 798 int n = 0, size, err;
801 __u16 dev_num; 799 __u16 dev_num;
802 800
@@ -815,11 +813,7 @@ int hci_get_dev_list(void __user *arg)
815 dr = dl->dev_req; 813 dr = dl->dev_req;
816 814
817 read_lock_bh(&hci_dev_list_lock); 815 read_lock_bh(&hci_dev_list_lock);
818 list_for_each(p, &hci_dev_list) { 816 list_for_each_entry(hdev, &hci_dev_list, list) {
819 struct hci_dev *hdev;
820
821 hdev = list_entry(p, struct hci_dev, list);
822
823 hci_del_off_timer(hdev); 817 hci_del_off_timer(hdev);
824 818
825 if (!test_bit(HCI_MGMT, &hdev->flags)) 819 if (!test_bit(HCI_MGMT, &hdev->flags))
@@ -1008,16 +1002,11 @@ int hci_link_keys_clear(struct hci_dev *hdev)
1008 1002
1009struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) 1003struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
1010{ 1004{
1011 struct list_head *p; 1005 struct link_key *k;
1012
1013 list_for_each(p, &hdev->link_keys) {
1014 struct link_key *k;
1015
1016 k = list_entry(p, struct link_key, list);
1017 1006
1007 list_for_each_entry(k, &hdev->link_keys, list)
1018 if (bacmp(bdaddr, &k->bdaddr) == 0) 1008 if (bacmp(bdaddr, &k->bdaddr) == 0)
1019 return k; 1009 return k;
1020 }
1021 1010
1022 return NULL; 1011 return NULL;
1023} 1012}
@@ -1280,16 +1269,11 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
1280struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, 1269struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
1281 bdaddr_t *bdaddr) 1270 bdaddr_t *bdaddr)
1282{ 1271{
1283 struct list_head *p; 1272 struct bdaddr_list *b;
1284
1285 list_for_each(p, &hdev->blacklist) {
1286 struct bdaddr_list *b;
1287
1288 b = list_entry(p, struct bdaddr_list, list);
1289 1273
1274 list_for_each_entry(b, &hdev->blacklist, list)
1290 if (bacmp(bdaddr, &b->bdaddr) == 0) 1275 if (bacmp(bdaddr, &b->bdaddr) == 0)
1291 return b; 1276 return b;
1292 }
1293 1277
1294 return NULL; 1278 return NULL;
1295} 1279}
@@ -2031,16 +2015,12 @@ EXPORT_SYMBOL(hci_send_sco);
2031static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote) 2015static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote)
2032{ 2016{
2033 struct hci_conn_hash *h = &hdev->conn_hash; 2017 struct hci_conn_hash *h = &hdev->conn_hash;
2034 struct hci_conn *conn = NULL; 2018 struct hci_conn *conn = NULL, *c;
2035 int num = 0, min = ~0; 2019 int num = 0, min = ~0;
2036 struct list_head *p;
2037 2020
2038 /* We don't have to lock device here. Connections are always 2021 /* We don't have to lock device here. Connections are always
2039 * added and removed with TX task disabled. */ 2022 * added and removed with TX task disabled. */
2040 list_for_each(p, &h->list) { 2023 list_for_each_entry(c, &h->list, list) {
2041 struct hci_conn *c;
2042 c = list_entry(p, struct hci_conn, list);
2043
2044 if (c->type != type || skb_queue_empty(&c->data_q)) 2024 if (c->type != type || skb_queue_empty(&c->data_q))
2045 continue; 2025 continue;
2046 2026
@@ -2089,14 +2069,12 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
2089static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type) 2069static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
2090{ 2070{
2091 struct hci_conn_hash *h = &hdev->conn_hash; 2071 struct hci_conn_hash *h = &hdev->conn_hash;
2092 struct list_head *p; 2072 struct hci_conn *c;
2093 struct hci_conn *c;
2094 2073
2095 BT_ERR("%s link tx timeout", hdev->name); 2074 BT_ERR("%s link tx timeout", hdev->name);
2096 2075
2097 /* Kill stalled connections */ 2076 /* Kill stalled connections */
2098 list_for_each(p, &h->list) { 2077 list_for_each_entry(c, &h->list, list) {
2099 c = list_entry(p, struct hci_conn, list);
2100 if (c->type == type && c->sent) { 2078 if (c->type == type && c->sent) {
2101 BT_ERR("%s killing stalled connection %s", 2079 BT_ERR("%s killing stalled connection %s",
2102 hdev->name, batostr(&c->dst)); 2080 hdev->name, batostr(&c->dst));