diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-10 16:02:12 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-16 17:57:14 -0400 |
commit | c1360a1cf35117d6f3898cb5183ce4349d06714c (patch) | |
tree | 0a68031ba6f6252054d7b6b5b5a40913a29c58e4 | |
parent | 7fbec224cfb44074ab88720c878aa3bdb3158377 (diff) |
Bluetooth: use bit operation on conf_state
Instead of making the bit operations manually, we now use set_bit,
test_bit, etc.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | include/net/bluetooth/l2cap.h | 20 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 77 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 4 |
3 files changed, 48 insertions, 53 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index bf1c7f681932..4ab1b27996bc 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -324,7 +324,7 @@ struct l2cap_chan { | |||
324 | __u16 monitor_timeout; | 324 | __u16 monitor_timeout; |
325 | __u16 mps; | 325 | __u16 mps; |
326 | 326 | ||
327 | __u8 conf_state; | 327 | unsigned long conf_state; |
328 | __u16 conn_state; | 328 | __u16 conn_state; |
329 | 329 | ||
330 | __u8 next_tx_seq; | 330 | __u8 next_tx_seq; |
@@ -424,14 +424,16 @@ struct l2cap_pinfo { | |||
424 | struct l2cap_chan *chan; | 424 | struct l2cap_chan *chan; |
425 | }; | 425 | }; |
426 | 426 | ||
427 | #define L2CAP_CONF_REQ_SENT 0x01 | 427 | enum { |
428 | #define L2CAP_CONF_INPUT_DONE 0x02 | 428 | CONF_REQ_SENT, |
429 | #define L2CAP_CONF_OUTPUT_DONE 0x04 | 429 | CONF_INPUT_DONE, |
430 | #define L2CAP_CONF_MTU_DONE 0x08 | 430 | CONF_OUTPUT_DONE, |
431 | #define L2CAP_CONF_MODE_DONE 0x10 | 431 | CONF_MTU_DONE, |
432 | #define L2CAP_CONF_CONNECT_PEND 0x20 | 432 | CONF_MODE_DONE, |
433 | #define L2CAP_CONF_NO_FCS_RECV 0x40 | 433 | CONF_CONNECT_PEND, |
434 | #define L2CAP_CONF_STATE2_DEVICE 0x80 | 434 | CONF_NO_FCS_RECV, |
435 | CONF_STATE2_DEVICE, | ||
436 | }; | ||
435 | 437 | ||
436 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 438 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
437 | #define L2CAP_CONF_MAX_CONF_RSP 2 | 439 | #define L2CAP_CONF_MAX_CONF_RSP 2 |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index bbbae2e0aa84..b4e927eb174e 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -381,8 +381,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
381 | } else | 381 | } else |
382 | sk->sk_state_change(sk); | 382 | sk->sk_state_change(sk); |
383 | 383 | ||
384 | if (!(chan->conf_state & L2CAP_CONF_OUTPUT_DONE && | 384 | if (!(test_bit(CONF_OUTPUT_DONE, &chan->conf_state) && |
385 | chan->conf_state & L2CAP_CONF_INPUT_DONE)) | 385 | test_bit(CONF_INPUT_DONE, &chan->conf_state))) |
386 | return; | 386 | return; |
387 | 387 | ||
388 | skb_queue_purge(&chan->tx_q); | 388 | skb_queue_purge(&chan->tx_q); |
@@ -633,7 +633,7 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) | |||
633 | 633 | ||
634 | static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) | 634 | static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) |
635 | { | 635 | { |
636 | return !(chan->conf_state & L2CAP_CONF_CONNECT_PEND); | 636 | return !test_bit(CONF_CONNECT_PEND, &chan->conf_state); |
637 | } | 637 | } |
638 | 638 | ||
639 | static void l2cap_do_start(struct l2cap_chan *chan) | 639 | static void l2cap_do_start(struct l2cap_chan *chan) |
@@ -651,7 +651,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) | |||
651 | req.psm = chan->psm; | 651 | req.psm = chan->psm; |
652 | 652 | ||
653 | chan->ident = l2cap_get_ident(conn); | 653 | chan->ident = l2cap_get_ident(conn); |
654 | chan->conf_state |= L2CAP_CONF_CONNECT_PEND; | 654 | set_bit(CONF_CONNECT_PEND, &chan->conf_state); |
655 | 655 | ||
656 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, | 656 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, |
657 | sizeof(req), &req); | 657 | sizeof(req), &req); |
@@ -740,10 +740,9 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
740 | continue; | 740 | continue; |
741 | } | 741 | } |
742 | 742 | ||
743 | if (!l2cap_mode_supported(chan->mode, | 743 | if (!l2cap_mode_supported(chan->mode, conn->feat_mask) |
744 | conn->feat_mask) | 744 | && test_bit(CONF_STATE2_DEVICE, |
745 | && chan->conf_state & | 745 | &chan->conf_state)) { |
746 | L2CAP_CONF_STATE2_DEVICE) { | ||
747 | /* l2cap_chan_close() calls list_del(chan) | 746 | /* l2cap_chan_close() calls list_del(chan) |
748 | * so release the lock */ | 747 | * so release the lock */ |
749 | read_unlock_bh(&conn->chan_lock); | 748 | read_unlock_bh(&conn->chan_lock); |
@@ -757,7 +756,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
757 | req.psm = chan->psm; | 756 | req.psm = chan->psm; |
758 | 757 | ||
759 | chan->ident = l2cap_get_ident(conn); | 758 | chan->ident = l2cap_get_ident(conn); |
760 | chan->conf_state |= L2CAP_CONF_CONNECT_PEND; | 759 | set_bit(CONF_CONNECT_PEND, &chan->conf_state); |
761 | 760 | ||
762 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, | 761 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, |
763 | sizeof(req), &req); | 762 | sizeof(req), &req); |
@@ -788,13 +787,13 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
788 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 787 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
789 | sizeof(rsp), &rsp); | 788 | sizeof(rsp), &rsp); |
790 | 789 | ||
791 | if (chan->conf_state & L2CAP_CONF_REQ_SENT || | 790 | if (test_bit(CONF_REQ_SENT, &chan->conf_state) || |
792 | rsp.result != L2CAP_CR_SUCCESS) { | 791 | rsp.result != L2CAP_CR_SUCCESS) { |
793 | bh_unlock_sock(sk); | 792 | bh_unlock_sock(sk); |
794 | continue; | 793 | continue; |
795 | } | 794 | } |
796 | 795 | ||
797 | chan->conf_state |= L2CAP_CONF_REQ_SENT; | 796 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
798 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 797 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
799 | l2cap_build_conf_req(chan, buf), buf); | 798 | l2cap_build_conf_req(chan, buf), buf); |
800 | chan->num_conf_req++; | 799 | chan->num_conf_req++; |
@@ -1917,7 +1916,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) | |||
1917 | switch (chan->mode) { | 1916 | switch (chan->mode) { |
1918 | case L2CAP_MODE_STREAMING: | 1917 | case L2CAP_MODE_STREAMING: |
1919 | case L2CAP_MODE_ERTM: | 1918 | case L2CAP_MODE_ERTM: |
1920 | if (chan->conf_state & L2CAP_CONF_STATE2_DEVICE) | 1919 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) |
1921 | break; | 1920 | break; |
1922 | 1921 | ||
1923 | /* fall through */ | 1922 | /* fall through */ |
@@ -1964,7 +1963,7 @@ done: | |||
1964 | break; | 1963 | break; |
1965 | 1964 | ||
1966 | if (chan->fcs == L2CAP_FCS_NONE || | 1965 | if (chan->fcs == L2CAP_FCS_NONE || |
1967 | chan->conf_state & L2CAP_CONF_NO_FCS_RECV) { | 1966 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
1968 | chan->fcs = L2CAP_FCS_NONE; | 1967 | chan->fcs = L2CAP_FCS_NONE; |
1969 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 1968 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
1970 | } | 1969 | } |
@@ -1987,7 +1986,7 @@ done: | |||
1987 | break; | 1986 | break; |
1988 | 1987 | ||
1989 | if (chan->fcs == L2CAP_FCS_NONE || | 1988 | if (chan->fcs == L2CAP_FCS_NONE || |
1990 | chan->conf_state & L2CAP_CONF_NO_FCS_RECV) { | 1989 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
1991 | chan->fcs = L2CAP_FCS_NONE; | 1990 | chan->fcs = L2CAP_FCS_NONE; |
1992 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 1991 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
1993 | } | 1992 | } |
@@ -2039,7 +2038,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
2039 | 2038 | ||
2040 | case L2CAP_CONF_FCS: | 2039 | case L2CAP_CONF_FCS: |
2041 | if (val == L2CAP_FCS_NONE) | 2040 | if (val == L2CAP_FCS_NONE) |
2042 | chan->conf_state |= L2CAP_CONF_NO_FCS_RECV; | 2041 | set_bit(CONF_NO_FCS_RECV, &chan->conf_state); |
2043 | 2042 | ||
2044 | break; | 2043 | break; |
2045 | 2044 | ||
@@ -2059,7 +2058,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
2059 | switch (chan->mode) { | 2058 | switch (chan->mode) { |
2060 | case L2CAP_MODE_STREAMING: | 2059 | case L2CAP_MODE_STREAMING: |
2061 | case L2CAP_MODE_ERTM: | 2060 | case L2CAP_MODE_ERTM: |
2062 | if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { | 2061 | if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { |
2063 | chan->mode = l2cap_select_mode(rfc.mode, | 2062 | chan->mode = l2cap_select_mode(rfc.mode, |
2064 | chan->conn->feat_mask); | 2063 | chan->conn->feat_mask); |
2065 | break; | 2064 | break; |
@@ -2092,14 +2091,14 @@ done: | |||
2092 | result = L2CAP_CONF_UNACCEPT; | 2091 | result = L2CAP_CONF_UNACCEPT; |
2093 | else { | 2092 | else { |
2094 | chan->omtu = mtu; | 2093 | chan->omtu = mtu; |
2095 | chan->conf_state |= L2CAP_CONF_MTU_DONE; | 2094 | set_bit(CONF_MTU_DONE, &chan->conf_state); |
2096 | } | 2095 | } |
2097 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); | 2096 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); |
2098 | 2097 | ||
2099 | switch (rfc.mode) { | 2098 | switch (rfc.mode) { |
2100 | case L2CAP_MODE_BASIC: | 2099 | case L2CAP_MODE_BASIC: |
2101 | chan->fcs = L2CAP_FCS_NONE; | 2100 | chan->fcs = L2CAP_FCS_NONE; |
2102 | chan->conf_state |= L2CAP_CONF_MODE_DONE; | 2101 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
2103 | break; | 2102 | break; |
2104 | 2103 | ||
2105 | case L2CAP_MODE_ERTM: | 2104 | case L2CAP_MODE_ERTM: |
@@ -2116,7 +2115,7 @@ done: | |||
2116 | rfc.monitor_timeout = | 2115 | rfc.monitor_timeout = |
2117 | le16_to_cpu(L2CAP_DEFAULT_MONITOR_TO); | 2116 | le16_to_cpu(L2CAP_DEFAULT_MONITOR_TO); |
2118 | 2117 | ||
2119 | chan->conf_state |= L2CAP_CONF_MODE_DONE; | 2118 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
2120 | 2119 | ||
2121 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 2120 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
2122 | sizeof(rfc), (unsigned long) &rfc); | 2121 | sizeof(rfc), (unsigned long) &rfc); |
@@ -2129,7 +2128,7 @@ done: | |||
2129 | 2128 | ||
2130 | chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); | 2129 | chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); |
2131 | 2130 | ||
2132 | chan->conf_state |= L2CAP_CONF_MODE_DONE; | 2131 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
2133 | 2132 | ||
2134 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 2133 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
2135 | sizeof(rfc), (unsigned long) &rfc); | 2134 | sizeof(rfc), (unsigned long) &rfc); |
@@ -2144,7 +2143,7 @@ done: | |||
2144 | } | 2143 | } |
2145 | 2144 | ||
2146 | if (result == L2CAP_CONF_SUCCESS) | 2145 | if (result == L2CAP_CONF_SUCCESS) |
2147 | chan->conf_state |= L2CAP_CONF_OUTPUT_DONE; | 2146 | set_bit(CONF_OUTPUT_DONE, &chan->conf_state); |
2148 | } | 2147 | } |
2149 | rsp->scid = cpu_to_le16(chan->dcid); | 2148 | rsp->scid = cpu_to_le16(chan->dcid); |
2150 | rsp->result = cpu_to_le16(result); | 2149 | rsp->result = cpu_to_le16(result); |
@@ -2186,7 +2185,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
2186 | if (olen == sizeof(rfc)) | 2185 | if (olen == sizeof(rfc)) |
2187 | memcpy(&rfc, (void *)val, olen); | 2186 | memcpy(&rfc, (void *)val, olen); |
2188 | 2187 | ||
2189 | if ((chan->conf_state & L2CAP_CONF_STATE2_DEVICE) && | 2188 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && |
2190 | rfc.mode != chan->mode) | 2189 | rfc.mode != chan->mode) |
2191 | return -ECONNREFUSED; | 2190 | return -ECONNREFUSED; |
2192 | 2191 | ||
@@ -2248,10 +2247,9 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) | |||
2248 | l2cap_send_cmd(conn, chan->ident, | 2247 | l2cap_send_cmd(conn, chan->ident, |
2249 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 2248 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
2250 | 2249 | ||
2251 | if (chan->conf_state & L2CAP_CONF_REQ_SENT) | 2250 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) |
2252 | return; | 2251 | return; |
2253 | 2252 | ||
2254 | chan->conf_state |= L2CAP_CONF_REQ_SENT; | ||
2255 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 2253 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
2256 | l2cap_build_conf_req(chan, buf), buf); | 2254 | l2cap_build_conf_req(chan, buf), buf); |
2257 | chan->num_conf_req++; | 2255 | chan->num_conf_req++; |
@@ -2433,10 +2431,10 @@ sendresp: | |||
2433 | L2CAP_INFO_REQ, sizeof(info), &info); | 2431 | L2CAP_INFO_REQ, sizeof(info), &info); |
2434 | } | 2432 | } |
2435 | 2433 | ||
2436 | if (chan && !(chan->conf_state & L2CAP_CONF_REQ_SENT) && | 2434 | if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && |
2437 | result == L2CAP_CR_SUCCESS) { | 2435 | result == L2CAP_CR_SUCCESS) { |
2438 | u8 buf[128]; | 2436 | u8 buf[128]; |
2439 | chan->conf_state |= L2CAP_CONF_REQ_SENT; | 2437 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
2440 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 2438 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
2441 | l2cap_build_conf_req(chan, buf), buf); | 2439 | l2cap_build_conf_req(chan, buf), buf); |
2442 | chan->num_conf_req++; | 2440 | chan->num_conf_req++; |
@@ -2477,20 +2475,18 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
2477 | l2cap_state_change(chan, BT_CONFIG); | 2475 | l2cap_state_change(chan, BT_CONFIG); |
2478 | chan->ident = 0; | 2476 | chan->ident = 0; |
2479 | chan->dcid = dcid; | 2477 | chan->dcid = dcid; |
2480 | chan->conf_state &= ~L2CAP_CONF_CONNECT_PEND; | 2478 | clear_bit(CONF_CONNECT_PEND, &chan->conf_state); |
2481 | 2479 | ||
2482 | if (chan->conf_state & L2CAP_CONF_REQ_SENT) | 2480 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) |
2483 | break; | 2481 | break; |
2484 | 2482 | ||
2485 | chan->conf_state |= L2CAP_CONF_REQ_SENT; | ||
2486 | |||
2487 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 2483 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
2488 | l2cap_build_conf_req(chan, req), req); | 2484 | l2cap_build_conf_req(chan, req), req); |
2489 | chan->num_conf_req++; | 2485 | chan->num_conf_req++; |
2490 | break; | 2486 | break; |
2491 | 2487 | ||
2492 | case L2CAP_CR_PEND: | 2488 | case L2CAP_CR_PEND: |
2493 | chan->conf_state |= L2CAP_CONF_CONNECT_PEND; | 2489 | set_bit(CONF_CONNECT_PEND, &chan->conf_state); |
2494 | break; | 2490 | break; |
2495 | 2491 | ||
2496 | default: | 2492 | default: |
@@ -2512,14 +2508,12 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
2512 | 2508 | ||
2513 | static inline void set_default_fcs(struct l2cap_chan *chan) | 2509 | static inline void set_default_fcs(struct l2cap_chan *chan) |
2514 | { | 2510 | { |
2515 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | ||
2516 | |||
2517 | /* FCS is enabled only in ERTM or streaming mode, if one or both | 2511 | /* FCS is enabled only in ERTM or streaming mode, if one or both |
2518 | * sides request it. | 2512 | * sides request it. |
2519 | */ | 2513 | */ |
2520 | if (chan->mode != L2CAP_MODE_ERTM && chan->mode != L2CAP_MODE_STREAMING) | 2514 | if (chan->mode != L2CAP_MODE_ERTM && chan->mode != L2CAP_MODE_STREAMING) |
2521 | chan->fcs = L2CAP_FCS_NONE; | 2515 | chan->fcs = L2CAP_FCS_NONE; |
2522 | else if (!(pi->chan->conf_state & L2CAP_CONF_NO_FCS_RECV)) | 2516 | else if (!test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) |
2523 | chan->fcs = L2CAP_FCS_CRC16; | 2517 | chan->fcs = L2CAP_FCS_CRC16; |
2524 | } | 2518 | } |
2525 | 2519 | ||
@@ -2586,10 +2580,10 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2586 | /* Reset config buffer. */ | 2580 | /* Reset config buffer. */ |
2587 | chan->conf_len = 0; | 2581 | chan->conf_len = 0; |
2588 | 2582 | ||
2589 | if (!(chan->conf_state & L2CAP_CONF_OUTPUT_DONE)) | 2583 | if (!test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) |
2590 | goto unlock; | 2584 | goto unlock; |
2591 | 2585 | ||
2592 | if (chan->conf_state & L2CAP_CONF_INPUT_DONE) { | 2586 | if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) { |
2593 | set_default_fcs(chan); | 2587 | set_default_fcs(chan); |
2594 | 2588 | ||
2595 | l2cap_state_change(chan, BT_CONNECTED); | 2589 | l2cap_state_change(chan, BT_CONNECTED); |
@@ -2604,9 +2598,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2604 | goto unlock; | 2598 | goto unlock; |
2605 | } | 2599 | } |
2606 | 2600 | ||
2607 | if (!(chan->conf_state & L2CAP_CONF_REQ_SENT)) { | 2601 | if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { |
2608 | u8 buf[64]; | 2602 | u8 buf[64]; |
2609 | chan->conf_state |= L2CAP_CONF_REQ_SENT; | ||
2610 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 2603 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
2611 | l2cap_build_conf_req(chan, buf), buf); | 2604 | l2cap_build_conf_req(chan, buf), buf); |
2612 | chan->num_conf_req++; | 2605 | chan->num_conf_req++; |
@@ -2679,9 +2672,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2679 | if (flags & 0x01) | 2672 | if (flags & 0x01) |
2680 | goto done; | 2673 | goto done; |
2681 | 2674 | ||
2682 | chan->conf_state |= L2CAP_CONF_INPUT_DONE; | 2675 | set_bit(CONF_INPUT_DONE, &chan->conf_state); |
2683 | 2676 | ||
2684 | if (chan->conf_state & L2CAP_CONF_OUTPUT_DONE) { | 2677 | if (test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) { |
2685 | set_default_fcs(chan); | 2678 | set_default_fcs(chan); |
2686 | 2679 | ||
2687 | l2cap_state_change(chan, BT_CONNECTED); | 2680 | l2cap_state_change(chan, BT_CONNECTED); |
@@ -4203,7 +4196,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
4203 | continue; | 4196 | continue; |
4204 | } | 4197 | } |
4205 | 4198 | ||
4206 | if (chan->conf_state & L2CAP_CONF_CONNECT_PEND) { | 4199 | if (test_bit(CONF_CONNECT_PEND, &chan->conf_state)) { |
4207 | bh_unlock_sock(sk); | 4200 | bh_unlock_sock(sk); |
4208 | continue; | 4201 | continue; |
4209 | } | 4202 | } |
@@ -4222,7 +4215,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
4222 | req.psm = chan->psm; | 4215 | req.psm = chan->psm; |
4223 | 4216 | ||
4224 | chan->ident = l2cap_get_ident(conn); | 4217 | chan->ident = l2cap_get_ident(conn); |
4225 | chan->conf_state |= L2CAP_CONF_CONNECT_PEND; | 4218 | set_bit(CONF_CONNECT_PEND, &chan->conf_state); |
4226 | 4219 | ||
4227 | l2cap_send_cmd(conn, chan->ident, | 4220 | l2cap_send_cmd(conn, chan->ident, |
4228 | L2CAP_CONN_REQ, sizeof(req), &req); | 4221 | L2CAP_CONN_REQ, sizeof(req), &req); |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 5c819e002fb1..39082d4e77ce 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -512,7 +512,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
512 | chan->mode = opts.mode; | 512 | chan->mode = opts.mode; |
513 | switch (chan->mode) { | 513 | switch (chan->mode) { |
514 | case L2CAP_MODE_BASIC: | 514 | case L2CAP_MODE_BASIC: |
515 | chan->conf_state &= ~L2CAP_CONF_STATE2_DEVICE; | 515 | clear_bit(CONF_STATE2_DEVICE, &chan->conf_state); |
516 | break; | 516 | break; |
517 | case L2CAP_MODE_ERTM: | 517 | case L2CAP_MODE_ERTM: |
518 | case L2CAP_MODE_STREAMING: | 518 | case L2CAP_MODE_STREAMING: |
@@ -891,7 +891,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
891 | chan->omtu = 0; | 891 | chan->omtu = 0; |
892 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { | 892 | if (!disable_ertm && sk->sk_type == SOCK_STREAM) { |
893 | chan->mode = L2CAP_MODE_ERTM; | 893 | chan->mode = L2CAP_MODE_ERTM; |
894 | chan->conf_state |= L2CAP_CONF_STATE2_DEVICE; | 894 | set_bit(CONF_STATE2_DEVICE, &chan->conf_state); |
895 | } else { | 895 | } else { |
896 | chan->mode = L2CAP_MODE_BASIC; | 896 | chan->mode = L2CAP_MODE_BASIC; |
897 | } | 897 | } |