summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-10 12:09:07 +0300
committerMarcel Holtmann <marcel@holtmann.org>2014-07-10 11:14:20 +0200
commit123abc0833181aec4796c628d9ffd608b2b41d5c (patch)
tree7b2b92bd4d9b6f1f1669b838742bb2eeacb96f3a /net/bluetooth/hci_core.c
parent031547d8688a0fc5da875b504bf11e6c2e18390e (diff)
downloadop-kernel-dev-123abc0833181aec4796c628d9ffd608b2b41d5c.zip
op-kernel-dev-123abc0833181aec4796c628d9ffd608b2b41d5c.tar.gz
Bluetooth: Refactor ioctl scan state update to its own function
With subsequent patches we'll also need to update the discoverable state. As the code grows bigger it's better to move this out from the switch statement into its own function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3844eeb..27c40e4 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2655,6 +2655,26 @@ done:
return ret;
}
+static void hci_update_scan_state(struct hci_dev *hdev, u8 scan)
+{
+ bool conn_changed;
+
+ BT_DBG("%s scan 0x%02x", hdev->name, scan);
+
+ if ((scan & SCAN_PAGE))
+ conn_changed = !test_and_set_bit(HCI_CONNECTABLE,
+ &hdev->dev_flags);
+ else
+ conn_changed = test_and_clear_bit(HCI_CONNECTABLE,
+ &hdev->dev_flags);
+
+ if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ return;
+
+ if (conn_changed)
+ mgmt_new_settings(hdev);
+}
+
int hci_dev_cmd(unsigned int cmd, void __user *arg)
{
struct hci_dev *hdev;
@@ -2719,19 +2739,8 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
/* Ensure that the connectable state gets correctly
* modified as this was a non-mgmt change.
*/
- if (!err) {
- bool changed;
-
- if ((dr.dev_opt & SCAN_PAGE))
- changed = !test_and_set_bit(HCI_CONNECTABLE,
- &hdev->dev_flags);
- else
- changed = test_and_clear_bit(HCI_CONNECTABLE,
- &hdev->dev_flags);
-
- if (changed && test_bit(HCI_MGMT, &hdev->dev_flags))
- mgmt_new_settings(hdev);
- }
+ if (!err)
+ hci_update_scan_state(hdev, dr.dev_opt);
break;
case HCISETLINKPOL:
OpenPOWER on IntegriCloud