Commit 43bd0f32 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Gustavo F. Padovan

Bluetooth: convert role_switch variable to flag in l2cap chan

role_switch variable inside l2cap_chan is a logical one and can
be easily converted to flag
Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 15770b1a
...@@ -324,7 +324,6 @@ struct l2cap_chan { ...@@ -324,7 +324,6 @@ struct l2cap_chan {
__le16 sport; __le16 sport;
__u8 sec_level; __u8 sec_level;
__u8 role_switch;
__u8 ident; __u8 ident;
...@@ -463,6 +462,7 @@ enum { ...@@ -463,6 +462,7 @@ enum {
/* Definitions for flags in l2cap_chan */ /* Definitions for flags in l2cap_chan */
enum { enum {
FLAG_ROLE_SWITCH,
FLAG_FORCE_ACTIVE, FLAG_FORCE_ACTIVE,
FLAG_FORCE_RELIABLE, FLAG_FORCE_RELIABLE,
FLAG_FLUSHABLE, FLAG_FLUSHABLE,
......
...@@ -3938,12 +3938,12 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) ...@@ -3938,12 +3938,12 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) { if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) {
lm1 |= HCI_LM_ACCEPT; lm1 |= HCI_LM_ACCEPT;
if (c->role_switch) if (test_bit(FLAG_ROLE_SWITCH, &c->flags))
lm1 |= HCI_LM_MASTER; lm1 |= HCI_LM_MASTER;
exact++; exact++;
} else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) { } else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) {
lm2 |= HCI_LM_ACCEPT; lm2 |= HCI_LM_ACCEPT;
if (c->role_switch) if (test_bit(FLAG_ROLE_SWITCH, &c->flags))
lm2 |= HCI_LM_MASTER; lm2 |= HCI_LM_MASTER;
} }
} }
......
...@@ -356,7 +356,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us ...@@ -356,7 +356,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
break; break;
} }
if (chan->role_switch) if (test_bit(FLAG_ROLE_SWITCH, &chan->flags))
opt |= L2CAP_LM_MASTER; opt |= L2CAP_LM_MASTER;
if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
...@@ -549,7 +549,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us ...@@ -549,7 +549,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
if (opt & L2CAP_LM_SECURE) if (opt & L2CAP_LM_SECURE)
chan->sec_level = BT_SECURITY_HIGH; chan->sec_level = BT_SECURITY_HIGH;
chan->role_switch = (opt & L2CAP_LM_MASTER); if (opt & L2CAP_LM_MASTER)
set_bit(FLAG_ROLE_SWITCH, &chan->flags);
else
clear_bit(FLAG_ROLE_SWITCH, &chan->flags);
if (opt & L2CAP_LM_RELIABLE) if (opt & L2CAP_LM_RELIABLE)
set_bit(FLAG_FORCE_RELIABLE, &chan->flags); set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
...@@ -941,7 +944,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) ...@@ -941,7 +944,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->max_tx = pchan->max_tx; chan->max_tx = pchan->max_tx;
chan->tx_win = pchan->tx_win; chan->tx_win = pchan->tx_win;
chan->sec_level = pchan->sec_level; chan->sec_level = pchan->sec_level;
chan->role_switch = pchan->role_switch;
chan->flags = pchan->flags; chan->flags = pchan->flags;
} else { } else {
...@@ -970,7 +972,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) ...@@ -970,7 +972,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->fcs = L2CAP_FCS_CRC16; chan->fcs = L2CAP_FCS_CRC16;
chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
chan->sec_level = BT_SECURITY_LOW; chan->sec_level = BT_SECURITY_LOW;
chan->role_switch = 0;
chan->flags = 0; chan->flags = 0;
set_bit(FLAG_FORCE_ACTIVE, &chan->flags); set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment