diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2012-02-17 18:39:35 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-19 05:32:21 -0500 |
commit | f39799f5047c4827b200acbf33cd0ba076afd7ed (patch) | |
tree | 91aaf60a5aeb5e0bbac57ec056f71552a695372a /net/bluetooth/mgmt.c | |
parent | ea585ab51d3fe2eb2d738c91f83e7c309e76b4fe (diff) |
Bluetooth: Prepare start_discovery
This patch does some code refactoring in start_discovery function
in order to prepare it for interleaved discovery support.
MGMT_ADDR_* macros were moved to hci_core.h since they are now used
to define discovery type macros.
Discovery type macros were defined according to mgmt-api.txt
specification:
Possible values for the Type parameter are a bit-wise or of the
following bits:
1 BR/EDR
2 LE Public
3 LE Random
By combining these e.g. the following values are possible:
1 BR/EDR
6 LE (public & random)
7 BR/EDR/LE (interleaved discovery)
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index f9f3e4c44150..196215c9d424 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2157,7 +2157,6 @@ static int start_discovery(struct sock *sk, u16 index, | |||
2157 | void *data, u16 len) | 2157 | void *data, u16 len) |
2158 | { | 2158 | { |
2159 | struct mgmt_cp_start_discovery *cp = data; | 2159 | struct mgmt_cp_start_discovery *cp = data; |
2160 | unsigned long discov_type = cp->type; | ||
2161 | struct pending_cmd *cmd; | 2160 | struct pending_cmd *cmd; |
2162 | struct hci_dev *hdev; | 2161 | struct hci_dev *hdev; |
2163 | int err; | 2162 | int err; |
@@ -2193,14 +2192,20 @@ static int start_discovery(struct sock *sk, u16 index, | |||
2193 | goto failed; | 2192 | goto failed; |
2194 | } | 2193 | } |
2195 | 2194 | ||
2196 | if (test_bit(MGMT_ADDR_BREDR, &discov_type)) | 2195 | switch (cp->type) { |
2196 | case DISCOV_TYPE_BREDR: | ||
2197 | case DISCOV_TYPE_INTERLEAVED: | ||
2197 | err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); | 2198 | err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); |
2198 | else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) && | 2199 | break; |
2199 | test_bit(MGMT_ADDR_LE_RANDOM, &discov_type)) | 2200 | |
2201 | case DISCOV_TYPE_LE: | ||
2200 | err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, | 2202 | err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, |
2201 | LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); | 2203 | LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); |
2202 | else | 2204 | break; |
2205 | |||
2206 | default: | ||
2203 | err = -EINVAL; | 2207 | err = -EINVAL; |
2208 | } | ||
2204 | 2209 | ||
2205 | if (err < 0) | 2210 | if (err < 0) |
2206 | mgmt_pending_remove(cmd); | 2211 | mgmt_pending_remove(cmd); |