All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan
@ 2011-10-10  7:33 Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-10  7:33 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    |   13 +++++++++----
 3 files changed, 17 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..be45529 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,8 @@ 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;
+		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
+			set_bit(FLAG_FLUSHABLE, &chan->flags);
 		chan->force_active = pchan->force_active;
 	} else {
 
@@ -962,7 +967,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;
+		clear_bit(FLAG_FLUSHABLE, &chan->flags);
 		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
 
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] Bluetooth: convert force_reliable variable to flag in l2cap chan
  2011-10-10  7:33 [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
@ 2011-10-10  7:33 ` Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
  2 siblings, 0 replies; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-10  7:33 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    |   13 +++++++++----
 3 files changed, 11 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 be45529..51949f7 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,8 @@ 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;
+		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);
 		chan->force_active = pchan->force_active;
@@ -966,7 +971,7 @@ 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;
+		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
 		clear_bit(FLAG_FLUSHABLE, &chan->flags);
 		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-10  7:33 [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
@ 2011-10-10  7:33 ` Emeltchenko Andrei
  2011-10-10 21:07   ` Gustavo Padovan
  2011-10-10  7:33 ` [PATCH 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
  2 siblings, 1 reply; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-10  7:33 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    |   14 +++++++++-----
 3 files changed, 12 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 51949f7..91c537d 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:
@@ -942,7 +946,8 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 			set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
 		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
 			set_bit(FLAG_FLUSHABLE, &chan->flags);
-		chan->force_active = pchan->force_active;
+		if (test_bit(FLAG_FORCE_ACTIVE, &pchan->flags))
+			set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
 	} else {
 
 		switch (sk->sk_type) {
@@ -973,8 +978,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 		chan->role_switch = 0;
 		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
 		clear_bit(FLAG_FLUSHABLE, &chan->flags);
-		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] 12+ messages in thread

* [PATCH 4/4] Bluetooth: convert role_switch variable to flag in l2cap chan
  2011-10-10  7:33 [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
  2011-10-10  7:33 ` [PATCH 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
@ 2011-10-10  7:33 ` Emeltchenko Andrei
  2 siblings, 0 replies; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-10  7:33 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    |   12 ++++++++----
 3 files changed, 11 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 91c537d..0143410 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,8 @@ 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;
+		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))
@@ -975,7 +979,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;
-		chan->role_switch = 0;
+		clear_bit(FLAG_ROLE_SWITCH, &chan->flags);
 		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
 		clear_bit(FLAG_FLUSHABLE, &chan->flags);
 		set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-10  7:33 ` [PATCH 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
@ 2011-10-10 21:07   ` Gustavo Padovan
  2011-10-11  7:50     ` Emeltchenko Andrei
  0 siblings, 1 reply; 12+ messages in thread
From: Gustavo Padovan @ 2011-10-10 21:07 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth

Hi Andrei,

* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-10-10 10:33:53 +0300]:

> 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    |   14 +++++++++-----
>  3 files changed, 12 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 51949f7..91c537d 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:
> @@ -942,7 +946,8 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
>  			set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
>  		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
>  			set_bit(FLAG_FLUSHABLE, &chan->flags);
> -		chan->force_active = pchan->force_active;
> +		if (test_bit(FLAG_FORCE_ACTIVE, &pchan->flags))
> +			set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
>  	} else {
>  
>  		switch (sk->sk_type) {
> @@ -973,8 +978,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
>  		chan->role_switch = 0;
>  		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
>  		clear_bit(FLAG_FLUSHABLE, &chan->flags);
> -		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
> -
> +		set_bit(FLAG_FORCE_ACTIVE, &chan->flags);

One last comment: set chan->flags to 0 here, the just to set the bits that
needs to be 1 at initialization.

	Gustavo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-10 21:07   ` Gustavo Padovan
@ 2011-10-11  7:50     ` Emeltchenko Andrei
  2011-10-11  9:44       ` Emeltchenko Andrei
  0 siblings, 1 reply; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11  7:50 UTC (permalink / raw)
  To: linux-bluetooth

Hi Gustavo,

On Mon, Oct 10, 2011 at 06:07:06PM -0300, Gustavo Padovan wrote:
> > 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    |   14 +++++++++-----
> >  3 files changed, 12 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 51949f7..91c537d 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:
> > @@ -942,7 +946,8 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
> >  			set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
> >  		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
> >  			set_bit(FLAG_FLUSHABLE, &chan->flags);
> > -		chan->force_active = pchan->force_active;
> > +		if (test_bit(FLAG_FORCE_ACTIVE, &pchan->flags))
> > +			set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
> >  	} else {
> >  
> >  		switch (sk->sk_type) {
> > @@ -973,8 +978,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
> >  		chan->role_switch = 0;
> >  		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
> >  		clear_bit(FLAG_FLUSHABLE, &chan->flags);
> > -		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
> > -
> > +		set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
> 
> One last comment: set chan->flags to 0 here, the just to set the bits that
> needs to be 1 at initialization.

Sorry do not understand this :-(

Do you mean assign chan->flags = 0; and set_bit only for
FLAG_FORCE_ACTIVE?

Best regards 
Andrei Emeltchenko 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-11  7:50     ` Emeltchenko Andrei
@ 2011-10-11  9:44       ` Emeltchenko Andrei
  2011-10-11 10:01         ` Szymon Janc
  0 siblings, 1 reply; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11  9:44 UTC (permalink / raw)
  To: linux-bluetooth

Hi Gustavo,

On Tue, Oct 11, 2011 at 10:50:34AM +0300, Emeltchenko Andrei wrote:
> > > @@ -942,7 +946,8 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
> > >  			set_bit(FLAG_FORCE_RELIABLE, &chan->flags);
> > >  		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
> > >  			set_bit(FLAG_FLUSHABLE, &chan->flags);
> > > -		chan->force_active = pchan->force_active;
> > > +		if (test_bit(FLAG_FORCE_ACTIVE, &pchan->flags))
> > > +			set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
> > >  	} else {
> > >  
> > >  		switch (sk->sk_type) {
> > > @@ -973,8 +978,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
> > >  		chan->role_switch = 0;
> > >  		clear_bit(FLAG_FORCE_RELIABLE, &chan->flags);
> > >  		clear_bit(FLAG_FLUSHABLE, &chan->flags);
> > > -		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
> > > -
> > > +		set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
> > 
> > One last comment: set chan->flags to 0 here, the just to set the bits that
> > needs to be 1 at initialization.
> 
> Sorry do not understand this :-(
> 
> Do you mean assign chan->flags = 0; and set_bit only for
> FLAG_FORCE_ACTIVE?

Just sent patches with cumulative difference below:


diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 3ca71b4..4b388b7 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -979,9 +979,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);
        }


Best regards 
Andrei Emeltchenko 


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-11  9:44       ` Emeltchenko Andrei
@ 2011-10-11 10:01         ` Szymon Janc
  2011-10-11 10:34           ` Emeltchenko Andrei
  0 siblings, 1 reply; 12+ messages in thread
From: Szymon Janc @ 2011-10-11 10:01 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth

Hi,

> > Sorry do not understand this :-(
> > 
> > Do you mean assign chan->flags = 0; and set_bit only for
> > FLAG_FORCE_ACTIVE?
> 
> Just sent patches with cumulative difference below:

I guess you could do similar in l2cap_sock_init() chan->flags = pchan->flags
instead of test_bit/set_bit burst.
 
> 
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 3ca71b4..4b388b7 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -979,9 +979,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);
>         }

-- 
BR
Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] Bluetooth: convert force_active variable to flag in l2cap chan
  2011-10-11 10:01         ` Szymon Janc
@ 2011-10-11 10:34           ` Emeltchenko Andrei
  0 siblings, 0 replies; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-11 10:34 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

On Tue, Oct 11, 2011 at 12:01:10PM +0200, Szymon Janc wrote:
> Hi,
> 
> > > Sorry do not understand this :-(
> > > 
> > > Do you mean assign chan->flags = 0; and set_bit only for
> > > FLAG_FORCE_ACTIVE?
> > 
> > Just sent patches with cumulative difference below:
> 
> I guess you could do similar in l2cap_sock_init() chan->flags = pchan->flags
> instead of test_bit/set_bit burst.

yes, I will change this way.

Best regards 
Andrei Emeltchenko 

>  
> > 
> > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > index 3ca71b4..4b388b7 100644
> > --- a/net/bluetooth/l2cap_sock.c
> > +++ b/net/bluetooth/l2cap_sock.c
> > @@ -979,9 +979,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);
> >         }
> 
> -- 
> BR
> Szymon Janc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan
  2011-10-07 18:22 ` Gustavo Padovan
@ 2011-10-10  7:35   ` Emeltchenko Andrei
  0 siblings, 0 replies; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-10  7:35 UTC (permalink / raw)
  To: linux-bluetooth

Hi Gustavo,

On Fri, Oct 07, 2011 at 03:22:14PM -0300, Gustavo Padovan wrote:
> > diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> > index 61f1f62..81fc8f0 100644
> > --- a/net/bluetooth/l2cap_sock.c
> > +++ b/net/bluetooth/l2cap_sock.c
> > @@ -446,14 +446,15 @@ 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;
> >  
> >  	case BT_POWER:
> >  		if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM
> > -				&& sk->sk_type != SOCK_RAW) {
> > +						&& sk->sk_type != SOCK_RAW) {
> 
> This change doesn't belong to this patch. Please fix this and resend.

I've just sent patch without this cosmetic change.

Best regards 
Andrei Emeltchenko 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan
  2011-10-07 13:54 [PATCH 1/4] Bluetooth: convert flushable " Emeltchenko Andrei
@ 2011-10-07 18:22 ` Gustavo Padovan
  2011-10-10  7:35   ` Emeltchenko Andrei
  0 siblings, 1 reply; 12+ messages in thread
From: Gustavo Padovan @ 2011-10-07 18:22 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth

Hi Andrei,

* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2011-10-07 16:54:03 +0300]:

> 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    |   15 ++++++++++-----
>  3 files changed, 18 insertions(+), 7 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..81fc8f0 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -446,14 +446,15 @@ 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;
>  
>  	case BT_POWER:
>  		if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM
> -				&& sk->sk_type != SOCK_RAW) {
> +						&& sk->sk_type != SOCK_RAW) {

This change doesn't belong to this patch. Please fix this and resend.

	Gustavo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan
@ 2011-10-07 13:54 Emeltchenko Andrei
  2011-10-07 18:22 ` Gustavo Padovan
  0 siblings, 1 reply; 12+ messages in thread
From: Emeltchenko Andrei @ 2011-10-07 13:54 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    |   15 ++++++++++-----
 3 files changed, 18 insertions(+), 7 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..81fc8f0 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -446,14 +446,15 @@ 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;
 
 	case BT_POWER:
 		if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM
-				&& sk->sk_type != SOCK_RAW) {
+						&& sk->sk_type != SOCK_RAW) {
 			err = -EINVAL;
 			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,8 @@ 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;
+		if (test_bit(FLAG_FLUSHABLE, &pchan->flags))
+			set_bit(FLAG_FLUSHABLE, &chan->flags);
 		chan->force_active = pchan->force_active;
 	} else {
 
@@ -962,7 +967,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;
+		clear_bit(FLAG_FLUSHABLE, &chan->flags);
 		chan->force_active = BT_POWER_FORCE_ACTIVE_ON;
 
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-10-11 10:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-10  7:33 [PATCH 1/4] Bluetooth: convert flushable variable to flag in l2cap chan Emeltchenko Andrei
2011-10-10  7:33 ` [PATCH 2/4] Bluetooth: convert force_reliable " Emeltchenko Andrei
2011-10-10  7:33 ` [PATCH 3/4] Bluetooth: convert force_active " Emeltchenko Andrei
2011-10-10 21:07   ` Gustavo Padovan
2011-10-11  7:50     ` Emeltchenko Andrei
2011-10-11  9:44       ` Emeltchenko Andrei
2011-10-11 10:01         ` Szymon Janc
2011-10-11 10:34           ` Emeltchenko Andrei
2011-10-10  7:33 ` [PATCH 4/4] Bluetooth: convert role_switch " Emeltchenko Andrei
  -- strict thread matches above, loose matches on Subject: below --
2011-10-07 13:54 [PATCH 1/4] Bluetooth: convert flushable " Emeltchenko Andrei
2011-10-07 18:22 ` Gustavo Padovan
2011-10-10  7:35   ` Emeltchenko Andrei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.