diff options
Diffstat (limited to 'net/bluetooth/rfcomm/core.c')
| -rw-r--r-- | net/bluetooth/rfcomm/core.c | 37 | 
1 files changed, 20 insertions, 17 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 4e32e18211f..501649bf559 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c @@ -51,8 +51,8 @@  #define VERSION "1.11" -static int disable_cfc; -static int l2cap_ertm; +static bool disable_cfc; +static bool l2cap_ertm;  static int channel_mtu = -1;  static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; @@ -377,13 +377,11 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d)  static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci)  {  	struct rfcomm_dlc *d; -	struct list_head *p; -	list_for_each(p, &s->dlcs) { -		d = list_entry(p, struct rfcomm_dlc, list); +	list_for_each_entry(d, &s->dlcs, list)  		if (d->dlci == dlci)  			return d; -	} +  	return NULL;  } @@ -751,7 +749,6 @@ void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *d  /* ---- RFCOMM frame sending ---- */  static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len)  { -	struct socket *sock = s->sock;  	struct kvec iv = { data, len };  	struct msghdr msg; @@ -759,7 +756,14 @@ static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len)  	memset(&msg, 0, sizeof(msg)); -	return kernel_sendmsg(sock, &msg, &iv, 1, len); +	return kernel_sendmsg(s->sock, &msg, &iv, 1, len); +} + +static int rfcomm_send_cmd(struct rfcomm_session *s, struct rfcomm_cmd *cmd) +{ +	BT_DBG("%p cmd %u", s, cmd->ctrl); + +	return rfcomm_send_frame(s, (void *) cmd, sizeof(*cmd));  }  static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) @@ -773,7 +777,7 @@ static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci)  	cmd.len  = __len8(0);  	cmd.fcs  = __fcs2((u8 *) &cmd); -	return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); +	return rfcomm_send_cmd(s, &cmd);  }  static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) @@ -787,7 +791,7 @@ static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci)  	cmd.len  = __len8(0);  	cmd.fcs  = __fcs2((u8 *) &cmd); -	return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); +	return rfcomm_send_cmd(s, &cmd);  }  static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) @@ -801,7 +805,7 @@ static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci)  	cmd.len  = __len8(0);  	cmd.fcs  = __fcs2((u8 *) &cmd); -	return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); +	return rfcomm_send_cmd(s, &cmd);  }  static int rfcomm_queue_disc(struct rfcomm_dlc *d) @@ -837,7 +841,7 @@ static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci)  	cmd.len  = __len8(0);  	cmd.fcs  = __fcs2((u8 *) &cmd); -	return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); +	return rfcomm_send_cmd(s, &cmd);  }  static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) @@ -1146,6 +1150,7 @@ static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)  			if (list_empty(&s->dlcs)) {  				s->state = BT_DISCONN;  				rfcomm_send_disc(s, 0); +				rfcomm_session_clear_timer(s);  			}  			break; @@ -2120,15 +2125,13 @@ static struct hci_cb rfcomm_cb = {  static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)  {  	struct rfcomm_session *s; -	struct list_head *pp, *p;  	rfcomm_lock(); -	list_for_each(p, &session_list) { -		s = list_entry(p, struct rfcomm_session, list); -		list_for_each(pp, &s->dlcs) { +	list_for_each_entry(s, &session_list, list) { +		struct rfcomm_dlc *d; +		list_for_each_entry(d, &s->dlcs, list) {  			struct sock *sk = s->sock->sk; -			struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);  			seq_printf(f, "%s %s %ld %d %d %d %d\n",  						batostr(&bt_sk(sk)->src),  |