diff options
author | Florian Grandel <fgrandel@gmail.com> | 2015-06-17 21:16:36 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-06-18 12:11:51 -0400 |
commit | 91aa9bb2e3d2130b0ef004d2a05cfda6f0222ce2 (patch) | |
tree | 693594f0a6c431fa23ec12d0fcb339d76f495684 /net/bluetooth/mgmt.c | |
parent | 5d900e4601391576a3c0644d7fcad1ebf41a516e (diff) |
Bluetooth: mgmt: dry update_scan_rsp_data()
update_scan_rsp_data() duplicates code from get_current_adv_instance().
This is being fixed by letting the former make use of the latter.
Signed-off-by: Florian Grandel <fgrandel@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index a8319f6cfa65..c3304164cab9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -832,6 +832,20 @@ static struct mgmt_pending_cmd *pending_find_data(u16 opcode, | |||
832 | return mgmt_pending_find_data(HCI_CHANNEL_CONTROL, opcode, hdev, data); | 832 | return mgmt_pending_find_data(HCI_CHANNEL_CONTROL, opcode, hdev, data); |
833 | } | 833 | } |
834 | 834 | ||
835 | static u8 get_current_adv_instance(struct hci_dev *hdev) | ||
836 | { | ||
837 | /* The "Set Advertising" setting supersedes the "Add Advertising" | ||
838 | * setting. Here we set the advertising data based on which | ||
839 | * setting was set. When neither apply, default to the global settings, | ||
840 | * represented by instance "0". | ||
841 | */ | ||
842 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING_INSTANCE) && | ||
843 | !hci_dev_test_flag(hdev, HCI_ADVERTISING)) | ||
844 | return 0x01; | ||
845 | |||
846 | return 0x00; | ||
847 | } | ||
848 | |||
835 | static u8 create_default_scan_rsp_data(struct hci_dev *hdev, u8 *ptr) | 849 | static u8 create_default_scan_rsp_data(struct hci_dev *hdev, u8 *ptr) |
836 | { | 850 | { |
837 | u8 ad_len = 0; | 851 | u8 ad_len = 0; |
@@ -900,21 +914,8 @@ static void update_scan_rsp_data_for_instance(struct hci_request *req, | |||
900 | 914 | ||
901 | static void update_scan_rsp_data(struct hci_request *req) | 915 | static void update_scan_rsp_data(struct hci_request *req) |
902 | { | 916 | { |
903 | struct hci_dev *hdev = req->hdev; | 917 | update_scan_rsp_data_for_instance(req, |
904 | u8 instance; | 918 | get_current_adv_instance(req->hdev)); |
905 | |||
906 | /* The "Set Advertising" setting supersedes the "Add Advertising" | ||
907 | * setting. Here we set the scan response data based on which | ||
908 | * setting was set. When neither apply, default to the global settings, | ||
909 | * represented by instance "0". | ||
910 | */ | ||
911 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING_INSTANCE) && | ||
912 | !hci_dev_test_flag(hdev, HCI_ADVERTISING)) | ||
913 | instance = 0x01; | ||
914 | else | ||
915 | instance = 0x00; | ||
916 | |||
917 | update_scan_rsp_data_for_instance(req, instance); | ||
918 | } | 919 | } |
919 | 920 | ||
920 | static u8 get_adv_discov_flags(struct hci_dev *hdev) | 921 | static u8 get_adv_discov_flags(struct hci_dev *hdev) |
@@ -941,20 +942,6 @@ static u8 get_adv_discov_flags(struct hci_dev *hdev) | |||
941 | return 0; | 942 | return 0; |
942 | } | 943 | } |
943 | 944 | ||
944 | static u8 get_current_adv_instance(struct hci_dev *hdev) | ||
945 | { | ||
946 | /* The "Set Advertising" setting supersedes the "Add Advertising" | ||
947 | * setting. Here we set the advertising data based on which | ||
948 | * setting was set. When neither apply, default to the global settings, | ||
949 | * represented by instance "0". | ||
950 | */ | ||
951 | if (hci_dev_test_flag(hdev, HCI_ADVERTISING_INSTANCE) && | ||
952 | !hci_dev_test_flag(hdev, HCI_ADVERTISING)) | ||
953 | return 0x01; | ||
954 | |||
955 | return 0x00; | ||
956 | } | ||
957 | |||
958 | static bool get_connectable(struct hci_dev *hdev) | 945 | static bool get_connectable(struct hci_dev *hdev) |
959 | { | 946 | { |
960 | struct mgmt_pending_cmd *cmd; | 947 | struct mgmt_pending_cmd *cmd; |
@@ -1093,10 +1080,7 @@ static void update_adv_data_for_instance(struct hci_request *req, u8 instance) | |||
1093 | 1080 | ||
1094 | static void update_adv_data(struct hci_request *req) | 1081 | static void update_adv_data(struct hci_request *req) |
1095 | { | 1082 | { |
1096 | struct hci_dev *hdev = req->hdev; | 1083 | update_adv_data_for_instance(req, get_current_adv_instance(req->hdev)); |
1097 | u8 instance = get_current_adv_instance(hdev); | ||
1098 | |||
1099 | update_adv_data_for_instance(req, instance); | ||
1100 | } | 1084 | } |
1101 | 1085 | ||
1102 | int mgmt_update_adv_data(struct hci_dev *hdev) | 1086 | int mgmt_update_adv_data(struct hci_dev *hdev) |