Bluetooth: Get rid of __rfcomm_get_sock_by_channel()
rfcomm_get_sock_by_channel() was the only user of this function, so I merged both into rfcomm_get_sock_by_channel(). The socket lock now should be hold outside of rfcomm_get_sock_by_channel() once we hold and release it inside the same function now. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
		
					parent
					
						
							
								e0f0cb5636
							
						
					
				
			
			
				commit
				
					
						eeb366564b
					
				
			
		
					 1 changed files with 7 additions and 12 deletions
				
			
		| 
						 | 
					@ -140,11 +140,13 @@ static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
 | 
				
			||||||
/* Find socket with channel and source bdaddr.
 | 
					/* Find socket with channel and source bdaddr.
 | 
				
			||||||
 * Returns closest match.
 | 
					 * Returns closest match.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static struct sock *__rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
 | 
					static struct sock *rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sock *sk = NULL, *sk1 = NULL;
 | 
						struct sock *sk = NULL, *sk1 = NULL;
 | 
				
			||||||
	struct hlist_node *node;
 | 
						struct hlist_node *node;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						read_lock(&rfcomm_sk_list.lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sk_for_each(sk, node, &rfcomm_sk_list.head) {
 | 
						sk_for_each(sk, node, &rfcomm_sk_list.head) {
 | 
				
			||||||
		if (state && sk->sk_state != state)
 | 
							if (state && sk->sk_state != state)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
| 
						 | 
					@ -159,19 +161,10 @@ static struct sock *__rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t
 | 
				
			||||||
				sk1 = sk;
 | 
									sk1 = sk;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return node ? sk : sk1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find socket with given address (channel, src).
 | 
					 | 
				
			||||||
 * Returns locked socket */
 | 
					 | 
				
			||||||
static inline struct sock *rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct sock *s;
 | 
					 | 
				
			||||||
	read_lock(&rfcomm_sk_list.lock);
 | 
					 | 
				
			||||||
	s = __rfcomm_get_sock_by_channel(state, channel, src);
 | 
					 | 
				
			||||||
	if (s) bh_lock_sock(s);
 | 
					 | 
				
			||||||
	read_unlock(&rfcomm_sk_list.lock);
 | 
						read_unlock(&rfcomm_sk_list.lock);
 | 
				
			||||||
	return s;
 | 
					
 | 
				
			||||||
 | 
						return node ? sk : sk1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void rfcomm_sock_destruct(struct sock *sk)
 | 
					static void rfcomm_sock_destruct(struct sock *sk)
 | 
				
			||||||
| 
						 | 
					@ -945,6 +938,8 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
 | 
				
			||||||
	if (!parent)
 | 
						if (!parent)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bh_lock_sock(parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check for backlog size */
 | 
						/* Check for backlog size */
 | 
				
			||||||
	if (sk_acceptq_is_full(parent)) {
 | 
						if (sk_acceptq_is_full(parent)) {
 | 
				
			||||||
		BT_DBG("backlog full %d", parent->sk_ack_backlog);
 | 
							BT_DBG("backlog full %d", parent->sk_ack_backlog);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue