* [PATCHv3 0/4] Convert logical variable to flags
@ 2011-10-11 11:04 Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 11:04 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Changes:
* PATCHv3: following cumulative change applied:
@@ -944,14 +944,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->max_tx = pchan->max_tx;
chan->tx_win = pchan->tx_win;
chan->sec_level = pchan->sec_level;
- if (test_bit(FLAG_ROLE_SWITCH, &pchan->flags))
- set_bit(FLAG_ROLE_SWITCH, &chan->flags);
- if (test_bit(FLAG_FORCE_RELIABLE, &pchan->flags))
- set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
- if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
- set_bit(FLAG_FLUSHABLE, &chan->flags);
- if (test_bit(FLAG_FORCE_ACTIVE, &pchan->flags))
- set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
+ chan->flags = pchan->flags;
} else {
switch (sk->sk_type) {
@@ -979,9 +972,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->fcs = L2CAP_FCS_CRC16;
chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
chan->sec_level = BT_SECURITY_LOW;
- clear_bit(FLAG_ROLE_SWITCH, &chan->flags);
- clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
- clear_bit(FLAG_FLUSHABLE, &chan->flags);
+ chan->flags = 0;
set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
}
Andrei Emeltchenko (4):
Bluetooth: convert flushable variable to flag in l2cap chan
Bluetooth: convert force_reliable variable to flag in l2cap chan
Bluetooth: convert force_active variable to flag in l2cap chan
Bluetooth: convert role_switch variable to flag in l2cap chan
include/net/bluetooth/l2cap.h | 13 ++++++++---
net/bluetooth/l2cap_core.c | 13 ++++++-----
net/bluetooth/l2cap_sock.c | 43 ++++++++++++++++++++++++----------------
3 files changed, 42 insertions(+), 27 deletions(-)
--
1.7.4.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv3 1/4] Bluetooth: convert flushable variable to flag in l2cap chan
2011-10-11 11:04 [PATCHv3 0/4] Convert logical variable to flags Emeltchenko Andrei
@ 2011-10-11 11:04 ` Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 11:04 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
flushable variable inside l2cap_chan is a logical one and can
be easily converted to flag. Added flags in l2cap_chan structure.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/l2cap.h | 7 ++++++-
net/bluetooth/l2cap_core.c | 3 ++-
net/bluetooth/l2cap_sock.c | 12 ++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 2933767..0fe5d59 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -326,7 +326,6 @@ struct l2cap_chan {
__u8 sec_level;
__u8 role_switch;
__u8 force_reliable;
- __u8 flushable;
__u8 force_active;
__u8 ident;
@@ -346,6 +345,7 @@ struct l2cap_chan {
unsigned long conf_state;
unsigned long conn_state;
+ unsigned long flags;
__u8 next_tx_seq;
__u8 expected_ack_seq;
@@ -463,6 +463,11 @@ enum {
CONN_RNR_SENT,
};
+/* Definitions for flags in l2cap_chan */
+enum {
+ FLAG_FLUSHABLE,
+};
+
#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3158cec..b21ecff 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1253,7 +1253,8 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len);
- if (!chan->flushable && lmp_no_flush_capable(hcon->hdev))
+ if (!test_bit(FLAG_FLUSHABLE, &chan->flags) &&
+ lmp_no_flush_capable(hcon->hdev))
flags = ACL_START_NO_FLUSH;
else
flags = ACL_START;
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 61f1f62..99782cb 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -446,7 +446,8 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
case BT_FLUSHABLE:
- if (put_user(chan->flushable, (u32 __user *) optval))
+ if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags),
+ (u32 __user *) optval))
err = -EFAULT;
break;
@@ -655,7 +656,10 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
}
}
- chan->flushable = opt;
+ if (opt)
+ set_bit(FLAG_FLUSHABLE, &chan->flags);
+ else
+ clear_bit(FLAG_FLUSHABLE, &chan->flags);
break;
case BT_POWER:
@@ -931,7 +935,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->sec_level = pchan->sec_level;
chan->role_switch = pchan->role_switch;
chan->force_reliable = pchan->force_reliable;
- chan->flushable = pchan->flushable;
+ chan->flags = pchan->flags;
chan->force_active = pchan->force_active;
} else {
@@ -962,7 +966,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->sec_level = BT_SECURITY_LOW;
chan->role_switch = 0;
chan->force_reliable = 0;
- chan->flushable = BT_FLUSHABLE_OFF;
+ chan->flags = 0;
chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv3 2/4] Bluetooth: convert force_reliable variable to flag in l2cap chan
2011-10-11 11:04 [PATCHv3 0/4] Convert logical variable to flags Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
@ 2011-10-11 11:04 ` Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
3 siblings, 0 replies; 6+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 11:04 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
force_reliable variable inside l2cap_chan is a logical one and can
be easily converted to flag
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 2 +-
net/bluetooth/l2cap_sock.c | 10 ++++++----
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 0fe5d59..6c0d247 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -325,7 +325,6 @@ struct l2cap_chan {
__u8 sec_level;
__u8 role_switch;
- __u8 force_reliable;
__u8 force_active;
__u8 ident;
@@ -465,6 +464,7 @@ enum {
/* Definitions for flags in l2cap_chan */
enum {
+ FLAG_FORCE_RELIABLE,
FLAG_FLUSHABLE,
};
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b21ecff..57e4b2c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -948,7 +948,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
list_for_each_entry(chan, &conn->chan_l, list) {
struct sock *sk = chan->sk;
- if (chan->force_reliable)
+ if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
sk->sk_err = err;
}
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 99782cb..405d736 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -359,7 +359,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
if (chan->role_switch)
opt |= L2CAP_LM_MASTER;
- if (chan->force_reliable)
+ if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
opt |= L2CAP_LM_RELIABLE;
if (put_user(opt, (u32 __user *) optval))
@@ -550,7 +550,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
chan->sec_level = BT_SECURITY_HIGH;
chan->role_switch = (opt & L2CAP_LM_MASTER);
- chan->force_reliable = (opt & L2CAP_LM_RELIABLE);
+
+ if (opt & L2CAP_LM_RELIABLE)
+ set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
+ else
+ clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
break;
default:
@@ -934,7 +938,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->tx_win = pchan->tx_win;
chan->sec_level = pchan->sec_level;
chan->role_switch = pchan->role_switch;
- chan->force_reliable = pchan->force_reliable;
chan->flags = pchan->flags;
chan->force_active = pchan->force_active;
} else {
@@ -965,7 +968,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
chan->sec_level = BT_SECURITY_LOW;
chan->role_switch = 0;
- chan->force_reliable = 0;
chan->flags = 0;
chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv3 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
2011-10-11 11:04 [PATCHv3 0/4] Convert logical variable to flags Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
@ 2011-10-11 11:04 ` Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
3 siblings, 0 replies; 6+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 11:04 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
force_active variable inside l2cap_chan is a logical one and can
be easily converted to flag
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 4 ++--
net/bluetooth/l2cap_sock.c | 12 +++++++-----
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 6c0d247..440e7b8 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -325,7 +325,6 @@ struct l2cap_chan {
__u8 sec_level;
__u8 role_switch;
- __u8 force_active;
__u8 ident;
@@ -464,6 +463,7 @@ enum {
/* Definitions for flags in l2cap_chan */
enum {
+ FLAG_FORCE_ACTIVE,
FLAG_FORCE_RELIABLE,
FLAG_FLUSHABLE,
};
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 57e4b2c..aeeacf8 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -605,7 +605,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
else
flags = ACL_START;
- bt_cb(skb)->force_active = chan->force_active;
+ bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags);
hci_send_acl(chan->conn->hcon, skb, flags);
}
@@ -1259,7 +1259,7 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
else
flags = ACL_START;
- bt_cb(skb)->force_active = chan->force_active;
+ bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags);
hci_send_acl(hcon, skb, flags);
}
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 405d736..bf196c6 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -459,7 +459,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
}
- pwr.force_active = chan->force_active;
+ pwr.force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags);
len = min_t(unsigned int, len, sizeof(pwr));
if (copy_to_user(optval, (char *) &pwr, len))
@@ -680,7 +680,11 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
err = -EFAULT;
break;
}
- chan->force_active = pwr.force_active;
+
+ if (pwr.force_active)
+ set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
+ else
+ clear_bit(FLAG_FORCE_ACTIVE, &chan->flags);
break;
default:
@@ -939,7 +943,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->sec_level = pchan->sec_level;
chan->role_switch = pchan->role_switch;
chan->flags = pchan->flags;
- chan->force_active = pchan->force_active;
} else {
switch (sk->sk_type) {
@@ -969,8 +972,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->sec_level = BT_SECURITY_LOW;
chan->role_switch = 0;
chan->flags = 0;
- chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
-
+ set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
}
/* Default config options */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv3 4/4] Bluetooth: convert role_switch variable to flag in l2cap chan
2011-10-11 11:04 [PATCHv3 0/4] Convert logical variable to flags Emeltchenko Andrei
` (2 preceding siblings ...)
2011-10-11 11:04 ` [PATCHv3 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
@ 2011-10-11 11:04 ` Emeltchenko Andrei
2011-10-11 13:55 ` Gustavo Padovan
3 siblings, 1 reply; 6+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 11:04 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
role_switch variable inside l2cap_chan is a logical one and can
be easily converted to flag
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 4 ++--
net/bluetooth/l2cap_sock.c | 9 +++++----
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 440e7b8..aea083c 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -324,7 +324,6 @@ struct l2cap_chan {
__le16 sport;
__u8 sec_level;
- __u8 role_switch;
__u8 ident;
@@ -463,6 +462,7 @@ enum {
/* Definitions for flags in l2cap_chan */
enum {
+ FLAG_ROLE_SWITCH,
FLAG_FORCE_ACTIVE,
FLAG_FORCE_RELIABLE,
FLAG_FLUSHABLE,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index aeeacf8..18a08c5 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -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)) {
lm1 |= HCI_LM_ACCEPT;
- if (c->role_switch)
+ if (test_bit(FLAG_ROLE_SWITCH, &c->flags))
lm1 |= HCI_LM_MASTER;
exact++;
} else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) {
lm2 |= HCI_LM_ACCEPT;
- if (c->role_switch)
+ if (test_bit(FLAG_ROLE_SWITCH, &c->flags))
lm2 |= HCI_LM_MASTER;
}
}
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index bf196c6..48ad8ba 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -356,7 +356,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
break;
}
- if (chan->role_switch)
+ if (test_bit(FLAG_ROLE_SWITCH, &chan->flags))
opt |= L2CAP_LM_MASTER;
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
if (opt & L2CAP_LM_SECURE)
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)
set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
@@ -941,7 +944,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->max_tx = pchan->max_tx;
chan->tx_win = pchan->tx_win;
chan->sec_level = pchan->sec_level;
- chan->role_switch = pchan->role_switch;
chan->flags = pchan->flags;
} else {
@@ -970,7 +972,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
chan->fcs = L2CAP_FCS_CRC16;
chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
chan->sec_level = BT_SECURITY_LOW;
- chan->role_switch = 0;
chan->flags = 0;
set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv3 4/4] Bluetooth: convert role_switch variable to flag in l2cap chan
2011-10-11 11:04 ` [PATCHv3 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
@ 2011-10-11 13:55 ` Gustavo Padovan
0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2011-10-11 13:55 UTC (permalink / raw)
To: Emeltchenko Andrei; +Cc: linux-bluetooth
Hi Andrei,
* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-10-11 14:04:34 +0300]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> role_switch variable inside l2cap_chan is a logical one and can
> be easily converted to flag
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> include/net/bluetooth/l2cap.h | 2 +-
> net/bluetooth/l2cap_core.c | 4 ++--
> net/bluetooth/l2cap_sock.c | 9 +++++----
> 3 files changed, 8 insertions(+), 7 deletions(-)
All four patches applied, thanks.
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-11 13:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 11:04 [PATCHv3 0/4] Convert logical variable to flags Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
2011-10-11 11:04 ` [PATCHv3 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
2011-10-11 13:55 ` Gustavo Padovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).