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/rfcomm | |
| 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/rfcomm')
| -rw-r--r-- | net/bluetooth/rfcomm/core.c | 14 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/tty.c | 20 |
2 files changed, 12 insertions, 22 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 38b618c96de6..3d35eba6d0cb 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
| @@ -377,13 +377,11 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d) | |||
| 377 | static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) | 377 | static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) |
| 378 | { | 378 | { |
| 379 | struct rfcomm_dlc *d; | 379 | struct rfcomm_dlc *d; |
| 380 | struct list_head *p; | ||
| 381 | 380 | ||
| 382 | list_for_each(p, &s->dlcs) { | 381 | list_for_each_entry(d, &s->dlcs, list) |
| 383 | d = list_entry(p, struct rfcomm_dlc, list); | ||
| 384 | if (d->dlci == dlci) | 382 | if (d->dlci == dlci) |
| 385 | return d; | 383 | return d; |
| 386 | } | 384 | |
| 387 | return NULL; | 385 | return NULL; |
| 388 | } | 386 | } |
| 389 | 387 | ||
| @@ -2115,15 +2113,13 @@ static struct hci_cb rfcomm_cb = { | |||
| 2115 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) | 2113 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) |
| 2116 | { | 2114 | { |
| 2117 | struct rfcomm_session *s; | 2115 | struct rfcomm_session *s; |
| 2118 | struct list_head *pp, *p; | ||
| 2119 | 2116 | ||
| 2120 | rfcomm_lock(); | 2117 | rfcomm_lock(); |
| 2121 | 2118 | ||
| 2122 | list_for_each(p, &session_list) { | 2119 | list_for_each_entry(s, &session_list, list) { |
| 2123 | s = list_entry(p, struct rfcomm_session, list); | 2120 | struct rfcomm_dlc *d; |
| 2124 | list_for_each(pp, &s->dlcs) { | 2121 | list_for_each_entry(d, &s->dlcs, list) { |
| 2125 | struct sock *sk = s->sock->sk; | 2122 | struct sock *sk = s->sock->sk; |
| 2126 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); | ||
| 2127 | 2123 | ||
| 2128 | seq_printf(f, "%s %s %ld %d %d %d %d\n", | 2124 | seq_printf(f, "%s %s %ld %d %d %d %d\n", |
| 2129 | batostr(&bt_sk(sk)->src), | 2125 | batostr(&bt_sk(sk)->src), |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 947f1b3afd15..fa8f4de53b99 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
| @@ -134,13 +134,10 @@ static inline void rfcomm_dev_put(struct rfcomm_dev *dev) | |||
| 134 | static struct rfcomm_dev *__rfcomm_dev_get(int id) | 134 | static struct rfcomm_dev *__rfcomm_dev_get(int id) |
| 135 | { | 135 | { |
| 136 | struct rfcomm_dev *dev; | 136 | struct rfcomm_dev *dev; |
| 137 | struct list_head *p; | ||
| 138 | 137 | ||
| 139 | list_for_each(p, &rfcomm_dev_list) { | 138 | list_for_each_entry(dev, &rfcomm_dev_list, list) |
| 140 | dev = list_entry(p, struct rfcomm_dev, list); | ||
| 141 | if (dev->id == id) | 139 | if (dev->id == id) |
| 142 | return dev; | 140 | return dev; |
| 143 | } | ||
| 144 | 141 | ||
| 145 | return NULL; | 142 | return NULL; |
| 146 | } | 143 | } |
| @@ -198,7 +195,7 @@ static DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL); | |||
| 198 | 195 | ||
| 199 | static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | 196 | static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) |
| 200 | { | 197 | { |
| 201 | struct rfcomm_dev *dev; | 198 | struct rfcomm_dev *dev, *entry; |
| 202 | struct list_head *head = &rfcomm_dev_list, *p; | 199 | struct list_head *head = &rfcomm_dev_list, *p; |
| 203 | int err = 0; | 200 | int err = 0; |
| 204 | 201 | ||
| @@ -213,8 +210,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | |||
| 213 | if (req->dev_id < 0) { | 210 | if (req->dev_id < 0) { |
| 214 | dev->id = 0; | 211 | dev->id = 0; |
| 215 | 212 | ||
| 216 | list_for_each(p, &rfcomm_dev_list) { | 213 | list_for_each_entry(entry, &rfcomm_dev_list, list) { |
| 217 | if (list_entry(p, struct rfcomm_dev, list)->id != dev->id) | 214 | if (entry->id != dev->id) |
| 218 | break; | 215 | break; |
| 219 | 216 | ||
| 220 | dev->id++; | 217 | dev->id++; |
| @@ -223,9 +220,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) | |||
| 223 | } else { | 220 | } else { |
| 224 | dev->id = req->dev_id; | 221 | dev->id = req->dev_id; |
| 225 | 222 | ||
| 226 | list_for_each(p, &rfcomm_dev_list) { | 223 | list_for_each_entry(entry, &rfcomm_dev_list, list) { |
| 227 | struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list); | ||
| 228 | |||
| 229 | if (entry->id == dev->id) { | 224 | if (entry->id == dev->id) { |
| 230 | err = -EADDRINUSE; | 225 | err = -EADDRINUSE; |
| 231 | goto out; | 226 | goto out; |
| @@ -456,9 +451,9 @@ static int rfcomm_release_dev(void __user *arg) | |||
| 456 | 451 | ||
| 457 | static int rfcomm_get_dev_list(void __user *arg) | 452 | static int rfcomm_get_dev_list(void __user *arg) |
| 458 | { | 453 | { |
| 454 | struct rfcomm_dev *dev; | ||
| 459 | struct rfcomm_dev_list_req *dl; | 455 | struct rfcomm_dev_list_req *dl; |
| 460 | struct rfcomm_dev_info *di; | 456 | struct rfcomm_dev_info *di; |
| 461 | struct list_head *p; | ||
| 462 | int n = 0, size, err; | 457 | int n = 0, size, err; |
| 463 | u16 dev_num; | 458 | u16 dev_num; |
| 464 | 459 | ||
| @@ -480,8 +475,7 @@ static int rfcomm_get_dev_list(void __user *arg) | |||
| 480 | 475 | ||
| 481 | read_lock_bh(&rfcomm_dev_lock); | 476 | read_lock_bh(&rfcomm_dev_lock); |
| 482 | 477 | ||
| 483 | list_for_each(p, &rfcomm_dev_list) { | 478 | list_for_each_entry(dev, &rfcomm_dev_list, list) { |
| 484 | struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list); | ||
| 485 | if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) | 479 | if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) |
| 486 | continue; | 480 | continue; |
| 487 | (di + n)->id = dev->id; | 481 | (di + n)->id = dev->id; |
