diff options
author | Geliang Tang <geliangtang@163.com> | 2015-12-18 10:33:25 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-12-20 02:11:10 -0500 |
commit | 7eb7404f7ee4bf59cb034897ab678aba2755c5e0 (patch) | |
tree | 8a8d4ed999773f5b208bb0ca0771971e900fc5e9 /net/bluetooth/rfcomm/core.c | |
parent | 07f6f4a31e5a8dee67960fc07bb0b37c5f879d4d (diff) |
Bluetooth: use list_for_each_entry*
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.
Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 29709fbfd1f5..f7eb02f09b54 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -692,11 +692,9 @@ static struct rfcomm_session *rfcomm_session_del(struct rfcomm_session *s) | |||
692 | 692 | ||
693 | static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst) | 693 | static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst) |
694 | { | 694 | { |
695 | struct rfcomm_session *s; | 695 | struct rfcomm_session *s, *n; |
696 | struct list_head *p, *n; | ||
697 | struct l2cap_chan *chan; | 696 | struct l2cap_chan *chan; |
698 | list_for_each_safe(p, n, &session_list) { | 697 | list_for_each_entry_safe(s, n, &session_list, list) { |
699 | s = list_entry(p, struct rfcomm_session, list); | ||
700 | chan = l2cap_pi(s->sock->sk)->chan; | 698 | chan = l2cap_pi(s->sock->sk)->chan; |
701 | 699 | ||
702 | if ((!bacmp(src, BDADDR_ANY) || !bacmp(&chan->src, src)) && | 700 | if ((!bacmp(src, BDADDR_ANY) || !bacmp(&chan->src, src)) && |
@@ -709,16 +707,14 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst) | |||
709 | static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s, | 707 | static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s, |
710 | int err) | 708 | int err) |
711 | { | 709 | { |
712 | struct rfcomm_dlc *d; | 710 | struct rfcomm_dlc *d, *n; |
713 | struct list_head *p, *n; | ||
714 | 711 | ||
715 | s->state = BT_CLOSED; | 712 | s->state = BT_CLOSED; |
716 | 713 | ||
717 | BT_DBG("session %p state %ld err %d", s, s->state, err); | 714 | BT_DBG("session %p state %ld err %d", s, s->state, err); |
718 | 715 | ||
719 | /* Close all dlcs */ | 716 | /* Close all dlcs */ |
720 | list_for_each_safe(p, n, &s->dlcs) { | 717 | list_for_each_entry_safe(d, n, &s->dlcs, list) { |
721 | d = list_entry(p, struct rfcomm_dlc, list); | ||
722 | d->state = BT_CLOSED; | 718 | d->state = BT_CLOSED; |
723 | __rfcomm_dlc_close(d, err); | 719 | __rfcomm_dlc_close(d, err); |
724 | } | 720 | } |
@@ -1771,13 +1767,11 @@ static struct rfcomm_session *rfcomm_recv_frame(struct rfcomm_session *s, | |||
1771 | 1767 | ||
1772 | static void rfcomm_process_connect(struct rfcomm_session *s) | 1768 | static void rfcomm_process_connect(struct rfcomm_session *s) |
1773 | { | 1769 | { |
1774 | struct rfcomm_dlc *d; | 1770 | struct rfcomm_dlc *d, *n; |
1775 | struct list_head *p, *n; | ||
1776 | 1771 | ||
1777 | BT_DBG("session %p state %ld", s, s->state); | 1772 | BT_DBG("session %p state %ld", s, s->state); |
1778 | 1773 | ||
1779 | list_for_each_safe(p, n, &s->dlcs) { | 1774 | list_for_each_entry_safe(d, n, &s->dlcs, list) { |
1780 | d = list_entry(p, struct rfcomm_dlc, list); | ||
1781 | if (d->state == BT_CONFIG) { | 1775 | if (d->state == BT_CONFIG) { |
1782 | d->mtu = s->mtu; | 1776 | d->mtu = s->mtu; |
1783 | if (rfcomm_check_security(d)) { | 1777 | if (rfcomm_check_security(d)) { |
@@ -1843,14 +1837,11 @@ static int rfcomm_process_tx(struct rfcomm_dlc *d) | |||
1843 | 1837 | ||
1844 | static void rfcomm_process_dlcs(struct rfcomm_session *s) | 1838 | static void rfcomm_process_dlcs(struct rfcomm_session *s) |
1845 | { | 1839 | { |
1846 | struct rfcomm_dlc *d; | 1840 | struct rfcomm_dlc *d, *n; |
1847 | struct list_head *p, *n; | ||
1848 | 1841 | ||
1849 | BT_DBG("session %p state %ld", s, s->state); | 1842 | BT_DBG("session %p state %ld", s, s->state); |
1850 | 1843 | ||
1851 | list_for_each_safe(p, n, &s->dlcs) { | 1844 | list_for_each_entry_safe(d, n, &s->dlcs, list) { |
1852 | d = list_entry(p, struct rfcomm_dlc, list); | ||
1853 | |||
1854 | if (test_bit(RFCOMM_TIMED_OUT, &d->flags)) { | 1845 | if (test_bit(RFCOMM_TIMED_OUT, &d->flags)) { |
1855 | __rfcomm_dlc_close(d, ETIMEDOUT); | 1846 | __rfcomm_dlc_close(d, ETIMEDOUT); |
1856 | continue; | 1847 | continue; |
@@ -1985,14 +1976,11 @@ static struct rfcomm_session *rfcomm_check_connection(struct rfcomm_session *s) | |||
1985 | 1976 | ||
1986 | static void rfcomm_process_sessions(void) | 1977 | static void rfcomm_process_sessions(void) |
1987 | { | 1978 | { |
1988 | struct list_head *p, *n; | 1979 | struct rfcomm_session *s, *n; |
1989 | 1980 | ||
1990 | rfcomm_lock(); | 1981 | rfcomm_lock(); |
1991 | 1982 | ||
1992 | list_for_each_safe(p, n, &session_list) { | 1983 | list_for_each_entry_safe(s, n, &session_list, list) { |
1993 | struct rfcomm_session *s; | ||
1994 | s = list_entry(p, struct rfcomm_session, list); | ||
1995 | |||
1996 | if (test_and_clear_bit(RFCOMM_TIMED_OUT, &s->flags)) { | 1984 | if (test_and_clear_bit(RFCOMM_TIMED_OUT, &s->flags)) { |
1997 | s->state = BT_DISCONN; | 1985 | s->state = BT_DISCONN; |
1998 | rfcomm_send_disc(s, 0); | 1986 | rfcomm_send_disc(s, 0); |
@@ -2075,15 +2063,12 @@ failed: | |||
2075 | 2063 | ||
2076 | static void rfcomm_kill_listener(void) | 2064 | static void rfcomm_kill_listener(void) |
2077 | { | 2065 | { |
2078 | struct rfcomm_session *s; | 2066 | struct rfcomm_session *s, *n; |
2079 | struct list_head *p, *n; | ||
2080 | 2067 | ||
2081 | BT_DBG(""); | 2068 | BT_DBG(""); |
2082 | 2069 | ||
2083 | list_for_each_safe(p, n, &session_list) { | 2070 | list_for_each_entry_safe(s, n, &session_list, list) |
2084 | s = list_entry(p, struct rfcomm_session, list); | ||
2085 | rfcomm_session_del(s); | 2071 | rfcomm_session_del(s); |
2086 | } | ||
2087 | } | 2072 | } |
2088 | 2073 | ||
2089 | static int rfcomm_run(void *unused) | 2074 | static int rfcomm_run(void *unused) |
@@ -2113,8 +2098,7 @@ static int rfcomm_run(void *unused) | |||
2113 | static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt) | 2098 | static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt) |
2114 | { | 2099 | { |
2115 | struct rfcomm_session *s; | 2100 | struct rfcomm_session *s; |
2116 | struct rfcomm_dlc *d; | 2101 | struct rfcomm_dlc *d, *n; |
2117 | struct list_head *p, *n; | ||
2118 | 2102 | ||
2119 | BT_DBG("conn %p status 0x%02x encrypt 0x%02x", conn, status, encrypt); | 2103 | BT_DBG("conn %p status 0x%02x encrypt 0x%02x", conn, status, encrypt); |
2120 | 2104 | ||
@@ -2122,9 +2106,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt) | |||
2122 | if (!s) | 2106 | if (!s) |
2123 | return; | 2107 | return; |
2124 | 2108 | ||
2125 | list_for_each_safe(p, n, &s->dlcs) { | 2109 | list_for_each_entry_safe(d, n, &s->dlcs, list) { |
2126 | d = list_entry(p, struct rfcomm_dlc, list); | ||
2127 | |||
2128 | if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) { | 2110 | if (test_and_clear_bit(RFCOMM_SEC_PENDING, &d->flags)) { |
2129 | rfcomm_dlc_clear_timer(d); | 2111 | rfcomm_dlc_clear_timer(d); |
2130 | if (status || encrypt == 0x00) { | 2112 | if (status || encrypt == 0x00) { |