aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-10 05:09:07 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-10 05:14:20 -0400
commit123abc0833181aec4796c628d9ffd608b2b41d5c (patch)
tree7b2b92bd4d9b6f1f1669b838742bb2eeacb96f3a
parent031547d8688a0fc5da875b504bf11e6c2e18390e (diff)
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>
-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 3844eeb85453..27c40e4901a3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2655,6 +2655,26 @@ done:
2655 return ret; 2655 return ret;
2656} 2656}
2657 2657
2658static void hci_update_scan_state(struct hci_dev *hdev, u8 scan)
2659{
2660 bool conn_changed;
2661
2662 BT_DBG("%s scan 0x%02x", hdev->name, scan);
2663
2664 if ((scan & SCAN_PAGE))
2665 conn_changed = !test_and_set_bit(HCI_CONNECTABLE,
2666 &hdev->dev_flags);
2667 else
2668 conn_changed = test_and_clear_bit(HCI_CONNECTABLE,
2669 &hdev->dev_flags);
2670
2671 if (!test_bit(HCI_MGMT, &hdev->dev_flags))
2672 return;
2673
2674 if (conn_changed)
2675 mgmt_new_settings(hdev);
2676}
2677
2658int hci_dev_cmd(unsigned int cmd, void __user *arg) 2678int hci_dev_cmd(unsigned int cmd, void __user *arg)
2659{ 2679{
2660 struct hci_dev *hdev; 2680 struct hci_dev *hdev;
@@ -2719,19 +2739,8 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
2719 /* Ensure that the connectable state gets correctly 2739 /* Ensure that the connectable state gets correctly
2720 * modified as this was a non-mgmt change. 2740 * modified as this was a non-mgmt change.
2721 */ 2741 */
2722 if (!err) { 2742 if (!err)
2723 bool changed; 2743 hci_update_scan_state(hdev, dr.dev_opt);
2724
2725 if ((dr.dev_opt & SCAN_PAGE))
2726 changed = !test_and_set_bit(HCI_CONNECTABLE,
2727 &hdev->dev_flags);
2728 else
2729 changed = test_and_clear_bit(HCI_CONNECTABLE,
2730 &hdev->dev_flags);
2731
2732 if (changed && test_bit(HCI_MGMT, &hdev->dev_flags))
2733 mgmt_new_settings(hdev);
2734 }
2735 break; 2744 break;
2736 2745
2737 case HCISETLINKPOL: 2746 case HCISETLINKPOL: