diff options
| author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2011-11-01 04:58:56 -0400 |
|---|---|---|
| committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-07 14:24:46 -0500 |
| commit | 8035ded466049ca2fe8c04564a0fa00f222abe3f (patch) | |
| tree | f589157028c85ebaa17be9f329405d1ccffa6304 /net/bluetooth | |
| parent | 457f48507deb0e8c8dd299c7d8dce7c2c0e291e8 (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')
| -rw-r--r-- | net/bluetooth/bnep/core.c | 13 | ||||
| -rw-r--r-- | net/bluetooth/cmtp/core.c | 13 | ||||
| -rw-r--r-- | net/bluetooth/hci_conn.c | 14 | ||||
| -rw-r--r-- | net/bluetooth/hci_core.c | 46 | ||||
| -rw-r--r-- | net/bluetooth/hci_sysfs.c | 18 | ||||
| -rw-r--r-- | net/bluetooth/hidp/core.c | 1 | ||||
| -rw-r--r-- | net/bluetooth/mgmt.c | 32 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/core.c | 14 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/tty.c | 20 |
9 files changed, 51 insertions, 120 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 91bcd3a961ec..a6cd856046ab 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
| @@ -65,15 +65,13 @@ static DECLARE_RWSEM(bnep_session_sem); | |||
| 65 | static struct bnep_session *__bnep_get_session(u8 *dst) | 65 | static struct bnep_session *__bnep_get_session(u8 *dst) |
| 66 | { | 66 | { |
| 67 | struct bnep_session *s; | 67 | struct bnep_session *s; |
| 68 | struct list_head *p; | ||
| 69 | 68 | ||
| 70 | BT_DBG(""); | 69 | BT_DBG(""); |
| 71 | 70 | ||
| 72 | list_for_each(p, &bnep_session_list) { | 71 | list_for_each_entry(s, &bnep_session_list, list) |
| 73 | s = list_entry(p, struct bnep_session, list); | ||
| 74 | if (!compare_ether_addr(dst, s->eh.h_source)) | 72 | if (!compare_ether_addr(dst, s->eh.h_source)) |
| 75 | return s; | 73 | return s; |
| 76 | } | 74 | |
| 77 | return NULL; | 75 | return NULL; |
| 78 | } | 76 | } |
| 79 | 77 | ||
| @@ -667,17 +665,14 @@ static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s) | |||
| 667 | 665 | ||
| 668 | int bnep_get_connlist(struct bnep_connlist_req *req) | 666 | int bnep_get_connlist(struct bnep_connlist_req *req) |
| 669 | { | 667 | { |
| 670 | struct list_head *p; | 668 | struct bnep_session *s; |
| 671 | int err = 0, n = 0; | 669 | int err = 0, n = 0; |
| 672 | 670 | ||
| 673 | down_read(&bnep_session_sem); | 671 | down_read(&bnep_session_sem); |
| 674 | 672 | ||
| 675 | list_for_each(p, &bnep_session_list) { | 673 | list_for_each_entry(s, &bnep_session_list, list) { |
| 676 | struct bnep_session *s; | ||
| 677 | struct bnep_conninfo ci; | 674 | struct bnep_conninfo ci; |
| 678 | 675 | ||
| 679 | s = list_entry(p, struct bnep_session, list); | ||
| 680 | |||
| 681 | __bnep_copy_ci(&ci, s); | 676 | __bnep_copy_ci(&ci, s); |
| 682 | 677 | ||
| 683 | if (copy_to_user(req->ci, &ci, sizeof(ci))) { | 678 | if (copy_to_user(req->ci, &ci, sizeof(ci))) { |
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 7d00ddf9e9dc..9e8940b24bba 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c | |||
| @@ -53,15 +53,13 @@ static LIST_HEAD(cmtp_session_list); | |||
| 53 | static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr) | 53 | static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr) |
| 54 | { | 54 | { |
| 55 | struct cmtp_session *session; | 55 | struct cmtp_session *session; |
| 56 | struct list_head *p; | ||
| 57 | 56 | ||
| 58 | BT_DBG(""); | 57 | BT_DBG(""); |
| 59 | 58 | ||
| 60 | list_for_each(p, &cmtp_session_list) { | 59 | list_for_each_entry(session, &cmtp_session_list, list) |
| 61 | session = list_entry(p, struct cmtp_session, list); | ||
| 62 | if (!bacmp(bdaddr, &session->bdaddr)) | 60 | if (!bacmp(bdaddr, &session->bdaddr)) |
| 63 | return session; | 61 | return session; |
| 64 | } | 62 | |
| 65 | return NULL; | 63 | return NULL; |
| 66 | } | 64 | } |
| 67 | 65 | ||
| @@ -431,19 +429,16 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) | |||
| 431 | 429 | ||
| 432 | int cmtp_get_connlist(struct cmtp_connlist_req *req) | 430 | int cmtp_get_connlist(struct cmtp_connlist_req *req) |
| 433 | { | 431 | { |
| 434 | struct list_head *p; | 432 | struct cmtp_session *session; |
| 435 | int err = 0, n = 0; | 433 | int err = 0, n = 0; |
| 436 | 434 | ||
| 437 | BT_DBG(""); | 435 | BT_DBG(""); |
| 438 | 436 | ||
| 439 | down_read(&cmtp_session_sem); | 437 | down_read(&cmtp_session_sem); |
| 440 | 438 | ||
| 441 | list_for_each(p, &cmtp_session_list) { | 439 | list_for_each_entry(session, &cmtp_session_list, list) { |
| 442 | struct cmtp_session *session; | ||
| 443 | struct cmtp_conninfo ci; | 440 | struct cmtp_conninfo ci; |
| 444 | 441 | ||
| 445 | session = list_entry(p, struct cmtp_session, list); | ||
| 446 | |||
| 447 | __cmtp_copy_session(session, &ci); | 442 | __cmtp_copy_session(session, &ci); |
| 448 | 443 | ||
| 449 | if (copy_to_user(req->ci, &ci, sizeof(ci))) { | 444 | if (copy_to_user(req->ci, &ci, sizeof(ci))) { |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index c1c597e3e198..6e98ff3da2a4 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
| @@ -453,16 +453,13 @@ int hci_conn_del(struct hci_conn *conn) | |||
| 453 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) | 453 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) |
| 454 | { | 454 | { |
| 455 | int use_src = bacmp(src, BDADDR_ANY); | 455 | int use_src = bacmp(src, BDADDR_ANY); |
| 456 | struct hci_dev *hdev = NULL; | 456 | struct hci_dev *hdev = NULL, *d; |
| 457 | struct list_head *p; | ||
| 458 | 457 | ||
| 459 | BT_DBG("%s -> %s", batostr(src), batostr(dst)); | 458 | BT_DBG("%s -> %s", batostr(src), batostr(dst)); |
| 460 | 459 | ||
| 461 | read_lock_bh(&hci_dev_list_lock); | 460 | read_lock_bh(&hci_dev_list_lock); |
| 462 | 461 | ||
| 463 | list_for_each(p, &hci_dev_list) { | 462 | list_for_each_entry(d, &hci_dev_list, list) { |
| 464 | struct hci_dev *d = list_entry(p, struct hci_dev, list); | ||
| 465 | |||
| 466 | if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags)) | 463 | if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags)) |
| 467 | continue; | 464 | continue; |
| 468 | 465 | ||
| @@ -855,10 +852,10 @@ EXPORT_SYMBOL(hci_conn_put_device); | |||
| 855 | 852 | ||
| 856 | int hci_get_conn_list(void __user *arg) | 853 | int hci_get_conn_list(void __user *arg) |
| 857 | { | 854 | { |
| 855 | register struct hci_conn *c; | ||
| 858 | struct hci_conn_list_req req, *cl; | 856 | struct hci_conn_list_req req, *cl; |
| 859 | struct hci_conn_info *ci; | 857 | struct hci_conn_info *ci; |
| 860 | struct hci_dev *hdev; | 858 | struct hci_dev *hdev; |
| 861 | struct list_head *p; | ||
| 862 | int n = 0, size, err; | 859 | int n = 0, size, err; |
| 863 | 860 | ||
| 864 | if (copy_from_user(&req, arg, sizeof(req))) | 861 | if (copy_from_user(&req, arg, sizeof(req))) |
| @@ -882,10 +879,7 @@ int hci_get_conn_list(void __user *arg) | |||
| 882 | ci = cl->conn_info; | 879 | ci = cl->conn_info; |
| 883 | 880 | ||
| 884 | hci_dev_lock_bh(hdev); | 881 | hci_dev_lock_bh(hdev); |
| 885 | list_for_each(p, &hdev->conn_hash.list) { | 882 | list_for_each_entry(c, &hdev->conn_hash.list, list) { |
| 886 | register struct hci_conn *c; | ||
| 887 | c = list_entry(p, struct hci_conn, list); | ||
| 888 | |||
| 889 | bacpy(&(ci + n)->bdaddr, &c->dst); | 883 | bacpy(&(ci + n)->bdaddr, &c->dst); |
| 890 | (ci + n)->handle = c->handle; | 884 | (ci + n)->handle = c->handle; |
| 891 | (ci + n)->type = c->type; | 885 | (ci + n)->type = c->type; |
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. */ |
| 320 | struct hci_dev *hci_dev_get(int index) | 320 | struct 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 | |
