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/mgmt.c | |
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/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9ffd7c3dbb3e..7809aa979358 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -123,6 +123,7 @@ static int read_index_list(struct sock *sk) | |||
123 | { | 123 | { |
124 | struct mgmt_rp_read_index_list *rp; | 124 | struct mgmt_rp_read_index_list *rp; |
125 | struct list_head *p; | 125 | struct list_head *p; |
126 | struct hci_dev *d; | ||
126 | size_t rp_len; | 127 | size_t rp_len; |
127 | u16 count; | 128 | u16 count; |
128 | int i, err; | 129 | int i, err; |
@@ -146,9 +147,7 @@ static int read_index_list(struct sock *sk) | |||
146 | put_unaligned_le16(count, &rp->num_controllers); | 147 | put_unaligned_le16(count, &rp->num_controllers); |
147 | 148 | ||
148 | i = 0; | 149 | i = 0; |
149 | list_for_each(p, &hci_dev_list) { | 150 | list_for_each_entry(d, &hci_dev_list, list) { |
150 | struct hci_dev *d = list_entry(p, struct hci_dev, list); | ||
151 | |||
152 | hci_del_off_timer(d); | 151 | hci_del_off_timer(d); |
153 | 152 | ||
154 | set_bit(HCI_MGMT, &d->flags); | 153 | set_bit(HCI_MGMT, &d->flags); |
@@ -277,13 +276,9 @@ static void mgmt_pending_foreach(u16 opcode, int index, | |||
277 | 276 | ||
278 | static struct pending_cmd *mgmt_pending_find(u16 opcode, int index) | 277 | static struct pending_cmd *mgmt_pending_find(u16 opcode, int index) |
279 | { | 278 | { |
280 | struct list_head *p; | 279 | struct pending_cmd *cmd; |
281 | |||
282 | list_for_each(p, &cmd_list) { | ||
283 | struct pending_cmd *cmd; | ||
284 | |||
285 | cmd = list_entry(p, struct pending_cmd, list); | ||
286 | 280 | ||
281 | list_for_each_entry(cmd, &cmd_list, list) { | ||
287 | if (cmd->opcode != opcode) | 282 | if (cmd->opcode != opcode) |
288 | continue; | 283 | continue; |
289 | 284 | ||
@@ -592,7 +587,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data) | |||
592 | u16 eir_len = 0; | 587 | u16 eir_len = 0; |
593 | u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)]; | 588 | u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)]; |
594 | int i, truncated = 0; | 589 | int i, truncated = 0; |
595 | struct list_head *p; | 590 | struct bt_uuid *uuid; |
596 | size_t name_len; | 591 | size_t name_len; |
597 | 592 | ||
598 | name_len = strlen(hdev->dev_name); | 593 | name_len = strlen(hdev->dev_name); |
@@ -617,8 +612,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data) | |||
617 | memset(uuid16_list, 0, sizeof(uuid16_list)); | 612 | memset(uuid16_list, 0, sizeof(uuid16_list)); |
618 | 613 | ||
619 | /* Group all UUID16 types */ | 614 | /* Group all UUID16 types */ |
620 | list_for_each(p, &hdev->uuids) { | 615 | list_for_each_entry(uuid, &hdev->uuids, list) { |
621 | struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list); | ||
622 | u16 uuid16; | 616 | u16 uuid16; |
623 | 617 | ||
624 | uuid16 = get_uuid16(uuid->uuid); | 618 | uuid16 = get_uuid16(uuid->uuid); |
@@ -1069,6 +1063,7 @@ static int get_connections(struct sock *sk, u16 index) | |||
1069 | { | 1063 | { |
1070 | struct mgmt_rp_get_connections *rp; | 1064 | struct mgmt_rp_get_connections *rp; |
1071 | struct hci_dev *hdev; | 1065 | struct hci_dev *hdev; |
1066 | struct hci_conn *c; | ||
1072 | struct list_head *p; | 1067 | struct list_head *p; |
1073 | size_t rp_len; | 1068 | size_t rp_len; |
1074 | u16 count; | 1069 | u16 count; |
@@ -1097,11 +1092,8 @@ static int get_connections(struct sock *sk, u16 index) | |||
1097 | put_unaligned_le16(count, &rp->conn_count); | 1092 | put_unaligned_le16(count, &rp->conn_count); |
1098 | 1093 | ||
1099 | i = 0; | 1094 | i = 0; |
1100 | list_for_each(p, &hdev->conn_hash.list) { | 1095 | list_for_each_entry(c, &hdev->conn_hash.list, list) |
1101 | struct hci_conn *c = list_entry(p, struct hci_conn, list); | ||
1102 | |||
1103 | bacpy(&rp->conn[i++], &c->dst); | 1096 | bacpy(&rp->conn[i++], &c->dst); |
1104 | } | ||
1105 | 1097 | ||
1106 | err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); | 1098 | err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); |
1107 | 1099 | ||
@@ -1270,13 +1262,9 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data, | |||
1270 | static inline struct pending_cmd *find_pairing(struct hci_conn *conn) | 1262 | static inline struct pending_cmd *find_pairing(struct hci_conn *conn) |
1271 | { | 1263 | { |
1272 | struct hci_dev *hdev = conn->hdev; | 1264 | struct hci_dev *hdev = conn->hdev; |
1273 | struct list_head *p; | 1265 | struct pending_cmd *cmd; |
1274 | |||
1275 | list_for_each(p, &cmd_list) { | ||
1276 | struct pending_cmd *cmd; | ||
1277 | |||
1278 | cmd = list_entry(p, struct pending_cmd, list); | ||
1279 | 1266 | ||
1267 | list_for_each_entry(cmd, &cmd_list, list) { | ||
1280 | if (cmd->opcode != MGMT_OP_PAIR_DEVICE) | 1268 | if (cmd->opcode != MGMT_OP_PAIR_DEVICE) |
1281 | continue; | 1269 | continue; |
1282 | 1270 | ||