diff options
Diffstat (limited to 'net/bluetooth')
| -rw-r--r-- | net/bluetooth/af_bluetooth.c | 60 | ||||
| -rw-r--r-- | net/bluetooth/cmtp/capi.c | 1 | ||||
| -rw-r--r-- | net/bluetooth/hci_debugfs.c | 210 | ||||
| -rw-r--r-- | net/bluetooth/hci_request.c | 64 | ||||
| -rw-r--r-- | net/bluetooth/hidp/core.c | 2 | 
5 files changed, 95 insertions, 242 deletions
| diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 91e3ba280706..84d92a077834 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -421,7 +421,7 @@ out:  }  EXPORT_SYMBOL(bt_sock_stream_recvmsg); -static inline unsigned int bt_accept_poll(struct sock *parent) +static inline __poll_t bt_accept_poll(struct sock *parent)  {  	struct bt_sock *s, *n;  	struct sock *sk; @@ -431,17 +431,17 @@ static inline unsigned int bt_accept_poll(struct sock *parent)  		if (sk->sk_state == BT_CONNECTED ||  		    (test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags) &&  		     sk->sk_state == BT_CONNECT2)) -			return POLLIN | POLLRDNORM; +			return EPOLLIN | EPOLLRDNORM;  	}  	return 0;  } -unsigned int bt_sock_poll(struct file *file, struct socket *sock, +__poll_t bt_sock_poll(struct file *file, struct socket *sock,  			  poll_table *wait)  {  	struct sock *sk = sock->sk; -	unsigned int mask = 0; +	__poll_t mask = 0;  	BT_DBG("sock %p, sk %p", sock, sk); @@ -451,20 +451,20 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,  		return bt_accept_poll(sk);  	if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) -		mask |= POLLERR | -			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); +		mask |= EPOLLERR | +			(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);  	if (sk->sk_shutdown & RCV_SHUTDOWN) -		mask |= POLLRDHUP | POLLIN | POLLRDNORM; +		mask |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;  	if (sk->sk_shutdown == SHUTDOWN_MASK) -		mask |= POLLHUP; +		mask |= EPOLLHUP;  	if (!skb_queue_empty(&sk->sk_receive_queue)) -		mask |= POLLIN | POLLRDNORM; +		mask |= EPOLLIN | EPOLLRDNORM;  	if (sk->sk_state == BT_CLOSED) -		mask |= POLLHUP; +		mask |= EPOLLHUP;  	if (sk->sk_state == BT_CONNECT ||  			sk->sk_state == BT_CONNECT2 || @@ -472,7 +472,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,  		return mask;  	if (!test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags) && sock_writeable(sk)) -		mask |= POLLOUT | POLLWRNORM | POLLWRBAND; +		mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND;  	else  		sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); @@ -766,43 +766,39 @@ static int __init bt_init(void)  		return err;  	err = sock_register(&bt_sock_family_ops); -	if (err < 0) { -		bt_sysfs_cleanup(); -		return err; -	} +	if (err) +		goto cleanup_sysfs;  	BT_INFO("HCI device and connection manager initialized");  	err = hci_sock_init(); -	if (err < 0) -		goto error; +	if (err) +		goto unregister_socket;  	err = l2cap_init(); -	if (err < 0) -		goto sock_err; +	if (err) +		goto cleanup_socket;  	err = sco_init(); -	if (err < 0) { -		l2cap_exit(); -		goto sock_err; -	} +	if (err) +		goto cleanup_cap;  	err = mgmt_init(); -	if (err < 0) { -		sco_exit(); -		l2cap_exit(); -		goto sock_err; -	} +	if (err) +		goto cleanup_sco;  	return 0; -sock_err: +cleanup_sco: +	sco_exit(); +cleanup_cap: +	l2cap_exit(); +cleanup_socket:  	hci_sock_cleanup(); - -error: +unregister_socket:  	sock_unregister(PF_BLUETOOTH); +cleanup_sysfs:  	bt_sysfs_cleanup(); -  	return err;  } diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c index bb308224099c..426a92f02db4 100644 --- a/net/bluetooth/cmtp/capi.c +++ b/net/bluetooth/cmtp/capi.c @@ -527,7 +527,6 @@ static int cmtp_proc_open(struct inode *inode, struct file *file)  }  static const struct file_operations cmtp_proc_fops = { -	.owner		= THIS_MODULE,  	.open		= cmtp_proc_open,  	.read		= seq_read,  	.llseek		= seq_lseek, diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c index 63df63ebfb24..418b76e557b0 100644 --- a/net/bluetooth/hci_debugfs.c +++ b/net/bluetooth/hci_debugfs.c @@ -88,17 +88,7 @@ static int __name ## _show(struct seq_file *f, void *ptr)		      \  	return 0;							      \  }									      \  									      \ -static int __name ## _open(struct inode *inode, struct file *file)	      \ -{									      \ -	return single_open(file, __name ## _show, inode->i_private);	      \ -}									      \ -									      \ -static const struct file_operations __name ## _fops = {			      \ -	.open		= __name ## _open,				      \ -	.read		= seq_read,					      \ -	.llseek		= seq_lseek,					      \ -	.release	= single_release,				      \ -}									      \ +DEFINE_SHOW_ATTRIBUTE(__name)  static int features_show(struct seq_file *f, void *ptr)  { @@ -106,37 +96,16 @@ static int features_show(struct seq_file *f, void *ptr)  	u8 p;  	hci_dev_lock(hdev); -	for (p = 0; p < HCI_MAX_PAGES && p <= hdev->max_page; p++) { -		seq_printf(f, "%2u: 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x " -			   "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n", p, -			   hdev->features[p][0], hdev->features[p][1], -			   hdev->features[p][2], hdev->features[p][3], -			   hdev->features[p][4], hdev->features[p][5], -			   hdev->features[p][6], hdev->features[p][7]); -	} +	for (p = 0; p < HCI_MAX_PAGES && p <= hdev->max_page; p++) +		seq_printf(f, "%2u: %8ph\n", p, hdev->features[p]);  	if (lmp_le_capable(hdev)) -		seq_printf(f, "LE: 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x " -			   "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n", -			   hdev->le_features[0], hdev->le_features[1], -			   hdev->le_features[2], hdev->le_features[3], -			   hdev->le_features[4], hdev->le_features[5], -			   hdev->le_features[6], hdev->le_features[7]); +		seq_printf(f, "LE: %8ph\n", hdev->le_features);  	hci_dev_unlock(hdev);  	return 0;  } -static int features_open(struct inode *inode, struct file *file) -{ -	return single_open(file, features_show, inode->i_private); -} - -static const struct file_operations features_fops = { -	.open		= features_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(features);  static int device_id_show(struct seq_file *f, void *ptr)  { @@ -150,17 +119,7 @@ static int device_id_show(struct seq_file *f, void *ptr)  	return 0;  } -static int device_id_open(struct inode *inode, struct file *file) -{ -	return single_open(file, device_id_show, inode->i_private); -} - -static const struct file_operations device_id_fops = { -	.open		= device_id_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(device_id);  static int device_list_show(struct seq_file *f, void *ptr)  { @@ -180,17 +139,7 @@ static int device_list_show(struct seq_file *f, void *ptr)  	return 0;  } -static int device_list_open(struct inode *inode, struct file *file) -{ -	return single_open(file, device_list_show, inode->i_private); -} - -static const struct file_operations device_list_fops = { -	.open		= device_list_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(device_list);  static int blacklist_show(struct seq_file *f, void *p)  { @@ -205,17 +154,7 @@ static int blacklist_show(struct seq_file *f, void *p)  	return 0;  } -static int blacklist_open(struct inode *inode, struct file *file) -{ -	return single_open(file, blacklist_show, inode->i_private); -} - -static const struct file_operations blacklist_fops = { -	.open		= blacklist_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(blacklist);  static int uuids_show(struct seq_file *f, void *p)  { @@ -240,17 +179,7 @@ static int uuids_show(struct seq_file *f, void *p)         return 0;  } -static int uuids_open(struct inode *inode, struct file *file) -{ -	return single_open(file, uuids_show, inode->i_private); -} - -static const struct file_operations uuids_fops = { -	.open		= uuids_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(uuids);  static int remote_oob_show(struct seq_file *f, void *ptr)  { @@ -269,17 +198,7 @@ static int remote_oob_show(struct seq_file *f, void *ptr)  	return 0;  } -static int remote_oob_open(struct inode *inode, struct file *file) -{ -	return single_open(file, remote_oob_show, inode->i_private); -} - -static const struct file_operations remote_oob_fops = { -	.open		= remote_oob_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(remote_oob);  static int conn_info_min_age_set(void *data, u64 val)  { @@ -443,17 +362,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p)  	return 0;  } -static int inquiry_cache_open(struct inode *inode, struct file *file) -{ -	return single_open(file, inquiry_cache_show, inode->i_private); -} - -static const struct file_operations inquiry_cache_fops = { -	.open		= inquiry_cache_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(inquiry_cache);  static int link_keys_show(struct seq_file *f, void *ptr)  { @@ -469,17 +378,7 @@ static int link_keys_show(struct seq_file *f, void *ptr)  	return 0;  } -static int link_keys_open(struct inode *inode, struct file *file) -{ -	return single_open(file, link_keys_show, inode->i_private); -} - -static const struct file_operations link_keys_fops = { -	.open		= link_keys_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(link_keys);  static int dev_class_show(struct seq_file *f, void *ptr)  { @@ -493,17 +392,7 @@ static int dev_class_show(struct seq_file *f, void *ptr)  	return 0;  } -static int dev_class_open(struct inode *inode, struct file *file) -{ -	return single_open(file, dev_class_show, inode->i_private); -} - -static const struct file_operations dev_class_fops = { -	.open		= dev_class_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(dev_class);  static int voice_setting_get(void *data, u64 *val)  { @@ -692,17 +581,7 @@ static int identity_show(struct seq_file *f, void *p)  	return 0;  } -static int identity_open(struct inode *inode, struct file *file) -{ -	return single_open(file, identity_show, inode->i_private); -} - -static const struct file_operations identity_fops = { -	.open		= identity_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(identity);  static int rpa_timeout_set(void *data, u64 val)  { @@ -746,17 +625,7 @@ static int random_address_show(struct seq_file *f, void *p)  	return 0;  } -static int random_address_open(struct inode *inode, struct file *file) -{ -	return single_open(file, random_address_show, inode->i_private); -} - -static const struct file_operations random_address_fops = { -	.open		= random_address_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(random_address);  static int static_address_show(struct seq_file *f, void *p)  { @@ -769,17 +638,7 @@ static int static_address_show(struct seq_file *f, void *p)  	return 0;  } -static int static_address_open(struct inode *inode, struct file *file) -{ -	return single_open(file, static_address_show, inode->i_private); -} - -static const struct file_operations static_address_fops = { -	.open		= static_address_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(static_address);  static ssize_t force_static_address_read(struct file *file,  					 char __user *user_buf, @@ -841,17 +700,7 @@ static int white_list_show(struct seq_file *f, void *ptr)  	return 0;  } -static int white_list_open(struct inode *inode, struct file *file) -{ -	return single_open(file, white_list_show, inode->i_private); -} - -static const struct file_operations white_list_fops = { -	.open		= white_list_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(white_list);  static int identity_resolving_keys_show(struct seq_file *f, void *ptr)  { @@ -869,18 +718,7 @@ static int identity_resolving_keys_show(struct seq_file *f, void *ptr)  	return 0;  } -static int identity_resolving_keys_open(struct inode *inode, struct file *file) -{ -	return single_open(file, identity_resolving_keys_show, -			   inode->i_private); -} - -static const struct file_operations identity_resolving_keys_fops = { -	.open		= identity_resolving_keys_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(identity_resolving_keys);  static int long_term_keys_show(struct seq_file *f, void *ptr)  { @@ -898,17 +736,7 @@ static int long_term_keys_show(struct seq_file *f, void *ptr)  	return 0;  } -static int long_term_keys_open(struct inode *inode, struct file *file) -{ -	return single_open(file, long_term_keys_show, inode->i_private); -} - -static const struct file_operations long_term_keys_fops = { -	.open		= long_term_keys_open, -	.read		= seq_read, -	.llseek		= seq_lseek, -	.release	= single_release, -}; +DEFINE_SHOW_ATTRIBUTE(long_term_keys);  static int conn_min_interval_set(void *data, u64 val)  { diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index abc0f3224dd1..3394e6791673 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -919,6 +919,43 @@ static bool adv_use_rpa(struct hci_dev *hdev, uint32_t flags)  	return true;  } +static bool is_advertising_allowed(struct hci_dev *hdev, bool connectable) +{ +	/* If there is no connection we are OK to advertise. */ +	if (hci_conn_num(hdev, LE_LINK) == 0) +		return true; + +	/* Check le_states if there is any connection in slave role. */ +	if (hdev->conn_hash.le_num_slave > 0) { +		/* Slave connection state and non connectable mode bit 20. */ +		if (!connectable && !(hdev->le_states[2] & 0x10)) +			return false; + +		/* Slave connection state and connectable mode bit 38 +		 * and scannable bit 21. +		 */ +		if (connectable && (!(hdev->le_states[4] & 0x01) || +				    !(hdev->le_states[2] & 0x40))) +			return false; +	} + +	/* Check le_states if there is any connection in master role. */ +	if (hci_conn_num(hdev, LE_LINK) != hdev->conn_hash.le_num_slave) { +		/* Master connection state and non connectable mode bit 18. */ +		if (!connectable && !(hdev->le_states[2] & 0x02)) +			return false; + +		/* Master connection state and connectable mode bit 35 and +		 * scannable 19. +		 */ +		if (connectable && (!(hdev->le_states[4] & 0x10) || +				    !(hdev->le_states[2] & 0x08))) +			return false; +	} + +	return true; +} +  void __hci_req_enable_advertising(struct hci_request *req)  {  	struct hci_dev *hdev = req->hdev; @@ -927,7 +964,15 @@ void __hci_req_enable_advertising(struct hci_request *req)  	bool connectable;  	u32 flags; -	if (hci_conn_num(hdev, LE_LINK) > 0) +	flags = get_adv_instance_flags(hdev, hdev->cur_adv_instance); + +	/* If the "connectable" instance flag was not set, then choose between +	 * ADV_IND and ADV_NONCONN_IND based on the global connectable setting. +	 */ +	connectable = (flags & MGMT_ADV_FLAG_CONNECTABLE) || +		      mgmt_get_connectable(hdev); + +	if (!is_advertising_allowed(hdev, connectable))  		return;  	if (hci_dev_test_flag(hdev, HCI_LE_ADV)) @@ -940,14 +985,6 @@ void __hci_req_enable_advertising(struct hci_request *req)  	 */  	hci_dev_clear_flag(hdev, HCI_LE_ADV); -	flags = get_adv_instance_flags(hdev, hdev->cur_adv_instance); - -	/* If the "connectable" instance flag was not set, then choose between -	 * ADV_IND and ADV_NONCONN_IND based on the global connectable setting. -	 */ -	connectable = (flags & MGMT_ADV_FLAG_CONNECTABLE) || -		      mgmt_get_connectable(hdev); -  	/* Set require_privacy to true only when non-connectable  	 * advertising is used. In that case it is fine to use a  	 * non-resolvable private address. @@ -1985,13 +2022,6 @@ unlock:  	hci_dev_unlock(hdev);  } -static void disable_advertising(struct hci_request *req) -{ -	u8 enable = 0x00; - -	hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable); -} -  static int active_scan(struct hci_request *req, unsigned long opt)  {  	uint16_t interval = opt; @@ -2017,7 +2047,7 @@ static int active_scan(struct hci_request *req, unsigned long opt)  		cancel_adv_timeout(hdev);  		hci_dev_unlock(hdev); -		disable_advertising(req); +		__hci_req_disable_advertising(req);  	}  	/* If controller is scanning, it means the background scanning is diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index f2cec70d520c..1036e4fa1ea2 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -789,7 +789,7 @@ static int hidp_setup_hid(struct hidp_session *session,  	hid->dev.parent = &session->conn->hcon->dev;  	hid->ll_driver = &hidp_hid_driver; -	/* True if device is blacklisted in drivers/hid/hid-core.c */ +	/* True if device is blacklisted in drivers/hid/hid-quirks.c */  	if (hid_ignore(hid)) {  		hid_destroy_device(session->hid);  		session->hid = NULL; |